Browse Source

Corrected arg naming and added specific version downloading for pinning the version to test with.

pull/709/head
Alex Laurie 4 months ago
parent
commit
cfbc2aac81
  1. 20
      .devcontainer/Dockerfile
  2. 6
      .devcontainer/devcontainer.json

20
.devcontainer/Dockerfile

@ -14,13 +14,15 @@ RUN dnf update -y && \
&& dnf clean all && dnf clean all
# Set up arguments for Hugo installation # Set up arguments for Hugo installation
ARG HUGO_VERSION=latest ARG VERSION
ARG HUGO_VARIANT=hugo_extended ARG VARIANT
ARG WORKSPACE_DIR ARG WORKSPACE_DIR
# Download and install Hugo # Download and install Hugo
RUN if [ "$HUGO_VERSION" = "latest" ]; then \ RUN if [ "$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)}'); \ 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 && \ fi && \
ARCH=$(uname -m) && \ ARCH=$(uname -m) && \
case "$ARCH" in \ case "$ARCH" in \
@ -28,15 +30,15 @@ RUN if [ "$HUGO_VERSION" = "latest" ]; then \
"arm64"|"aarch64") HUGO_ARCH="arm64";; \ "arm64"|"aarch64") HUGO_ARCH="arm64";; \
*) echo "Unsupported architecture: $ARCH" && exit 1;; \ *) echo "Unsupported architecture: $ARCH" && exit 1;; \
esac && \ esac && \
echo "Installing Hugo version: ${HUGO_VERSION}" && \ echo "Installing Hugo version: ${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 && \ 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 && \ tar -xzf hugo.tar.gz && \
mv hugo /usr/local/bin/hugo && \ mv hugo /usr/local/bin/hugo && \
chmod +x /usr/local/bin/hugo && \ chmod +x /usr/local/bin/hugo && \
rm hugo.tar.gz rm hugo.tar.gz
# Create a non-root user for development # Create a non-root user for development
ARG USERNAME=vscode ARG USERNAME=alma_www_user
ARG USER_UID=1000 ARG USER_UID=1000
ARG USER_GID=$USER_UID 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 \ && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME && chmod 0440 /etc/sudoers.d/$USERNAME
USER vscode USER alma_www_user
# Expose port for Hugo server # Expose port for Hugo server
EXPOSE 1313 EXPOSE 1313
@ -54,4 +56,4 @@ EXPOSE 1313
WORKDIR ${WORKSPACE_DIR} WORKDIR ${WORKSPACE_DIR}
ENTRYPOINT ["hugo", "server"] ENTRYPOINT ["hugo", "server"]
CMD ["--bind=0.0.0.0"] CMD ["--bind=0.0.0.0"]

6
.devcontainer/devcontainer.json

@ -4,8 +4,8 @@
"build": { "build": {
"dockerfile": "Dockerfile", "dockerfile": "Dockerfile",
"args": { "args": {
"VARIANT": "hugo", "VARIANT": "hugo_extended",
"VERSION": "latest", "VERSION": "v0.139.3",
"WORKSPACE_DIR": "${containerWorkspaceFolder}" "WORKSPACE_DIR": "${containerWorkspaceFolder}"
} }
}, },
@ -32,6 +32,6 @@
} }
}, },
"forwardPorts": [1313], "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" "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"
} }

Loading…
Cancel
Save