+ split docker images successful

This commit is contained in:
Lucas Briese
2019-07-21 23:04:00 +02:00
parent 62ef6948a1
commit df253d53e1
24 changed files with 775 additions and 17 deletions

64
lgsm/Dockerfile Normal file
View File

@ -0,0 +1,64 @@
FROM debian:stretch
# Const \\ Overwrite Env \\ Configs possible \\ Configs needed
ENV STEAM_PATH="/home/steam" \
SERVER_PATH="/home/steam/serverfiles" \
STEAM_CMD="/home/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 \
\
\
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"]
COPY ["entrypoint.sh", "initCron.sh", "/home/"]
# procps needed for ps command
RUN dpkg --add-architecture i386 && \
apt-get update -y && \
apt-get install -y mailutils postfix curl wget file bzip2 gzip unzip bsdmainutils python util-linux ca-certificates \
binutils bc jq tmux lib32gcc1 libstdc++6 libstdc++6:i386 lib32tinfo5 \
locales procps && \
\
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 && \
\
ulimit -n 2048 && \
sed -i 's/# en_US.UTF-8/en_US.UTF-8/' /etc/locale.gen && \
locale-gen && \
\
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

81
lgsm/entrypoint.sh Normal file
View File

@ -0,0 +1,81 @@
#!/bin/bash
if [ "${DEBUGGING}" = "true" ]; then
set -o xtrace
fi
set -o errexit
set -o pipefail
echo "starting entrypoint.sh"
set -e
# --- Install / Update ---
cd "$STEAM_PATH"
if [ -n "$SERVER_EXECUTABLE" ] && [ -e "${STEAM_PATH}/$SERVER_EXECUTABLE" ]; then
./"$SERVER_EXECUTABLE" update-lgsm
./"$SERVER_EXECUTABLE" update
else
bash linuxgsm.sh "$SERVER_GAME"
./"$SERVER_EXECUTABLE" auto-install
fi
if [ -e "/home/prepareServer.sh" ]; then
cd /home
./prepareServer.sh
cd "$STEAM_PATH"
fi
# --- Apply LGSM Workarounds ---
#force fetch of command_console.sh
if [ ! -e "${STEAM_PATH}/lgsm/functions/command_console.sh" ]; then
wget -O "${STEAM_PATH}/lgsm/functions/command_console.sh" "https://raw.githubusercontent.com/GameServerManagers/LinuxGSM/master/lgsm/functions/command_console.sh"
chmod +x "${STEAM_PATH}/lgsm/functions/command_console.sh"
fi
#skip confirmation
sed -i 's/! fn_prompt_yn "Continue?" Y/[ "1" != "1" ]/' "${STEAM_PATH}/lgsm/functions/command_console.sh"
# --- Start Server ---
#start server
IS_RUNNING="true"
function stopServer() {
echo "stopping server..."
cd "${STEAM_PATH}"
pid=$(pidof "$SERVER_EXECUTABLE")
kill -2 "$pid" || true
echo "server stopped!"
echo "stopping entrypoint..."
IS_RUNNING="false"
}
./"$SERVER_EXECUTABLE" start
trap stopServer SIGTERM
#start cron
bash "/home/initCron.sh"
# --- Wait for Shutdown ---
echo "Server is running, waiting for SIGTERM"
while [ "$IS_RUNNING" = "true" ]
do
sleep 1s
done
echo "entrypoint stopped"
exit 0

34
lgsm/initCron.sh Normal file
View File

@ -0,0 +1,34 @@
#!/bin/sh
if [ "${DEBUGGING}" = "true" ]; then
set -o xtrace
fi
set -o errexit
set -o pipefail
set -o nounset
LOG_PATH="$STEAM_PATH/logs"
CRON="$LOG_PATH/lgsm.cron"
CRON_LOG="$LOG_PATH/cron.log"
#set up cronjob
mkdir "$LOG_PATH" || true
rm -f "$CRON" || true
touch "$CRON"
# false positive
# shellcheck disable=SC2129
echo "$CRON_MONITOR $STEAM_PATH/gmodserver monitor > '$LOG_PATH/monitor.log' 2>&1" >> "$CRON"
# shellcheck disable=SC2129
echo "$CRON_UPDATE $STEAM_PATH/gmodserver update > '$LOG_PATH/update.log' 2>&1" >> "$CRON"
# shellcheck disable=SC2129
echo "$CRON_FORCE_UPDATE $STEAM_PATH/gmodserver force-update >'$LOG_PATH/force-update.log' 2>&1" >> "$CRON"
# shellcheck disable=SC2129
echo "$CRON_LOG_ROTATE mv -f '$CRON_LOG' '${CRON_LOG}.old'" >> "$CRON"
echo "" >> "$CRON"
if [ -e "$CRON_LOG" ]; then
mv -f "$CRON_LOG" "${CRON_LOG}.old"
fi
supercronic "$CRON" 2> "$LOG_PATH/cron.log" &