1
0
Fork 0

Use two-step process for building image without unnecessary files and dependencies

This commit is contained in:
Jonas Tobias Hopusch 2021-12-27 21:04:33 +01:00
parent fd16cc396f
commit dd2459eb30
Failed to generate hash of commit

View file

@ -1,4 +1,4 @@
FROM caddy:2
FROM alpine:latest AS builder
ARG WEBSITE_ARCHIVE_URL
ARG WEBSITE_ARCHIVE_FOLDER
@ -9,9 +9,14 @@ RUN apk add zola --repository http://dl-cdn.alpinelinux.org/alpine/edge/communit
COPY archive-token.txt /archive-token.txt
RUN curl -X "GET" -H "Authorization: token $(cat /archive-token.txt)" "$WEBSITE_ARCHIVE_URL" 2>/dev/null | gzip --decompress --stdout - | tar xf - ; rm /archive-token.txt
WORKDIR /srv/$WEBSITE_ARCHIVE_FOLDER
WORKDIR /$WEBSITE_ARCHIVE_FOLDER
RUN zola build ; rm public/404.html
FROM caddy:2
ARG WEBSITE_ARCHIVE_FOLDER
COPY --from=builder /$WEBSITE_ARCHIVE_FOLDER/public /site
EXPOSE 80/tcp
CMD ["caddy", "file-server", "--root", "public"]
CMD ["caddy", "file-server", "--root", "/site/"]