This commit is contained in:
Lucas Briese 2021-11-08 23:38:55 +01:00
parent d73cc30676
commit 176f6c5411
7 changed files with 142 additions and 104 deletions

View File

@ -1,6 +1,73 @@
ARG SUFFIX="" FROM debian:buster-slim as lgsm
FROM jusito/docker-ttt:lgsm_debian${SUFFIX} # Const \\ Overwrite Env \\ Configs possible \\ Configs needed
# C.UTF-8 -> en_US.UTF-8
ENV STEAM_PATH="/home/steam" \
SERVER_PATH="/home/steam/serverfiles" \
STEAM_CMD="/home/steam/.steam/steamcmd" \
GROUP_ID=10000 \
USER_ID=10000 \
DOCKER_USER=steam \
SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.9/supercronic-linux-amd64 \
SUPERCRONIC=supercronic-linux-amd64 \
SUPERCRONIC_SHA1SUM=5ddf8ea26b56d4a7ff6faecdd8966610d5cb9d85 \
\
\
DEBIAN_FRONTEND=noninteractive \
LANG=C.UTF-8 \
TERM=xterm \
\
\
DEBUGGING=false \
CRON_MONITOR="*/5 * * * *" \
CRON_UPDATE="*/30 * * * *" \
CRON_FORCE_UPDATE="0 10 * * 0" \
CRON_LOG_ROTATE="0 0 * * 0" \
\
\
SERVER_EXECUTABLE="" \
SERVER_GAME="" \
TZ="Europe/Berlin"
#https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
ENTRYPOINT ["./home/entrypoint.sh"]
#WORKDIR "$STEAM_PATH"
COPY ["lgsm/entrypoint.sh", "lgsm/initCron.sh", "lgsm/createAlias.sh", "/home/"]
# procps needed for ps command
# iproute2 needed because of "-slim"
RUN dpkg --add-architecture i386 && \
apt-get update -y && \
apt-get install -y mailutils postfix curl wget file tar bzip2 gzip unzip bsdmainutils python util-linux ca-certificates \
binutils bc jq tmux lib32gcc1 libstdc++6 lib32stdc++6 libtinfo5:i386 netcat libsdl2-2.0-0:i386 \
procps iproute2 && \
\
groupadd -g $GROUP_ID $DOCKER_USER && \
useradd -d "$STEAM_PATH" -g $GROUP_ID -u $USER_ID -m $DOCKER_USER && \
chown "$DOCKER_USER:$DOCKER_USER" /home/entrypoint.sh && \
chown "$DOCKER_USER:$DOCKER_USER" /home/initCron.sh && \
mkdir -p "$SERVER_PATH" && \
chown -R "$DOCKER_USER:$DOCKER_USER" "$STEAM_PATH" && \
chmod a=rx /home/entrypoint.sh && \
chmod a=rx /home/initCron.sh && \
chmod a=rx /home/createAlias.sh && \
\
ulimit -n 2048 && \
\
wget -O "$STEAM_PATH/linuxgsm.sh" "https://linuxgsm.sh" && \
chown "$DOCKER_USER:$DOCKER_USER" "$STEAM_PATH/linuxgsm.sh" && \
chmod +x "$STEAM_PATH/linuxgsm.sh" && \
\
\
wget -O "${SUPERCRONIC}" "$SUPERCRONIC_URL" && \
echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - && \
chmod +x "$SUPERCRONIC" && \
mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" && \
ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic
FROM lgsm as gmod
# Const \\ Overwrite Env \\ Configs optional # Const \\ Overwrite Env \\ Configs optional
ENV CSS_PATH="/home/steam/addons/css" \ ENV CSS_PATH="/home/steam/addons/css" \
@ -74,7 +141,7 @@ ENV CSS_PATH="/home/steam/addons/css" \
USE_MY_REPLACER_CONFIG=false USE_MY_REPLACER_CONFIG=false
COPY ["prepareServer.sh", "initConfig.sh", "forceWorkshopDownload.sh", "installAndMountAddons.sh", "common.cfg", "/home/"] COPY ["gmod/prepareServer.sh", "gmod/initConfig.sh", "gmod/forceWorkshopDownload.sh", "gmod/installAndMountAddons.sh", "gmod/common.cfg", "/home/"]
RUN chown "$DOCKER_USER:$DOCKER_USER" /home/prepareServer.sh && \ RUN chown "$DOCKER_USER:$DOCKER_USER" /home/prepareServer.sh && \
chown "$DOCKER_USER:$DOCKER_USER" /home/initConfig.sh && \ chown "$DOCKER_USER:$DOCKER_USER" /home/initConfig.sh && \
@ -100,3 +167,13 @@ RUN chown "$DOCKER_USER:$DOCKER_USER" /home/prepareServer.sh && \
/home/createAlias.sh "update" '/home/steam/gmodserver update' && \ /home/createAlias.sh "update" '/home/steam/gmodserver update' && \
/home/createAlias.sh "update-lgsm" '/home/steam/gmodserver update-lgsm' && \ /home/createAlias.sh "update-lgsm" '/home/steam/gmodserver update-lgsm' && \
/home/createAlias.sh "validate" '/home/steam/gmodserver validate' /home/createAlias.sh "validate" '/home/steam/gmodserver validate'
FROM gmod as TTT
ENV SERVER_GAMEMODE="terrortown"
COPY "TTT/server.cfg.default" "/home/server.cfg.default"
USER "$USER_ID:$GROUP_ID"
VOLUME "$SERVER_PATH"

21
docker-compose.yml Normal file
View File

@ -0,0 +1,21 @@
volumes:
TTTDev:
services:
ttt:
build: .
ports:
- 27015:27015/tcp
- 27015:27015/udp
environment:
INSTALL_CSS: "true"
SERVER_DEFAULT_MAP: ttt_lttp_kakariko_a4
SERVER_PORT: 27015
SERVER_NAME: "Example Name"
SERVER_PASSWORD: securePassword
SERVER_VOICE_ENABLE: 0
SERVER_MAX_PLAYERS: 20
SERVER_RCON_PASSWORD: securePassword
WORKSHOP_COLLECTION_ID: 1895900191
volumes:
- TTTDev:/home/steam/serverfiles

14
hooks/pre_push Normal file
View File

@ -0,0 +1,14 @@
#!/bin/sh
set -o errexit
set -o nounset
imageSuffix=""
if [ "$SOURCE_BRANCH" != "master" ]; then
imageSuffix="-$(echo "$SOURCE_BRANCH" | sed 's/\//-/g')"
fi
echo "current directory:"
echo "$(pwd)"
ls -lA .
bash test/testBuild.sh "$imageSuffix" --skip-ttt --push

View File

@ -1,69 +0,0 @@
FROM debian:buster-slim
# Const \\ Overwrite Env \\ Configs possible \\ Configs needed
# C.UTF-8 -> en_US.UTF-8
ENV STEAM_PATH="/home/steam" \
SERVER_PATH="/home/steam/serverfiles" \
STEAM_CMD="/home/steam/.steam/steamcmd" \
GROUP_ID=10000 \
USER_ID=10000 \
DOCKER_USER=steam \
SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.9/supercronic-linux-amd64 \
SUPERCRONIC=supercronic-linux-amd64 \
SUPERCRONIC_SHA1SUM=5ddf8ea26b56d4a7ff6faecdd8966610d5cb9d85 \
\
\
DEBIAN_FRONTEND=noninteractive \
LANG=C.UTF-8 \
TERM=xterm \
\
\
DEBUGGING=false \
CRON_MONITOR="*/5 * * * *" \
CRON_UPDATE="*/30 * * * *" \
CRON_FORCE_UPDATE="0 10 * * 0" \
CRON_LOG_ROTATE="0 0 * * 0" \
\
\
SERVER_EXECUTABLE="" \
SERVER_GAME="" \
TZ="Europe/Berlin"
#https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
ENTRYPOINT ["./home/entrypoint.sh"]
#WORKDIR "$STEAM_PATH"
COPY ["entrypoint.sh", "initCron.sh", "createAlias.sh", "/home/"]
# procps needed for ps command
# iproute2 needed because of "-slim"
RUN dpkg --add-architecture i386 && \
apt-get update -y && \
apt-get install -y mailutils postfix curl wget file tar bzip2 gzip unzip bsdmainutils python util-linux ca-certificates \
binutils bc jq tmux lib32gcc1 libstdc++6 lib32stdc++6 libtinfo5:i386 netcat \
procps iproute2 && \
\
groupadd -g $GROUP_ID $DOCKER_USER && \
useradd -d "$STEAM_PATH" -g $GROUP_ID -u $USER_ID -m $DOCKER_USER && \
chown "$DOCKER_USER:$DOCKER_USER" /home/entrypoint.sh && \
chown "$DOCKER_USER:$DOCKER_USER" /home/initCron.sh && \
mkdir -p "$SERVER_PATH" && \
chown -R "$DOCKER_USER:$DOCKER_USER" "$STEAM_PATH" && \
chmod a=rx /home/entrypoint.sh && \
chmod a=rx /home/initCron.sh && \
chmod a=rx /home/createAlias.sh && \
\
ulimit -n 2048 && \
\
wget -O "$STEAM_PATH/linuxgsm.sh" "https://linuxgsm.sh" && \
chown "$DOCKER_USER:$DOCKER_USER" "$STEAM_PATH/linuxgsm.sh" && \
chmod +x "$STEAM_PATH/linuxgsm.sh" && \
\
\
wget -O "${SUPERCRONIC}" "$SUPERCRONIC_URL" && \
echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - && \
chmod +x "$SUPERCRONIC" && \
mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" && \
ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic

View File

@ -18,7 +18,7 @@ set -e
# --- Install / Update --- # --- Install / Update ---
cd "$STEAM_PATH" cd "$STEAM_PATH"
if [ -n "$SERVER_EXECUTABLE" ] && [ -e "${STEAM_PATH}/$SERVER_EXECUTABLE" ]; then if [ -n "$SERVER_EXECUTABLE" ] && [ -e "${STEAM_PATH}/$SERVER_EXECUTABLE" ] && [ -d "$STEAM_CMD" ]; then
echo "[entrypoint.sh]updating..." echo "[entrypoint.sh]updating..."
./"$SERVER_EXECUTABLE" update-lgsm ./"$SERVER_EXECUTABLE" update-lgsm
./"$SERVER_EXECUTABLE" update ./"$SERVER_EXECUTABLE" update

View File

@ -1,19 +0,0 @@
#!/bin/sh
set -o errexit
#set -o pipefail
set -o nounset
imageSuffix=""
if [ "$SOURCE_BRANCH" != "master" ]; then
imageSuffix="-$(echo "$SOURCE_BRANCH" | sed 's/\//-/g')"
fi
#docker build -t "$DOCKER_REPO:lgsm_debian${imageSuffix}" "lgsm/"
cd ..
bash test/testBuild.sh "$imageSuffix" true
docker push "$DOCKER_REPO:gmod_debian${imageSuffix}"
docker push "$DOCKER_REPO:gmod_ttt_debian${imageSuffix}"
docker push "$DOCKER_REPO:latest${imageSuffix}"

View File

@ -1,7 +1,9 @@
#!/bin/bash #!/bin/bash
readonly SUFFIX="$1" readonly SUFFIX="$1"
readonly SKIP_LGSM="$2" readonly BUILD_TTT="$(grep -qF -e '--skip-ttt' <<< "$@" && echo false || echo true)"
readonly PUSH="$(grep -qF -e '--push' <<< "$@" && echo true || echo false)"
readonly repository="${DOCKER_REPO:-jusito/docker-ttt}"
if [ "${DEBUGGING}" = "true" ]; then if [ "${DEBUGGING}" = "true" ]; then
set -o xtrace set -o xtrace
@ -13,18 +15,30 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
echo "[testBuild][INFO]build" function process() {
tag_prefix="$1"
target="$2"
cache_option="$(grep -qF -e '--no-cache' <<< "$@" && echo "--no-cache" || echo "")"
if [ "$SKIP_LGSM" = true ]; then docker rmi "$repository:$tag_prefix${SUFFIX}" || true
docker rmi "jusito/docker-ttt:lgsm_debian${SUFFIX}" || true docker build --target "$target" $cache_option -t "$repository:$tag_prefix${SUFFIX}" .
docker build --no-cache -t "jusito/docker-ttt:lgsm_debian${SUFFIX}" "lgsm/" if "$PUSH"; then
docker push "$repository:$tag_prefix${SUFFIX}"
fi
}
echo "[testBuild][INFO] build"
process "lgsm_debian" "lgsm" --no-cache
process "gmod_debian" "gmod"
if "$BUILD_TTT"; then
process "gmod_ttt_debian" "TTT"
fi fi
docker rmi "jusito/docker-ttt:gmod_debian${SUFFIX}" || true docker rmi "$repository:latest${SUFFIX}" || true
docker build --no-cache -t "jusito/docker-ttt:gmod_debian${SUFFIX}" "gmod/" docker tag "$repository:gmod_ttt_debian${SUFFIX}" "$repository:latest${SUFFIX}"
if "$PUSH"; then
docker push "$repository:latest${SUFFIX}"
fi
docker rmi "jusito/docker-ttt:gmod_ttt_debian${SUFFIX}" || true echo "[testBuild][INFO] build done!"
docker build --no-cache -t "jusito/docker-ttt:gmod_ttt_debian${SUFFIX}" "TTT/"
docker rmi "$DOCKER_REPO:latest${SUFFIX}" || true
docker tag "$DOCKER_REPO:gmod_ttt_debian${SUFFIX}" "$DOCKER_REPO:latest${SUFFIX}"