forked from startersclan/docker-sourceservers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
144 lines (135 loc) · 5.5 KB
/
Dockerfile
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# syntax=docker/dockerfile:1
# Builds a clean image containing the latest version of the specified game.
FROM startersclan/steamcmd:git-20231109.0.0
ARG SERVER_DIR=/server
ARG APPMANIFEST_AR_URL=https://github.com/startersclan/hlds-appmanifest/archive/refs/tags/v2.0.0.tar.gz
ARG APPID
ARG MOD
ARG FIX_APPMANIFEST=false
ARG CLIENT_APPID
ARG INSTALL_COUNT
ARG STEAM_LOGIN
ARG CACHE_KEY
# Download game
RUN --mount=type=secret,id=STEAM_USERNAME \
--mount=type=secret,id=STEAM_PASSWORD \
STEAM_USERNAME=$( cat /run/secrets/STEAM_USERNAME ); \
STEAM_PASSWORD=$( cat /run/secrets/STEAM_PASSWORD ); \
if [ -z "$INSTALL_COUNT" ]; then \
echo "[BUILD] INSTALL_COUNT is null. Using default values"; \
if [ "$APPID" = 90 ]; then \
INSTALL_COUNT=3; \
else \
INSTALL_COUNT=1; \
fi; \
fi; \
echo "[BUILD] SERVER_DIR: $SERVER_DIR"; \
echo "[BUILD] APPMANIFEST_AR_URL: $APPMANIFEST_AR_URL"; \
echo "[BUILD] APPID: $APPID"; \
echo "[BUILD] MOD: $MOD"; \
echo "[BUILD] FIX_APPMANIFEST: $FIX_APPMANIFEST"; \
echo "[BUILD] CLIENT_APPID: $CLIENT_APPID"; \
echo "[BUILD] INSTALL_COUNT: $INSTALL_COUNT"; \
echo "[BUILD] STEAM_LOGIN: $STEAM_LOGIN"; \
if [ "$STEAM_LOGIN" = 'true' ]; then \
echo "[BUILD] STEAM_LOGIN is true. Will log in via user"; \
steamcmdLoginArgs="$STEAM_USERNAME $STEAM_PASSWORD"; \
else \
echo "[BUILD] STEAM_LOGIN is null or not true. Will connect anonymously"; \
steamcmdLoginArgs='anonymous'; \
fi; \
if [ "$APPID" = 90 ] && [ -n "$MOD" ]; then \
steamcmdArgs="+force_install_dir $SERVER_DIR +login $steamcmdLoginArgs +app_set_config $APPID mod $MOD +app_update $APPID validate +quit"; \
else \
steamcmdArgs="+force_install_dir $SERVER_DIR +login $steamcmdLoginArgs +app_update $APPID validate +quit"; \
fi; \
if [ "$APPID" = 90 ]; then \
if [ "$FIX_APPMANIFEST" = 'true' ]; then \
echo "[BUILD] APPID is 90 and FIX_APPMANIFEST is true. Will apply appmanifest fix"; \
else \
echo "[BUILD] APPID is 90 but FIX_APPMANIFEST is null or not true. Will not apply appmanifest fix"; \
fi; \
else \
echo "[BUILD] APPID is not 90. Will not apply appmanifest fix"; \
fi; \
echo "[BUILD] Downloading game"; \
i=0; \
while [ "$i" -le $(( $INSTALL_COUNT-1 )) ]; do \
echo "[BUILD] Install count: [$(( i+1 ))/$INSTALL_COUNT]"; \
steamcmd.sh $steamcmdArgs; \
ls -al "$SERVER_DIR/steamapps"; \
i=$(( i+1 )); \
if [ "$i" -eq 1 ] && [ "$APPID" = 90 ] && [ "$FIX_APPMANIFEST" = 'true' ]; then \
if [ -n "$MOD" ]; then \
WILDCARD_PATTERN="*/$MOD/*"; \
else \
WILDCARD_PATTERN='*/valve/*'; \
fi; \
echo "[BUILD] Applying appmanifest fix"; \
curl -sqL "$APPMANIFEST_AR_URL" | tar -zxvf - -C "$SERVER_DIR/steamapps" --wildcards "$WILDCARD_PATTERN" --strip-components=2; \
ls -al "$SERVER_DIR/steamapps"; \
fi; \
done; \
echo "[BUILD] Performing cleanup"; \
# Clean up a different set of files for srcds/cs2
if [ "$APPID" = 730 ]; then \
cd "$STEAMCMD_DIR" && rm -rf \
package \
public \
siteserverui \
steam \
linux32/libtier0_s.so \
linux32/libvstdlib_s.so \
linux32/steamconsole.so \
update_hosts_cached.vdf; \
else \
cd "$STEAMCMD_DIR" && rm -rf \
linux64 \
package \
public \
siteserverui \
steam \
linux32/libtier0_s.so \
linux32/libvstdlib_s.so \
linux32/steamclient.so \
linux32/steamconsole.so \
update_hosts_cached.vdf; \
rm -rf /root/.steam; \
fi; \
if [ "$APPID" = 90 ]; then \
# Retain `/root/Steam/appcache` to prevent `steamcmd` from re-downloading `hlds` game entirely on game updates
rm -rf $( find /root/Steam -mindepth 1 -maxdepth 1 | grep -v '^/root/Steam/appcache' ); \
else \
# Cleanup. This also cleans up user data
rm -rf /root/Steam; \
fi;
# Apply game fixes
RUN echo "[BUILD] Applying game fixes"; \
# Create steam_appid.txt containing the game's appid to prevent crashes on first run
echo "[BUILD] CLIENT_APPID: $CLIENT_APPID"; \
echo "$CLIENT_APPID" > "$SERVER_DIR/steam_appid.txt"; \
# Create necessary symlinks for hlds
if [ "$APPID" = 90 ]; then \
echo "[UPDATE] Applying hotfixes for hlds"; \
# Hotfix "Error:./libstdc++.so.6: version CXXABI_1.3.8' not found"
ln -sfnv /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 /server/libgcc_s.so.1; \
ln -sfnv /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /server/libstdc++.so.6; \
ln -sfnv /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /steamcmd/linux32/libstdc++.so.6; \
fi; \
# Create necessary symlinks for srcds/cs2
if [ "$APPID" = 730 ]; then \
mkdir -p /root/.steam/sdk64; \
mkdir -p /root/.steam/sdk32; \
ln -sf "/$STEAMCMD_DIR/linux64/steamclient.so" /root/.steam/sdk64/steamclient.so; \
ln -sf "/$STEAMCMD_DIR/linux32/steamclient.so" /root/.steam/sdk32/steamclient.so; \
fi;
# For directly running the hlds_linux / srcds_linux binary
ENV LD_LIBRARY_PATH .:bin:$LD_LIBRARY_PATH
ENV APPID $APPID
ENV MOD $MOD
ENV CLIENT_APPID $CLIENT_APPID
ENV SERVER_DIR $SERVER_DIR
ENV PATH $PATH:$SERVER_DIR
WORKDIR $SERVER_DIR
ENTRYPOINT ["/bin/bash", "-c"]
CMD [""]