Skip to content

Commit

Permalink
Docker multi-stage build and make compatible with automated builds (#45)
Browse files Browse the repository at this point in the history
* Fix inconsistent indenting
* Remove duplicate code with multistage build
* Fix apt package versions [nano, curl, locales] that prevent build
* Remove wget
* Made PR compatible with docker hub automated builds

Co-authored-by: M. Mucahid Benlioglu <m.mucahidbenlioglu@gmail.com>
  • Loading branch information
CM2Walki and mbenlioglu authored Oct 23, 2022
1 parent 939da93 commit 4f9bf8c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 53 deletions.
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}

0 comments on commit 4f9bf8c

Please sign in to comment.