Skip to content

Instantly share code, notes, and snippets.

@exavolt
Last active April 4, 2024 21:09
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save exavolt/80cbdf4148fac42ab367eea793b8d4ac to your computer and use it in GitHub Desktop.
Save exavolt/80cbdf4148fac42ab367eea793b8d4ac to your computer and use it in GitHub Desktop.
Containerized Hugo (extended) with VSCode devcontainer
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.128.0/containers/hugo
{
"name": "Hugo",
"build": {
"dockerfile": "Dockerfile",
"args": {
// Update VARIANT to pick hugo variant.
// Example variants: hugo, hugo_extended
// Rebuild the container if it already exists to update.
"VARIANT": "hugo_extended",
// Update VERSION to pick a specific hugo version.
// Example versions: latest, 0.73.0, 0,71.1
// Rebuild the container if it already exists to update.
"VERSION": "latest",
}
},
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/zsh"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"bungcip.better-toml",
"davidanson.vscode-markdownlint"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
1313
],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",
// Uncomment to use Docker from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
// "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
// "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
FROM golang:1.13-alpine
# VARIANT can be either 'hugo' for the standard version or 'hugo_extended' for the extended version.
ARG VARIANT=hugo_extended
# VERSION can be either 'latest' or a specific version number
ARG VERSION=latest
RUN apk add --update --no-cache ca-certificates openssl git curl && \
case ${VERSION} in \
latest) \
export VERSION=$(curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}') ;;\
esac && \
echo ${VERSION} && \
wget -O ${VERSION}.tar.gz https://github.com/gohugoio/hugo/releases/download/v${VERSION}/${VARIANT}_${VERSION}_Linux-64bit.tar.gz && \
tar xf ${VERSION}.tar.gz && \
mv hugo* /usr/bin/hugo && \
go get github.com/yaegashi/muslstack && \
muslstack -s 0x800000 /usr/bin/hugo
FROM mcr.microsoft.com/vscode/devcontainers/base:0-alpine-3.12
# Required for hugo_extended
RUN apk add --update --no-cache libc6-compat
COPY --from=0 /usr/bin/hugo /usr/bin
EXPOSE 1313
WORKDIR /src
CMD ["/usr/bin/hugo server"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment