Add separate stage to build a distrobox optimized container

Signed-off-by: Felix Bartels <felix@9wd.eu>
This commit is contained in:
Felix Bartels 2023-08-06 17:54:37 +02:00
parent 0ac667af18
commit 2f413b92b1
2 changed files with 48 additions and 5 deletions

View file

@ -1,4 +1,41 @@
FROM node:lts-alpine FROM node:lts as build
RUN apk add --no-cache make python3 zip
# use --unsafe to not execute post actions as user nobody # use --unsafe to not execute post actions as user nobody
RUN npm -g install cloudron-surfer@6.0.0 --unsafe && npm cache clean --force && surfer --version RUN npm -g install cloudron-surfer@6.0.0 --unsafe && \
npm cache clean --force && \
surfer --version
FROM build as distrobox
# Install essential packages and locales
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils \
bash \
bash-completion \
bc \
curl \
dialog \
diffutils \
findutils \
gnupg2 \
less \
libegl1-mesa \
libgl1-mesa-glx \
libnss-myhostname \
libvte-2.9*-common \
libvte-common \
libvulkan1 \
locales \
lsof \
mesa-vulkan-drivers \
ncurses-base \
passwd \
pinentry-curses \
procps \
sudo \
time \
tzdata \
util-linux \
wget
# make sure that the distrobox stage is not the last one
FROM build as surfer

View file

@ -19,6 +19,12 @@ else
fi fi
$CMD build . -t "$DOCKER_IMAGE:latest" $CMD build . -t "$DOCKER_IMAGE:latest"
$CMD build . --target distrobox -t "$DOCKER_IMAGE:distrobox"
$CMD tag "$DOCKER_IMAGE:latest" "$DOCKER_IMAGE:$VERSION" $CMD tag "$DOCKER_IMAGE:latest" "$DOCKER_IMAGE:$VERSION"
$CMD push "$DOCKER_IMAGE:latest"
$CMD push "$DOCKER_IMAGE:$VERSION" if [ "${1:-}" == "push" ]; then
$CMD push "$DOCKER_IMAGE:latest"
$CMD push "$DOCKER_IMAGE:$VERSION"
$CMD push "$DOCKER_IMAGE:distrobox"
fi