-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile.exmaple
64 lines (53 loc) Β· 2.44 KB
/
Dockerfile.exmaple
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
############################################################
# Example Dockerfile that runs a dedicated game server
# with SteamCMD.
############################################################
FROM opensuse/leap:15.6
LABEL maintainer="code@yanwk.fun"
# Install runtimes & SteamCMD.
# When done, disable all Zypper repos.
RUN zypper install --no-confirm --no-recommends --auto-agree-with-licenses \
libSDL2-2_0-0 \
steamcmd \
&& zypper modifyrepo --disable --all \
&& rm -rf /var/cache/zypp/*
# Run SteamCMD for the first time, let it update & install some files,
# so other low-privilege users could run it properly.
# Clear /tmp when done.
RUN steamcmd +'quit' \
&& rm -rf /root/Steam/appcache/httpcache/* \
&& rm -rf /tmp/*
# Create a low-privilege user.
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
USER runner:runner
WORKDIR /home/runner
ENV STEAMAPPID 1007
ENV GAMEDIR "/home/runner/Steam/steamapps/common/Steamworks SDK Redist"
# Make directory before mount volume (or it will be root-owned).
# Make necessary symlink for SteamCMD.
RUN set -eux \
&& mkdir -p "${GAMEDIR}" \
&& 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
# Mount the whole game server folder as persistence.
# Could be optimized if the game server is data-program separated, but needs redesign.
VOLUME $GAMEDIR
# "EXPOSE" does not actually publish the port, it informs container which port needs to.
EXPOSE 8080/tcp
EXPOSE 8081/tcp
# If the executable file doesn't exist, SteamCMD will download, install and validate the server.
# If exists, SteamCMD will try to update the server, but without validation (or config files could be replaced).
CMD if [[ -f "${GAMEDIR}/DedicatedServerApp" ]] ; then \
steamcmd @ShutdownOnFailedCommand @NoPromptForPassword +login anonymous +app_update ${STEAMAPPID} +'quit' ; \
else \
steamcmd @ShutdownOnFailedCommand @NoPromptForPassword +login anonymous +app_update ${STEAMAPPID} validate +'quit' ; \
fi \
&& "${GAMEDIR}/DedicatedServerApp"