From ccb1743b405ebc4da43f112d764c0876f7eaf837 Mon Sep 17 00:00:00 2001 From: Senthilkumar Panneerselvam Date: Thu, 21 Mar 2024 11:12:42 +0100 Subject: [PATCH] User official images for docker build --- Dockerfile | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 33908ba..a8fa2fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,21 @@ -FROM klakegg/hugo:0.104.3-ubuntu-onbuild AS build +# Use alpine Linux, download desired version of HUGO and build html files +FROM alpine:3.19.1 AS build +RUN apk add --no-cache wget=1.21.4-r0 +ARG HUGO_VERSION="0.123.7" +RUN wget --quiet "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_Linux-64bit.tar.gz" && \ + tar xzf hugo_${HUGO_VERSION}_Linux-64bit.tar.gz && \ + rm -r hugo_${HUGO_VERSION}_Linux-64bit.tar.gz && \ + mv hugo /usr/bin && \ + chmod 755 /usr/bin/hugo +WORKDIR /src +COPY ./ /src +RUN mkdir /target && \ + hugo -d /target +# Serve the generated html using nginx FROM nginxinc/nginx-unprivileged:alpine -RUN sed -i '3 a\ absolute_redirect off;' /etc/nginx/conf.d/default.conf -RUN sed -i 's/#error_page 404/error_page 404/' /etc/nginx/conf.d/default.conf +RUN sed -i '3 a\ absolute_redirect off;' /etc/nginx/conf.d/default.conf && \ + sed -i 's/#error_page 404/error_page 404/' /etc/nginx/conf.d/default.conf COPY --from=build /target /usr/share/nginx/html EXPOSE 8080