Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial attempt to add steam user; #60

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a36f453
Initial attempt to add steam user;
Renegade-Master Feb 7, 2023
55b6ddf
Improve user home directory ownership;
Renegade-Master Feb 7, 2023
b6a4ec2
Improve user home directory ownership;
Renegade-Master Feb 7, 2023
95ec5a7
Modify directory permissions;
Renegade-Master Feb 8, 2023
d1cd883
Modify file permissions;
Renegade-Master Feb 8, 2023
bc80b33
Modify error logging;
Renegade-Master Feb 8, 2023
715302b
Improve error logging
Renegade-Master Feb 18, 2023
ebab5e6
Enabled Debug logs in GHA;
Renegade-Master Feb 18, 2023
8ea8e91
Improve logging
Renegade-Master Feb 18, 2023
1d6eac2
Run GHA as root
Renegade-Master Feb 18, 2023
f5abf62
Modifiy user in Dockerfile;
Renegade-Master Feb 18, 2023
d6b6958
Update GHA;
Renegade-Master Feb 18, 2023
05cb40c
Attempt permissions modification;
Renegade-Master Feb 18, 2023
84ac2b0
Update error logging;
Renegade-Master Feb 18, 2023
9747f96
Correct startup issue;
Renegade-Master Feb 18, 2023
232dfa8
Improve failed install detection;
Renegade-Master Feb 18, 2023
a4a9059
Add ownership change to installation;
Renegade-Master Feb 18, 2023
c32ebf3
Update GHA;
Renegade-Master Feb 18, 2023
12d2960
Update GHA;
Renegade-Master Feb 18, 2023
f1762ce
Update GHA;
Renegade-Master Feb 18, 2023
b3a888a
Update GHA;
Renegade-Master Feb 18, 2023
36bfea9
Update GHA;
Renegade-Master Feb 18, 2023
785d900
Update GHA;
Renegade-Master Feb 18, 2023
4ba3180
Update GHA;
Renegade-Master Feb 18, 2023
e9f5cd5
Update GHA;
Renegade-Master Feb 18, 2023
0a2b5cd
Modify user creation;
Renegade-Master Feb 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 29 additions & 10 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# Project Zomboid Dedicated Server using SteamCMD Docker Image.
# Copyright (C) 2021-2022 Renegade-Master [[email protected]]
# Copyright (C) 2021-2023 Renegade-Master [[email protected]]
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -19,6 +19,7 @@
name: Build and Test Server Image

on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
Expand All @@ -43,14 +44,13 @@ jobs:
- name: Set Variables
id: variables
run: |
echo "::set-output name=datetime::$(date +%Y%m%dT%H%M%SZ)"
echo "::set-output name=userid::$(id -u)"
echo "::set-output name=groupid::$(id -g)"
echo "datetime=$(date +%Y%m%dT%H%M%SZ)" >> $GITHUB_OUTPUT
echo "userid=$(id -u)" >> $GITHUB_OUTPUT
echo "groupid=$(id -g)" >> $GITHUB_OUTPUT

- name: Set Permissions on Executable Scripts
run: |
chmod +x src/install_server.scmd
chmod +x src/run_server.sh
chmod +x src/install_server.scmd src/run_server.sh

- name: Make Directories
run: mkdir ZomboidConfig ZomboidDedicatedServer
Expand Down Expand Up @@ -79,10 +79,12 @@ jobs:
# Run the Docker Image
docker run \
--rm \
--user ${{ steps.variables.outputs.userid }}:${{ steps.variables.outputs.groupid }} \
--name zomboid-dedicated-server \
--mount type=bind,source="$(pwd)/ZomboidDedicatedServer",target=/home/steam/ZomboidDedicatedServer \
--mount type=bind,source="$(pwd)/ZomboidConfig",target=/home/steam/Zomboid \
--env=AUTOSAVE_INTERVAL="16" \
--env=DEBUG="true" \
--env=DEFAULT_PORT="25496" \
--env=GC_CONFIG="G1GC" \
--env=MAP_NAMES="BedfordFalls;North;South;West" \
Expand All @@ -107,6 +109,7 @@ jobs:
if: ${{ success() && matrix.system == 'docker-compose' }}
run: |
sed -i "s/AUTOSAVE_INTERVAL=.*\"/AUTOSAVE_INTERVAL=16\"/g" "./docker-compose.yaml"
sed -i "s/DEBUG=.*\"/DEBUG=true\"/g" "./docker-compose.yaml"
sed -i "s/DEFAULT_PORT=.*\"/DEFAULT_PORT=25496\"/g" "./docker-compose.yaml"
sed -i "s/GC_CONFIG=.*\"/GC_CONFIG=G1GC\"/g" "./docker-compose.yaml"
sed -i "s/MAP_NAMES=.*\"/MAP_NAMES=BedfordFalls;North;South;West\"/g" "./docker-compose.yaml"
Expand All @@ -121,6 +124,8 @@ jobs:
sed -i "s/SERVER_PASSWORD=.*/SERVER_PASSWORD=github_action_test_password\"/g" "./docker-compose.yaml"
sed -i "s/UDP_PORT=.*\"/UDP_PORT=25499\"/g" "./docker-compose.yaml"

echo " user: ${{ steps.variables.outputs.userid }}:${{ steps.variables.outputs.groupid }}" >> "./docker-compose.yaml"

cat docker-compose.yaml

- name: Build the Docker-Compose Image
Expand Down Expand Up @@ -166,10 +171,12 @@ jobs:
# Run the Podman Image
podman run \
--rm \
--user ${{ steps.variables.outputs.userid }}:${{ steps.variables.outputs.groupid }} \
--name zomboid-dedicated-server \
--mount type=bind,source="$(pwd)/ZomboidDedicatedServer",target=/home/steam/ZomboidDedicatedServer \
--mount type=bind,source="$(pwd)/ZomboidConfig",target=/home/steam/Zomboid \
--env=AUTOSAVE_INTERVAL="16" \
--env=DEBUG="true" \
--env=DEFAULT_PORT="25496" \
--env=GC_CONFIG="G1GC" \
--env=MAP_NAMES="BedfordFalls;North;South;West" \
Expand All @@ -191,13 +198,21 @@ jobs:
run: |
pwd
echo ''
ls -lAuhFn ./ZomboidDedicatedServer/ > ./dedicated-server-install-listing.txt
ls -lAuhFn ./ | tee ./root-fs-listing.txt
echo ''
tree -aL 10 ./ | tee ./root-fs-tree.txt
echo ''
ls -lAuhFn ./src/ | tee ./src-listing.txt
echo ''
tree -aL 10 ./src/ | tee ./src-tree.txt
echo ''
ls -lAuhFn ./ZomboidDedicatedServer/ | tee ./dedicated-server-install-listing.txt
echo ''
ls -lAuhFn ./ZomboidConfig/ > ./dedicated-server-config-listing.txt
ls -lAuhFn ./ZomboidConfig/ | tee ./dedicated-server-config-listing.txt
echo ''
tree -aL 10 ./ZomboidDedicatedServer/ > ./dedicated-server-install-tree.txt
tree -aL 10 ./ZomboidDedicatedServer/ | tee ./dedicated-server-install-tree.txt
echo ''
tree -aL 10 ./ZomboidConfig/ > ./dedicated-server-config-tree.txt
tree -aL 10 ./ZomboidConfig/ | tee ./dedicated-server-config-tree.txt

- name: Upload Docker Logs
if: ${{ always() }}
Expand All @@ -219,8 +234,12 @@ jobs:
ZomboidDedicatedServer/ProjectZomboid64.json
dedicated-server-install-listing.txt
dedicated-server-config-listing.txt
root-fs-listing.txt
src-listing.txt
dedicated-server-install-tree.txt
dedicated-server-config-tree.txt
root-fs-config-tree.txt
src-config-tree.txt

test-docker:
name: Test Server
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/push_new_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ jobs:
- name: Set Variables
id: variables
run: |
echo "::set-output name=dkimagepath::renegademaster/zomboid-dedicated-server"
echo "::set-output name=ghimagepath::renegade-master/zomboid-dedicated-server"
echo "::set-output name=qyimagepath::renegade_master/zomboid-dedicated-server"
echo "::set-output name=datetime::$(date +%Y%m%dT%H%M%SZ)"
echo "datetime=$(date +%Y%m%dT%H%M%SZ)" >> $GITHUB_OUTPUT
echo "dkimagepath=renegademaster/zomboid-dedicated-server" >> $GITHUB_OUTPUT
echo "ghimagepath=renegade-master/zomboid-dedicated-server" >> $GITHUB_OUTPUT
echo "qyimagepath=renegade_master/zomboid-dedicated-server" >> $GITHUB_OUTPUT

- name: Login to Image Repositories
run: |
Expand Down
6 changes: 3 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Version 3, 29 June 2007

Project Zomboid Dedicated Server using SteamCMD Docker Image.
Copyright (C) 2021-2022 Renegade-Master [[email protected]]
Copyright (C) 2021-2023 Renegade-Master [[email protected]]

Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
Expand Down Expand Up @@ -635,7 +635,7 @@ state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

Project Zomboid Dedicated Server using SteamCMD Docker Image.
Copyright (C) 2021-2022 Renegade-Master [[email protected]]
Copyright (C) 2021-2023 Renegade-Master [[email protected]]

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -656,7 +656,7 @@ Also add information on how to contact you by electronic and paper mail.
notice like this when it starts in an interactive mode:

Project Zomboid Dedicated Server using SteamCMD Docker Image.
Copyright (C) 2021-2022 Renegade-Master [[email protected]]
Copyright (C) 2021-2023 Renegade-Master [[email protected]]

This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
Expand Down
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,15 @@ docker run --detach \
docker.io/renegademaster/zomboid-dedicated-server:latest
```

The default behaviour of the Container is not to automatically restart after a crash to give the user time to investigate the cause of the issue. You may however want to change the [restart policy](https://docs.docker.com/engine/reference/run/#restart-policies---restart) to automatically recover from an unexpected failure. The following options will help to recover from such a situation:
The default behaviour of the Container is not to automatically restart after a crash to give the user time to
investigate the cause of the issue. You may however want to change
the [restart policy](https://docs.docker.com/engine/reference/run/#restart-policies---restart) to automatically recover
from an unexpected failure. The following options will help to recover from such a situation:

- `--restart=unless-stopped` will restart the container every time that it exits unless the Container is stopped using the Docker/Podman API.
- `--restart=on-failure[:max-retries]` will restart the container only if it exits with a non-zero exit code. Optionally, it can also be configured to only restart a fixed number of times to help prevent crash-loops.
- `--restart=unless-stopped` will restart the container every time that it exits unless the Container is stopped using
the Docker/Podman API.
- `--restart=on-failure[:max-retries]` will restart the container only if it exits with a non-zero exit code.
Optionally, it can also be configured to only restart a fixed number of times to help prevent crash-loops.

These same options can be set in the `docker-compose.yaml` file.

Expand All @@ -69,7 +74,7 @@ runs [here](https://github.com/Renegade-Master/zomboid-dedicated-server/actions/
### Images:

| Provider | Image | Pull Command |
| ---------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
| [GitHub Packages](https://github.com/Renegade-Master/zomboid-dedicated-server/pkgs/container/zomboid-dedicated-server) | `ghcr.io/renegade-master/zomboid-dedicated-server` | `docker pull ghcr.io/renegade-master/zomboid-dedicated-server:x.y.z`<br/>`docker pull ghcr.io/renegade-master/zomboid-dedicated-server:latest` |
| [DockerHub](https://hub.docker.com/r/renegademaster/zomboid-dedicated-server) | `docker.io/renegademaster/zomboid-dedicated-server` | `docker pull docker.io/renegademaster/zomboid-dedicated-server:x.y.z`<br/>`docker pull docker.io/renegademaster/zomboid-dedicated-server:latest` |
| [Red Hat Quay](https://quay.io/repository/renegade_master/zomboid-dedicated-server) | `quay.io/renegade_master/zomboid-dedicated-server` | `docker pull quay.io/renegade_master/zomboid-dedicated-server:x.y.z`<br/>`docker pull quay.io/renegade_master/zomboid-dedicated-server:latest` |
Expand All @@ -87,7 +92,7 @@ runs [here](https://github.com/Renegade-Master/zomboid-dedicated-server/actions/
Two directories are required to be present on the host:

| Name | Directory | Description |
| ------------------ | ------------------------ | ---------------------------------------------------- |
|--------------------|--------------------------|------------------------------------------------------|
| Configuration Data | `ZomboidConfig` | For storing the server configuration and save files. |
| Installation Data | `ZomboidDedicatedServer` | For storing the server game data. |

Expand Down Expand Up @@ -116,7 +121,7 @@ table provided by the Docker image.
There are a total of three ports that can be utilised by the server, but only two are strictly required:

| Name | Default Port | Description | Required |
|----------------|--------------|----------------------------------------------------------------------| -------- |
|----------------|--------------|----------------------------------------------------------------------|----------|
| `DEFAULT_PORT` | `16261` | Port used by the server to listen for connections. | yes |
| `RCON_PORT` | `27015` | Port used by the server to listen for RCON connections/commands. | no |
| `UDP_PORT` | `16262` | Additional Port used by the server to facilitate Client connections. | yes |
Expand Down Expand Up @@ -147,10 +152,11 @@ recommended for ease of configuration.
### Optional environment variables

| Argument | Description | Values | Default |
| ---------------- | -------------------------------------------- | ----------------- | ------------- |
|------------------|----------------------------------------------|-------------------|---------------|
| `ADMIN_PASSWORD` | Server Admin account password | [a-zA-Z0-9]+ | changeme |
| `ADMIN_USERNAME` | Server Admin account username | [a-zA-Z0-9]+ | superuser |
| `BIND_IP` | IP to bind the server to | 0.0.0.0 | 0.0.0.0 |
| `DEBUG` | Enable debug logging | (true&vert;false) | `false` |
| `GAME_VERSION` | Game version to serve | [a-zA-Z0-9_]+ | `public` |
| `GC_CONFIG` | Specifices Java GC to use | [a-zA-Z0-9_]+ | ZGC |
| `MAP_NAMES` | Map Names (e.g. North;South) | map1;map2;map3 | Muldraugh, KY |
Expand All @@ -169,7 +175,7 @@ the configured environment variable.
Any other values *can* and *should* be edited directly in the .ini file.

| Argument | Description | .ini variable | Values | Default |
|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------| --------------------- | ---------------------- | ------------- |
|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------|-----------------------|------------------------|---------------|
| `AUTOSAVE_INTERVAL` | Interval between autosaves in minutes | SaveWorldEveryMinutes | [0-9]+ | 15m |
| `DEFAULT_PORT` | Port for other players to connect to | DefaultPort | 1000 - 65535 | 16261 |
| `MAX_PLAYERS` | Maximum players allowed in the Server | MaxPlayers | [0-9]+ | 16 |
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# Project Zomboid Dedicated Server using SteamCMD Docker Image.
# Copyright (C) 2021-2022 Renegade-Master [[email protected]]
# Copyright (C) 2021-2023 Renegade-Master [[email protected]]
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -31,6 +31,7 @@ services:
- "ADMIN_USERNAME=superuser"
- "AUTOSAVE_INTERVAL=15"
- "BIND_IP=0.0.0.0"
- "DEBUG=false"
- "DEFAULT_PORT=16261"
- "GAME_VERSION=public"
- "GC_CONFIG=ZGC"
Expand Down
30 changes: 25 additions & 5 deletions docker/zomboid-dedicated-server.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Project Zomboid Dedicated Server using SteamCMD Docker Image.
# Copyright (C) 2021-2022 Renegade-Master [[email protected]]
# Copyright (C) 2021-2023 Renegade-Master [[email protected]]
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -22,24 +22,44 @@
#######################################################################

# Base Image
ARG BASE_IMAGE="docker.io/renegademaster/steamcmd-minimal:1.1.2"
ARG BASE_IMAGE="docker.io/renegademaster/steamcmd-minimal:2.0.0-root"
ARG UID=1000
ARG GID=${UID}
ARG RUN_USER=steam

FROM ${BASE_IMAGE}
ARG UID
ARG GID
ARG RUN_USER

# Add metadata labels
LABEL com.renegademaster.zomboid-dedicated-server.authors="Renegade-Master" \
com.renegademaster.zomboid-dedicated-server.contributors="JohnEarle, ramielrowe" \
com.renegademaster.zomboid-dedicated-server.source-repository="https://github.com/Renegade-Master/zomboid-dedicated-server" \
com.renegademaster.zomboid-dedicated-server.image-repository="https://hub.docker.com/renegademaster/zomboid-dedicated-server"

# Copy the source files
COPY src /home/steam/
USER 0:0

# Install Python, and take ownership of rcon binary
RUN apt-get update && apt-get install -y --no-install-recommends \
python3-minimal iputils-ping tzdata \
python3-minimal iputils-ping \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/*

# Setup runtime user
RUN groupadd "${RUN_USER}" \
--gid "${GID}" \
&& useradd "${RUN_USER}" --create-home \
--uid "${UID}" \
--gid "${GID}" \
--home-dir /home/${RUN_USER} \
&& chown -R ${UID}:${GID} /home/${RUN_USER}/

# Login as the runtime user
USER ${RUN_USER}

# Copy the source files
COPY --chown=${RUN_USER} src /home/steam/

# Run the setup script
ENTRYPOINT ["/bin/bash", "/home/steam/run_server.sh"]
2 changes: 1 addition & 1 deletion src/edit_server_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#
# Project Zomboid Dedicated Server using SteamCMD Docker Image.
# Copyright (C) 2021-2022 Renegade-Master [[email protected]]
# Copyright (C) 2021-2023 Renegade-Master [[email protected]]
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
Loading