From 5ccb7daadb0d6936a0c279bc71272c6fb36fda29 Mon Sep 17 00:00:00 2001 From: Cody Robertson Date: Tue, 10 Dec 2024 14:09:58 -0500 Subject: [PATCH] Several tweaks to #709 - You can find explanations of the changes in https://github.com/AlmaLinux/almalinux.org/pull/709 --- .devcontainer/Dockerfile | 13 ++++++++++--- .devcontainer/devcontainer.json | 22 ++++++++++++++++------ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index a3a2db7..303d1d9 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -16,13 +16,20 @@ RUN dnf update -y && \ # Set up arguments for Hugo installation ARG HUGO_VERSION=latest ARG HUGO_VARIANT=hugo_extended +ARG WORKSPACE_DIR # Download and install Hugo RUN if [ "$HUGO_VERSION" = "latest" ]; then \ HUGO_VERSION=$(curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}'); \ fi && \ + ARCH=$(uname -m) && \ + case "$ARCH" in \ + "x86_64") HUGO_ARCH="64bit";; \ + "arm64"|"aarch64") HUGO_ARCH="arm64";; \ + *) echo "Unsupported architecture: $ARCH" && exit 1;; \ + esac && \ echo "Installing Hugo version: ${HUGO_VERSION}" && \ - wget -O hugo.tar.gz https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/${HUGO_VARIANT}_${HUGO_VERSION}_Linux-64bit.tar.gz && \ + wget -O hugo.tar.gz https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/${HUGO_VARIANT}_${HUGO_VERSION}_Linux-${HUGO_ARCH}.tar.gz && \ tar -xzf hugo.tar.gz && \ mv hugo /usr/local/bin/hugo && \ chmod +x /usr/local/bin/hugo && \ @@ -43,8 +50,8 @@ USER vscode # Expose port for Hugo server EXPOSE 1313 -# Set the working directory -WORKDIR /workspace +# Set the working directory to the container workspace directory +WORKDIR ${WORKSPACE_DIR} # Set the default command to run Hugo server CMD ["hugo", "server", "--bind=0.0.0.0"] \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index cd7a6a7..861a834 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,13 +1,14 @@ { "name": "AlmaLinux_WWW_Container", + "overrideCommand": false, "build": { "dockerfile": "Dockerfile", "args": { "VARIANT": "hugo", - "VERSION": "latest" + "VERSION": "latest", + "WORKSPACE_DIR": "${containerWorkspaceFolder}" } }, - "customizations": { "vscode": { "extensions": [ @@ -16,10 +17,19 @@ "esbenp.prettier-vscode", "yzhang.markdown-all-in-one", "tamasfe.even-better-toml" - ] - }, - "terminal.integrated.shell.linux": "/bin/bash" + ], + "settings": { + "terminal.integrated.defaultProfile.linux": "bash", + "terminal.integrated.profiles.linux": { + "bash": { + "path": "/bin/bash", + "icon": "terminal-bash" + } + } + } + } }, "forwardPorts": [1313], - "remoteUser": "vscode" + "remoteUser": "vscode", + "postCreateCommand": "echo 'function git_branch() { local branch; branch=\"$(git symbolic-ref --short HEAD 2> /dev/null)\"; if [[ -n \"$branch\" ]]; then echo -n \"$branch\"; return 0; fi; return 1; } && function git_has_changes() { git diff --quiet HEAD 2> /dev/null || echo -n \"✗\"; } && export WHITE=\"\\[\\033[1;37m\\]\" && export GREEN=\"\\[\\033[0;32m\\]\" && export BLUE=\"\\[\\033[0;94m\\]\" && export RED=\"\\[\\033[1;31m\\]\" && export YELLOW=\"\\[\\033[1;33m\\]\" && export RESET=\"\\[\\033[0m\\]\" && function prompt_command() { PS1=\"${GREEN}\\u${WHITE} ➜ ${BLUE}\\w ${BLUE}(${RED}\\$(git_branch)${YELLOW}\\$(git_has_changes)${BLUE})${RESET}$ \"; } && export PROMPT_COMMAND=\"prompt_command\"' >> ~/.bashrc" }