-
-
Notifications
You must be signed in to change notification settings - Fork 62
284 lines (250 loc) · 9.93 KB
/
docker-build.yml
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
name: Build and Test Server Image
on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
branches: [ main ]
defaults:
run:
shell: bash
jobs:
build-and-run:
name: Build and Run Server
runs-on: ubuntu-latest
outputs:
installdir: ${{ steps.volumes.outputs.installdir }}
configdir: ${{ steps.volumes.outputs.configdir }}
strategy:
matrix:
system: [ podman ]
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set Variables
id: variables
run: |
echo "datetime=$(date +%Y%m%dT%H%M%SZ)" >> $GITHUB_OUTPUT
echo "userid=$(id -u)" >> $GITHUB_OUTPUT
echo "groupid=$(id -g)" >> $GITHUB_OUTPUT
echo "hostip=$(hostname -I)" >> $GITHUB_OUTPUT
- name: Make Volumes
id: volumes
run: |
podman volume create zomboid-server-podman
podman volume create zomboid-config-podman
echo "installdir=$(podman volume inspect zomboid-server-podman | jq -r '.[].Mountpoint' -)" >> $GITHUB_OUTPUT
echo "configdir=$(podman volume inspect zomboid-config-podman | jq -r '.[].Mountpoint' -)" >> $GITHUB_OUTPUT
#######################
# Podman Build System #
#######################
- name: Download the latest version of the Image
if: ${{ success() && matrix.system == 'podman' }}
run: |
podman pull docker.io/renegademaster/zomboid-dedicated-server:latest
- name: Build the Podman Image
if: ${{ success() && matrix.system == 'podman' }}
run: |
BUILDAH_LAYERS=true buildah bud \
--file image/zomboid-server.Containerfile \
--tag docker.io/renegademaster/zomboid-dedicated-server:${{ steps.variables.outputs.datetime }} \
.
- name: Test Run the Podman Image
if: ${{ success() && matrix.system == 'podman' }}
continue-on-error: true
timeout-minutes: 10
run: |
# Start a timed shutdown signal
(sleep 360 && podman exec \
zomboid-server bash -c \
"rcon --address 127.0.0.1:\${RCON_PORT} --password \${RCON_PASSWORD} quit") &
# Run the Podman Image
podman run \
--rm \
--name zomboid-server \
--volume "zomboid-server-podman":/home/steam/ZomboidDedicatedServer \
--volume "zomboid-config-podman":/home/steam/Zomboid \
--env=AUTOSAVE_INTERVAL="16" \
--env LOG_LEVEL=DEBUG \
--env=DEFAULT_PORT="25496" \
--env=GC_CONFIG="G1GC" \
--env=MAP_NAMES="BedfordFalls;North;South;West" \
--env=MAX_PLAYERS="14" \
--env=MAX_RAM="6144m" \
--env=MOD_NAMES="BedfordFalls" \
--env=MOD_WORKSHOP_IDS="522891356" \
--env=PAUSE_ON_EMPTY="true" \
--env=PUBLIC_SERVER="false" \
--env=RCON_PASSWORD="github_action_test_rcon_password" \
--env=RCON_PORT="27025" \
--env=SERVER_NAME="GitHubActionTest" \
--env=SERVER_PASSWORD="github_action_test_password" \
--env=UDP_PORT="25499" \
docker.io/renegademaster/zomboid-dedicated-server:${{ steps.variables.outputs.datetime }} \
2>&1 | tee ./container.log
- name: Investigate File Structure
run: |
pwd
echo ''
ls -lAuhFn ./ | tee ./root-fs-listing.txt
echo ''
tree -aL 10 ./ | tee ./root-fs-tree.txt
echo ''
ls -lAuhFn ${{ steps.volumes.outputs.installdir }} | tee ./dedicated-server-install-listing.txt
echo ''
ls -lAuhFn ${{ steps.volumes.outputs.configdir }} | tee ./dedicated-server-config-listing.txt
echo ''
tree -aL 10 ${{ steps.volumes.outputs.installdir }} | tee ./dedicated-server-install-tree.txt
echo ''
tree -aL 10 ${{ steps.volumes.outputs.configdir }} | tee ./dedicated-server-config-tree.txt
- name: Copy Server Files to Upload Directory
run: |
mkdir ZomboidServerInfo
cp ${{ steps.volumes.outputs.configdir }}/Server/GitHubActionTest.ini \
${{ steps.volumes.outputs.configdir }}/Server/GitHubActionTest_SandboxVars.lua \
${{ steps.volumes.outputs.installdir }}/ProjectZomboid64.json \
./ZomboidServerInfo
- name: Upload Docker Logs
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: docker-logs-${{ matrix.system }}
path: |
container.log
- name: Upload Server Configuration
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: server-configs-${{ matrix.system }}
path: |
podman-compose.yaml
ZomboidServerInfo/
dedicated-server-install-listing.txt
dedicated-server-config-listing.txt
root-fs-listing.txt
dedicated-server-install-tree.txt
dedicated-server-config-tree.txt
root-fs-config-tree.txt
test-docker:
name: Test Server
runs-on: ubuntu-latest
needs:
- build-and-run
strategy:
matrix:
system: [ podman ]
env:
INSTALLDIR: ${{needs.build-and-run.outputs.installdir}}
CONFIGDIR: ${{needs.build-and-run.outputs.configdir}}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Download Docker Logs
uses: actions/download-artifact@v4
with:
name: docker-logs-${{ matrix.system }}
- name: Download Server Configs
uses: actions/download-artifact@v4
with:
name: server-configs-${{ matrix.system }}
- name: Test - Server Started
run: |
check_for_config() {
if ! grep -q -iE "$1" "./container.log"; then
printf "Could not find [%s] in [%s]\n" "$1" "./container.log"
exit 1
else
printf "Found [%s] in [%s]\n" "$1" "./container.log"
fi
}
check_for_config "LuaNet: Initialization \[DONE\]"
- name: Test - Server Stopped Gracefully
run: |
check_for_config() {
if ! grep -q -iE "$1" "./container.log"; then
printf "Could not find [%s] in [%s]\n" "$1" "./container.log"
exit 1
else
printf "Found [%s] in [%s]\n" "$1" "./container.log"
fi
}
check_for_config "ZNet: \[-> CZombienet: RakNetPeerInterface_Shutdown"
- name: Test - Configuration Completed
run: |
check_for_config() {
if ! grep -q -iE "$1" "./container.log"; then
printf "Could not find [%s] in [%s]\n" "$1" "./container.log"
else
printf "Found [%s] in [%s]\n" "$1" "./container.log"
exit 1
fi
}
check_for_config "sed: can't read"
check_for_config "not found!"
- name: Test - Server JVM Configuration Applied
run: |
check_for_config() {
if ! grep -q -iE "$1" "./ZomboidServerInfo/ProjectZomboid64.json"; then
printf "Could not find [%s] in [%s]\n" "$1" "./ZomboidServerInfo/ProjectZomboid64.json"
exit 1
else
printf "Found [%s] in [%s]\n" "$1" "./ZomboidServerInfo/ProjectZomboid64.json"
fi
}
check_for_config "\-Xmx6144m"
check_for_config "\-XX:\+UseG1GC"
- name: Test - Server Configuration Applied
run: |
install_directory="./ZomboidServerInfo"
workshop_directory="${install_directory}/steamapps/workshop"
mods_directory="${workshop_directory}/content/108600/522891356/mods"
bedford_maps="${mods_directory}/Bedford Falls/media/maps"
map_search_string="$(cat << EOF
│ ├── content
│ │ └── 108600
│ │ └── 522891356
│ │ └── mods
│ │ └── Bedford Falls
│ │ ├── media
│ │ │ ├── lua
│ │ │ │ ├── client
EOF
)"
py_script="$(cat << EOF
to_find = """${map_search_string}"""
with open("dedicated-server-install-tree.txt", "r") as file:
file_string = file.read()
if (to_find in file_string):
print("FOUND")
else:
print("NOT_FOUND")
EOF
)"
check_for_config() {
if ! grep -q -iE "$1" "./ZomboidServerInfo/GitHubActionTest.ini"; then
printf "Could not find [%s] in [%s]\n" "$1" "./ZomboidServerInfo/GitHubActionTest.ini"
exit 1
else
printf "Found [%s] in [%s]\n" "$1" "./ZomboidServerInfo/GitHubActionTest.ini"
fi
}
check_for_directory() {
if [[ $(python3 -c "${py_script}") == "FOUND" ]]; then
printf "Found map directory in [%s]\n" "${bedford_maps}"
else
printf "Could not find map directory in [%s]\n" "${bedford_maps}"
exit 1
fi
}
check_for_config "DefaultPort=25496"
check_for_config "Map=BedfordFalls;North;South;West"
check_for_config "MaxPlayers=14"
check_for_config "Open=false"
check_for_config "Password=github_action_test_password"
check_for_config "PauseEmpty=true"
check_for_config "PublicName=GitHubActionTest"
check_for_config "RCONPassword=github_action_test_rcon_password"
check_for_config "RCONPort=27025"
check_for_config "SaveWorldEveryMinutes=16"
check_for_config "UDPPort=25499"
check_for_directory