Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker multi-stage build and make compatible with automated builds #45

Merged
merged 12 commits into from
Oct 23, 2022
44 changes: 0 additions & 44 deletions bullseye-root/Dockerfile

This file was deleted.

18 changes: 9 additions & 9 deletions bullseye/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
############################################################
# Dockerfile that contains SteamCMD
############################################################
FROM debian:bullseye-slim
FROM debian:bullseye-slim as build_stage

LABEL maintainer="walentinlamonos@gmail.com"
ARG PUID=1000
Expand All @@ -16,19 +16,18 @@ RUN set -x \
&& apt-get install -y --no-install-recommends --no-install-suggests \
lib32stdc++6=10.2.1-6 \
lib32gcc-s1=10.2.1-6 \
wget=1.21-1+deb11u1 \
ca-certificates=20210119 \
nano=5.4-2 \
curl=7.74.0-1.3+deb11u1 \
locales=2.31-13+deb11u3 \
nano=5.4-2+deb11u1 \
curl=7.74.0-1.3+deb11u3 \
locales=2.31-13+deb11u4 \
&& sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \
&& dpkg-reconfigure --frontend=noninteractive locales \
# Create unprivileged user
&& useradd -u "${PUID}" -m "${USER}" \
# Download SteamCMD, execute as user
&& su "${USER}" -c \
"mkdir -p \"${STEAMCMDDIR}\" \
&& wget -qO- 'https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz' | tar xvzf - -C \"${STEAMCMDDIR}\" \
&& curl -fsSL 'https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz' | tar xvzf - -C \"${STEAMCMDDIR}\" \
&& \"./${STEAMCMDDIR}/steamcmd.sh\" +quit \
&& mkdir -p \"${HOMEDIR}/.steam/sdk32\" \
&& ln -s \"${STEAMCMDDIR}/linux32/steamclient.so\" \"${HOMEDIR}/.steam/sdk32/steamclient.so\" \
Expand All @@ -38,10 +37,11 @@ RUN set -x \
&& ln -s "${STEAMCMDDIR}/linux64/steamclient.so" "/usr/lib/x86_64-linux-gnu/steamclient.so" \
# Clean up
&& apt-get remove --purge --auto-remove -y \
wget \
&& rm -rf /var/lib/apt/lists/*

FROM build_stage AS bullseye-root
WORKDIR ${STEAMCMDDIR}

FROM bullseye-root AS bullseye
# Switch to user
USER ${USER}

WORKDIR ${STEAMCMDDIR}
5 changes: 5 additions & 0 deletions bullseye/hooks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
BUILD_PATH=$(echo ${DOCKERFILE_PATH}| sed 's#/#..#g' | sed 's#[a-zA-Z0-9]\+#/#g' | cut -c 2- )

docker build --target=bullseye -f $(basename ${DOCKERFILE_PATH}) -t $DOCKER_REPO:latest -t $DOCKER_REPO:steam ${BUILD_PATH}.
docker build --target=bullseye-root -f $(basename ${DOCKERFILE_PATH}) -t $DOCKER_REPO:root ${BUILD_PATH}.
2 changes: 2 additions & 0 deletions bullseye/hooks/push
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
docker push --all-tags ${DOCKER_REPO}