24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-05-31 21:07:55 +02:00

Dockerfile: Use Alpine as base for METHOD=package

No need to use the "large" docker.io/erlang image as we do not need any erlang/otp for the binary installers.
This commit is contained in:
sando38 2023-04-24 15:03:26 +02:00 committed by Badlop
parent 33ac7916d3
commit 8f05af7810

View File

@ -1,6 +1,10 @@
#' Define default build variables #' Define default build variables
## specifc ARGs for METHOD='direct'
ARG OTP_VSN='25.3' ARG OTP_VSN='25.3'
ARG ELIXIR_VSN='1.14.4' ARG ELIXIR_VSN='1.14.4'
## specifc ARGs for METHOD='package'
ARG ALPINE_VSN='3.17'
## general ARGs
ARG UID='9000' ARG UID='9000'
ARG USER='ejabberd' ARG USER='ejabberd'
ARG HOME="opt/$USER" ARG HOME="opt/$USER"
@ -71,7 +75,7 @@ RUN wget -O "$HOME/conf/cacert.pem" 'https://curl.se/ca/cacert.pem' \
################################################################################ ################################################################################
#' METHOD='package' - install ejabberd from binary tarball package #' METHOD='package' - install ejabberd from binary tarball package
FROM docker.io/erlang:${OTP_VSN}-alpine AS package FROM docker.io/alpine:${ALPINE_VSN} AS package
COPY tarballs/ejabberd-*-linux-musl-*.tar.gz /tmp/ COPY tarballs/ejabberd-*-linux-musl-*.tar.gz /tmp/
WORKDIR /rootfs WORKDIR /rootfs
ARG HOME ARG HOME
@ -132,21 +136,29 @@ RUN chown -R $UID:$UID $HOME
################################################################################ ################################################################################
#' METHOD='package' - install runtime dependencies #' METHOD='package' - install runtime dependencies
FROM docker.io/erlang:${OTP_VSN}-alpine AS runtime-package FROM docker.io/alpine:${ALPINE_VSN} AS runtime-package
RUN apk -U upgrade --available --no-cache \ RUN apk -U upgrade --available --no-cache \
&& apk add --no-cache \ && apk add --no-cache \
so:libcap.so.2 \ so:libcap.so.2 \
tini tini
################################################################################ ################################################################################
#' METHOD='direct' - install runtime dependencies #' METHOD='direct' - install runtime dependencies, remove erlang/OTP & rebar3
FROM runtime-package AS runtime-direct FROM docker.io/erlang:${OTP_VSN}-alpine AS runtime-direct
COPY --from=ejabberd /tmp/runDeps /tmp/runDeps COPY --from=ejabberd /tmp/runDeps /tmp/runDeps
RUN apk add --no-cache \ RUN apk -U upgrade --available --no-cache \
&& apk add --no-cache \
so:libcap.so.2 \
tini \
$(cat /tmp/runDeps) $(cat /tmp/runDeps)
RUN apk del .erlang-rundeps \
&& rm -f $(which rebar3) \
&& find /usr -type d -name 'erlang' -exec rm -rf {} + \
&& find /usr -type l -exec test ! -e {} \; -delete
################################################################################ ################################################################################
#' Remove erlang/OTP & rebar3 from base image, finalize runtime environment #' Finalize runtime environment
FROM runtime-${METHOD} AS runtime FROM runtime-${METHOD} AS runtime
ARG USER ARG USER
ARG UID ARG UID
@ -154,11 +166,6 @@ ARG HOME
RUN addgroup $USER -g $UID \ RUN addgroup $USER -g $UID \
&& adduser -s /sbin/nologin -D -u $UID -h /$HOME -G $USER $USER && adduser -s /sbin/nologin -D -u $UID -h /$HOME -G $USER $USER
RUN apk del .erlang-rundeps \
&& rm -f $(which rebar3) \
&& find /usr -type d -name 'erlang' -exec rm -rf {} + \
&& find /usr -type l -exec test ! -e {} \; -delete
################################################################################ ################################################################################
#' Build together production image #' Build together production image
FROM scratch AS prod FROM scratch AS prod