From cfbc2aac816ac0328cbd2c7b2f67e0a2fbf1e002 Mon Sep 17 00:00:00 2001 From: Alex Laurie Date: Fri, 17 Jan 2025 05:39:17 +0000 Subject: [PATCH] Corrected arg naming and added specific version downloading for pinning the version to test with. --- .devcontainer/Dockerfile | 20 +++++++++++--------- .devcontainer/devcontainer.json | 6 +++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 7b06edd..986186b 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -14,13 +14,15 @@ RUN dnf update -y && \ && dnf clean all # Set up arguments for Hugo installation -ARG HUGO_VERSION=latest -ARG HUGO_VARIANT=hugo_extended +ARG VERSION +ARG VARIANT 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)}'); \ +RUN if [ "$VERSION" = "latest" ]; then \ + VERSION=$(curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}'); \ + else \ + VERSION=$(echo $VERSION | sed 's/v//'); \ fi && \ ARCH=$(uname -m) && \ case "$ARCH" in \ @@ -28,15 +30,15 @@ RUN if [ "$HUGO_VERSION" = "latest" ]; then \ "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-${HUGO_ARCH}.tar.gz && \ + echo "Installing Hugo version: ${VERSION}" && \ + wget -O hugo.tar.gz https://github.com/gohugoio/hugo/releases/download/v${VERSION}/${VARIANT}_${VERSION}_Linux-${HUGO_ARCH}.tar.gz && \ tar -xzf hugo.tar.gz && \ mv hugo /usr/local/bin/hugo && \ chmod +x /usr/local/bin/hugo && \ rm hugo.tar.gz # Create a non-root user for development -ARG USERNAME=vscode +ARG USERNAME=alma_www_user ARG USER_UID=1000 ARG USER_GID=$USER_UID @@ -45,7 +47,7 @@ RUN groupadd --gid $USER_GID $USERNAME \ && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ && chmod 0440 /etc/sudoers.d/$USERNAME -USER vscode +USER alma_www_user # Expose port for Hugo server EXPOSE 1313 @@ -54,4 +56,4 @@ EXPOSE 1313 WORKDIR ${WORKSPACE_DIR} ENTRYPOINT ["hugo", "server"] -CMD ["--bind=0.0.0.0"] +CMD ["--bind=0.0.0.0"] \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e3d6a62..0b86b4a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,8 +4,8 @@ "build": { "dockerfile": "Dockerfile", "args": { - "VARIANT": "hugo", - "VERSION": "latest", + "VARIANT": "hugo_extended", + "VERSION": "v0.139.3", "WORKSPACE_DIR": "${containerWorkspaceFolder}" } }, @@ -32,6 +32,6 @@ } }, "forwardPorts": [1313], - "remoteUser": "vscode", + "remoteUser": "alma_www_user", "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" }