Static site generator - Hugo
Hugo is a static site generator repo.
- Create rsa keys repo with content (key, key.pub)
- Create dockerfile
FROM alpine AS build RUN apk add --update \ wget \ git \ openssh ARG BASE_URL="https://example.com" ARG HUGO_VERSION="0.152.2" ARG PLATFORM="Linux-ARM64" RUN wget --quiet "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_${PLATFORM}.tar.gz" && \ tar xzf hugo_${HUGO_VERSION}_${PLATFORM}.tar.gz && \ rm -r hugo_${HUGO_VERSION}_${PLATFORM}.tar.gz && \ mv hugo /usr/bin COPY key . # hack to avoid caching of git clone ADD "https://www.random.org/cgi-bin/randbyte?nbytes=10&format=h" skipcache RUN eval $(ssh-agent) && \ ssh-add key && \ ssh-keyscan -H <REPO_DOMAIN> >> /etc/ssh/ssh_known_hosts && \ git clone --branch master --single-branch --no-tags git@<REPO_DOMAIN>:blog.git WORKDIR /blog/blog RUN git branch RUN sed -i 's~<BASE_URL>~'${BASE_URL}'~g' config.toml RUN hugo --minify # uncomment to debug #RUN sleep 1h # serve previously build static page FROM httpd:alpine WORKDIR /usr/local/apache2/htdocs COPY --from=build /blog/blog/public . - Create
docker-compose.ymlservices: blog: build: context: . args: BASE_URL: "https://blog.${DOMAIN}" restart: "always" networks: ["server"] labels: - "traefik.enable=true" - "traefik.http.routers.blog.rule=Host(`blog.${DOMAIN}`)" networks: server: external: true