From d9f9c8731ddc6d5187f5d80a07ddfc1d6094b5a6 Mon Sep 17 00:00:00 2001 From: "Mr. Rubber Ducky (Simon)" <79613254+MrRubberDucky@users.noreply.github.com> Date: Mon, 22 Jan 2024 11:23:53 +0100 Subject: [PATCH] Build time optimizations Signed-off-by: Mr. Rubber Ducky (Simon) <79613254+MrRubberDucky@users.noreply.github.com> --- Caddy.Dockerfile | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/Caddy.Dockerfile b/Caddy.Dockerfile index 3b81072..7079bbb 100644 --- a/Caddy.Dockerfile +++ b/Caddy.Dockerfile @@ -1,18 +1,20 @@ +MAINTAINER MrRubberDucky + # ============================================================================= # 1. ALPINE BUILDER STAGE # ============================================================================= -ARG ALPINE_VERSION=latest +ARG ALPINE_VERSION=3.19.0 -FROM docker.io/library/alpine:${ALPINE_VERSION} AS alpine-builder +FROM docker.io/library/${ARCH}/alpine:${ALPINE_VERSION} AS alpine-builder WORKDIR /app # For clean-up, each stage is labeled LABEL stage=alpine-builder -ARG ALPINE_VERSION=latest \ - CADDY_VERSION=latest \ - BUILD_VERSION=0.1.0 \ +ARG ALPINE_VERSION=3.19.0 \ + CADDY_VERSION=2.7.6 \ + BUILD_VERSION=0.10 \ SHELL=/bin/bash \ GOPATH=/app/go \ USER=caddy \ @@ -28,16 +30,20 @@ COPY --chmod=0755 scripts/array-helper.sh /app/helper/array-helper.sh COPY templates/templatebuild.bashrc /app/temp.bashrc COPY templates/template.MODULES /app/helper/.MODULES -RUN echo "Installing dependencies" \ - && apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community \ - bash \ - git \ - envsubst \ - && apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing \ - xcaddy \ - ca-certificates \ +RUN echo "Installing dependencies" \ + && apk add --no-cache --virtual build_community --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community \ + bash \ + git \ + envsubst \ + && apk add --no-cache --virtual build_testing --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing \ + xcaddy \ + ca-certificates \ && envsubst < /app/temp.bashrc > /app/.bashrc \ - && /bin/bash -c /app/helper/array-helper.sh + && /bin/bash -c /app/helper/array-helper.sh \ + && apk del --rdepends \ + build_community \ + build_testing \ + && rm -rf /app # ============================================================================= # 2. ALPINE BASE STAGE @@ -48,9 +54,9 @@ WORKDIR /app LABEL stage=qor-caddy -ARG ALPINE_VERSION=latest \ - CADDY_VERSION=latest \ - BUILD_VERSION=0.1.0 \ +ARG ALPINE_VERSION=3.19.0 \ + CADDY_VERSION=2.7.6 \ + BUILD_VERSION=0.10 \ SHELL=/bin/bash \ GOPATH=/app/go \ USER=caddy \ @@ -72,6 +78,7 @@ EXPOSE 2019 RUN echo "Installing dependencies, setting up users etc." \ && apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community \ bash \ + && apk add --no-cache --virtual env_set --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community \ envsubst \ && apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing \ ca-certificates \ @@ -87,10 +94,11 @@ RUN echo "Installing dependencies, setting up users etc." \ --disabled-password \ "$USER" \ && adduser \ - "$USER" \ + "$USER" \ netdev \ && chown -R "$USER":"$GROUP" /srv /app \ && envsubst < /app/template.bashrc > /app/.bashrc \ - && rm /bin/ash /app/template.bashrc + && rm /bin/ash /app/template.bashrc \ + && apk del --rdepends envsubst \ ENTRYPOINT /app/scripts/docker-entrypoint.sh