## `source` is used to generate the static HTML with Hugo FROM debian:11 as source # Install dependencies ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && \ apt-get install -y imagemagick ca-certificates git wget # Install Hugo ENV HUGO_VERSION 0.111.2 RUN wget https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz && \ tar -xvf hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz && \ mv hugo /usr/local/bin/hugo && \ chmod +x /usr/local/bin/hugo # Copy site source WORKDIR /src COPY . ./ # Initialize submodules, like themes RUN git submodule update --init --recursive # Generate the site into /src/public RUN /usr/local/bin/hugo # Mogrify all images to be more efficient for the web RUN find ./public -name '*.jpg' -exec mogrify -auto-orient -monitor -sampling-factor 4:2:0 -strip -interlace JPEG -colorspace sRGB -resize 2048 -compress JPEG -quality 80 {} \; ## Create the final image with Nginx serving the static site FROM nginx:1-alpine COPY --from=source /src/public /usr/share/nginx/html