-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile.slim
97 lines (88 loc) Β· 4.17 KB
/
Dockerfile.slim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
################################################################################
# Dockerfile that contains Barotrauma Dedicated Server.
# Come with SteamCMD.
# Will download the server on first start.
# Will update the server on every start.
#
# SteamCMD part is inspired by: https://github.com/CM2Walki/steamcmd
# BaroServer part is inspired by: https://github.com/gnoeley/barotrauma-dedicated-server-docker
################################################################################
FROM opensuse/leap:15.6
LABEL maintainer="code@yanwk.fun"
# This image is less-often built, so less cache layer is needed.
# 1. Create a low-privilege user.
# 2. Install .NET runtime & SteamCMD.
# 3. Disable all Zypper repos.
# 4. Run SteamCMD for the first time, let it update.
# 5. Clear /tmp when done.
RUN set -eux \
&& sed -i 's/^CREATE_MAIL_SPOOL=yes/CREATE_MAIL_SPOOL=no/' /etc/default/useradd \
&& mkdir -p /home/runner \
&& groupadd runner \
&& useradd runner -g runner -d /home/runner \
&& chown runner:runner /home/runner \
&& printf "\
[packages-microsoft-com-prod]\n\
name=packages-microsoft-com-prod\n\
baseurl=https://packages.microsoft.com/opensuse/15/prod/\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://packages.microsoft.com/keys/microsoft.asc\n" \
> /etc/zypp/repos.d/microsoft-prod.repo \
&& zypper --gpg-auto-import-keys \
install --no-confirm --no-recommends --auto-agree-with-licenses \
libicu \
dotnet-runtime-6.0 \
libSDL2-2_0-0 \
steamcmd \
&& zypper modifyrepo --disable --all \
&& rm -rf /var/cache/zypp/* \
&& steamcmd +'quit' \
&& rm -rf /root/Steam/appcache/httpcache/* \
&& rm -rf /tmp/*
# The game server will be installed & running in a low-privilege user.
USER runner:runner
ENV STEAMAPPID=1026340
ENV GAMEDIR="/home/runner/Steam/steamapps/common/Barotrauma Dedicated Server"
# 1. Symlink lib for the game server to access Steam service.
# 2. Let SteamCMD download the game server for once,
# so it won't validate(reset) existing files at first start (ugly hack).
RUN set -eux \
&& mkdir -p /home/runner/Steam \
&& mkdir -p /home/runner/.steam/sdk32 \
&& mkdir -p /home/runner/.steam/sdk64 \
&& ln -s /usr/lib/steamcmd/linux32/steamclient.so /home/runner/.steam/sdk32/steamclient.so \
&& ln -s /usr/lib/steamcmd/linux64/steamclient.so /home/runner/.steam/sdk64/steamclient.so \
&& mkdir -p "${GAMEDIR}" \
&& steamcmd @ShutdownOnFailedCommand @NoPromptForPassword +login anonymous +app_update ${STEAMAPPID} validate +'quit' \
&& rm -rf "${GAMEDIR}/*"
# Fix for (only occurs on Linux): https://github.com/Regalis11/Barotrauma/issues/10112
# Note: if "~/.local/share/" doesn't exists, the game will try save campaigns & Workshop mods inside main folder.
# So we save all files in one place.
ENV FIX_PATH="${GAMEDIR}/Daedalic Entertainment GmbH/Barotrauma"
ENV FIX_LINKPATH="${FIX_PATH}/Daedalic Entertainment GmbH/Barotrauma"
# 1. Update SteamCMD on every start.
# 2. Use root to chown uploaded files. But will run server in low-privilege.
# 3. If the executable file "DedicatedServer" doesn't exist, SteamCMD will download, install and validate the server.
# If exists, SteamCMD will try to update the server, but will not validate (or config files will be replaced).
# 4. Make symlink for fixing nested folder issue mentioned above.
USER root:root
VOLUME $GAMEDIR
WORKDIR $GAMEDIR
EXPOSE 27015/udp 27016/udp
CMD steamcmd +'quit' \
&& rm -rf /tmp/dumps \
&& chown -R runner:runner "${GAMEDIR}/" \
&& su runner -c '\
if [ -f "${GAMEDIR}/DedicatedServer" ] ; then \
steamcmd @ShutdownOnFailedCommand @NoPromptForPassword +login anonymous +app_update ${STEAMAPPID} +'quit' ; \
else \
steamcmd @ShutdownOnFailedCommand @NoPromptForPassword +login anonymous +app_update ${STEAMAPPID} validate +'quit' ; \
fi \
&& mkdir -p "${GAMEDIR}/Daedalic Entertainment GmbH/Barotrauma/Multiplayer" \
&& mkdir -p "${FIX_PATH}/Daedalic Entertainment GmbH" \
&& if [ ! -L "${FIX_LINKPATH}" ] ; then \
ln -s "${FIX_PATH}" "${FIX_LINKPATH}" ; \
fi \
&& "${GAMEDIR}/DedicatedServer"\
'