Skip to content

Commit

Permalink
Build time optimizations
Browse files Browse the repository at this point in the history
Signed-off-by: Mr. Rubber Ducky (Simon) <[email protected]>
  • Loading branch information
MrRubberDucky authored Jan 22, 2024
1 parent f116a1f commit d9f9c87
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions Caddy.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
MAINTAINER MrRubberDucky <[email protected]>

# =============================================================================
# 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 \
Expand All @@ -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
Expand All @@ -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 \
Expand All @@ -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 \
Expand All @@ -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

0 comments on commit d9f9c87

Please sign in to comment.