Skip to content
This repository has been archived by the owner on Apr 10, 2022. It is now read-only.

Commit

Permalink
Add SDL libraries, ensure steam environment set.
Browse files Browse the repository at this point in the history
* Add SDL libraries for steam install, preventing new SDL errors
  ValveSoftware/steam-for-linux#7036
* Ensure steam user environment is setup correctly, updated instructions.
* Enforce set variables for startup scripts.
* Remove trace logging for startup scripts.
* Update examples.
  • Loading branch information
r-pufky committed Aug 15, 2020
1 parent 3cca9f8 commit 142ad09
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 32 deletions.
1 change: 1 addition & 0 deletions Dockerfile/BASE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ENV SERVER_DIR=/data/server \
STEAM=/steam \
PLATFORM=windows \
STEAM_APP_ID=0 \
STEAM_APP_EXTRAS='' \
UPDATE_OS=1 \
UPDATE_STEAM=1 \
UPDATE_SERVER=1 \
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile/INSTALL_STEAM
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ echo steam steam/question select 'I AGREE' | debconf-set-selections && \
dpkg --add-architecture i386 && \
apt-get --quiet update && \
apt-get --quiet --yes upgrade && \
# Explicitly add SDL library: https://github.com/ValveSoftware/steam-for-linux/issues/7036
apt-get install --yes --install-recommends \
libsdl2-2.0-0:i386 \
libsdl2-2.0-0 \
gdb && \
apt-get install --yes --install-recommends \
steamcmd && \
7 changes: 5 additions & 2 deletions Dockerfile/STEAM_SERVICE
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Create steam user and setup permissions.
useradd --create --home ${STEAM} steam && \
su steam -c " \
su - steam -c " \
cd ${STEAM} && \
steamcmd +quit" && \
mkdir -p /steam/.steam/{sdk32,sdk64} && \
echo "\nexport PATH=\$PATH:/steam/.steam/steamcmd/linux32:/steam/.steam/steamcmd/linux64" | tee -a /steam/.profile && \
# winehq may potentially take ~5 minutes on first boot to launch, due to
# blocking on boot events:
#
Expand All @@ -20,8 +22,9 @@ su steam -c " \
# https://ubuntuforums.org/archive/index.php/t-1499348.html
# https://bugs.winehq.org/show_bug.cgi?id=38653
echo 'Updating wine, ignore any errors ...' && \
su steam -c 'wineboot --update' /dev/null 2>&1 && \
su - steam -c 'wineboot --update' /dev/null 2>&1 && \
echo 'Wine update completed.' && \
mkdir -p /data && \
chown -R steam:steam ${STEAM} /data /docker && \
chmod 0755 /docker/* && \

61 changes: 38 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
Generic Steam dedicated server using Docker.

This provides a core installation of `steamcmd` to host dedicated servers. Both
linux and windows servers can be hosted using this image.
linux and windows servers (via [wine](winehq.org)) can be hosted using this
image.

## How it Runs
The docker image contains a base ubuntu install with wine (windows support) and
Expand All @@ -31,22 +32,22 @@ Fully working examples of different dedicated servers.

## Version Tags

| Tag | Description |
|--------------|-------------------------------------------------------------------------------------|
| stable | Ubuntu 18.04 with wine and steamcmd from binary repo. |
| latest | Ubuntu 18.04 with latest winehq STABLE packages and steamcmd. This **WILL** break. |
| experimental | Ubuntu 18.04 with latest winehq STAGING packages and steamcmd. This **WILL** break. |
| Tag | Description |
|--------------|---------------------------------------------------------------------------------|
| stable | Ubuntu 18.04: wine, steamcmd (package). |
| latest | Ubuntu 18.04: winehq STABLE packages, steamcmd (package). This **WILL** break. |
| experimental | Ubuntu 18.04: winehq STAGING packages, steamcmd (package). This **WILL** break. |
* Containers are automatically rebuilt weekly.

## Parameters

| Parameter | Function | Default |
|------------------|------------------------------------------------------------------------------------------|----------------|
| SERVER_DIR | Location for server files. | `/data/server` |
| STEAM | Location of steamcmd client. |`/steam` |
| STEAM | Location of steamcmd client. | `/steam` |
| PLATFORM | Platform to force specify when auto updating. `linux` or `windows`. | `windows` |
| STEAM_APP_ID | Steam application ID for auto updating. | `0` |
| STEAM_APP_EXTRAS | Optional. Additional options for steam app update. | `` |
| STEAM_APP_EXTRAS | Optional. Additional options and values for steam app update, e.g setting BETA versions. | `` |
| UPDATE_OS | Update core OS on startup. `1` enable, `0` disable. | `1` |
| UPDATE_STEAM | Update steamcmd on startup. `1` enable, `0` disable. | `1` |
| UPDATE_SERVER | Update dedicated server specified by `STEAM_APP_ID` on startup. `1` enable, `0` disable. | `1` |
Expand All @@ -65,15 +66,15 @@ for a detailed list of steam ports.

| Port | Protocol | Required? | Description |
|-------|----------|-----------|-------------------------|
|`27015`| TCP | Optional | SRCDS RCON port. |
|`27015`| UDP | Mandatory | Gameplay traffic. |
|`27015`| TCP | Optional | SRCDS RCON port. |
|`27016`| UDP | Optional | Steam announce traffic. |

## Volumes

| Volume | Function |
|---------|--------------------------------------------|
| /data | User data location for images. |
| Volume | Function |
|---------|--------------------------------|
| /data | User data location for images. |

## User/Group IDs
When using data volumes (`-v` flags), permissions issues can occur between the
Expand All @@ -99,10 +100,9 @@ uid=1000(myuser) gid=1000(myuser) groups=1000(myuser),4(adm),24(cdrom),27(sudo),
The value of `uid` (user ID) and `gid` (group ID) are the ones that you should
be given the container.


## Detailed Usage Instructions
Details how to setup a new server from scratch. See [Example Configurations](#example-configurations)
for working examples.
Details how to setup a new server from scratch. See
[Example Configurations](#example-configurations) for working examples.

### docker-compose (windows dedicated server)
```
Expand Down Expand Up @@ -176,7 +176,7 @@ minimum exposure if there are vulnerabilities in the game, as well as prevent
any permissions issues with server files.

```
su steam -c 'your server launch command'
su - steam -c 'your server launch command'
```

> Your specific launch command will vary based on what server you install.
Expand All @@ -186,7 +186,7 @@ su steam -c 'your server launch command'
This will launch a **Left 4 Dead** ``srcsd_run`` linux dedicated server.

```
su steam -c "/data/server/srcds_run -console -game left4dead -map l4d_hospital01_apartment -port 27015 +maxplayers 4 -nohltv +exec /data/server.cfg"
su - steam -c "/data/server/srcds_run -console -game left4dead -map l4d_hospital01_apartment -port 27015 +maxplayers 4 -nohltv +exec /data/server.cfg"
```
* this example would launch a Left 4 Dead dedicated server (222840).

Expand All @@ -196,7 +196,7 @@ dedicated server documentation and forums for launching a dedicated windows
server under wine for your game.

```bash
su steam -c "xvfb-run --auto-servernum \
su - steam -c "xvfb-run --auto-servernum \
wine64 ${SERVER_DIR}/ConanSandbox/Binaries/Win64/ConanSandboxServer-Win64-Test.exe -nosteamclient -game -server -log"
```
* This example lauches a conan exiles dedicated server (443030).
Expand All @@ -210,14 +210,14 @@ For servers that don't require saving of state between reboots, a simple bash sc
Windows
```bash
# This will run wine (for windows servers) and launch the server.
su steam -c "xvfb-run --auto-servernum \
su - steam -c "xvfb-run --auto-servernum \
wine64 ${SERVER_DIR}/ConanSandbox/Binaries/Win64/ConanSandboxServer-Win64-Test.exe -nosteamclient -game -server -log"
```

Linux
```bash
# launch the dedicated linux server under the steam user.
su steam -c "/data/server/startserver.sh \
su - steam -c "/data/server/startserver.sh \
-configfile=/data/server/serverconfig.xml"
```

Expand Down Expand Up @@ -262,7 +262,7 @@ function shutdown() {
trap shutdown SIGINT SIGKILL SIGTERM

function start_server() {
su steam -c "xvfb-run --auto-servernum wine64 ${SERVER_DIR}/ConanSandbox/Binaries/Win64/ConanSandboxServer-Win64-Test.exe -nosteamclient -game -server -log"
su - steam -c "xvfb-run --auto-servernum wine64 ${SERVER_DIR}/ConanSandbox/Binaries/Win64/ConanSandboxServer-Win64-Test.exe -nosteamclient -game -server -log"
}

function watch_server() {
Expand Down Expand Up @@ -313,8 +313,8 @@ patches; remember to switch to the `steam` user when executing this commands.

custom_server
```bash
su steam -c "winetricks dotnet472"
su steam -c "winetricks vcrun2013"
su - steam -c "winetricks dotnet472"
su - steam -c "winetricks vcrun2013"
```

## Building
Expand Down Expand Up @@ -376,11 +376,26 @@ access to.
srcds_run ... -pidfile /data/server/{GAME}.pid
```

### Could not find `steamclient.so` or `[S_API FAIL] SteamAPI_Init() ... or a local steamclient.dll.`
The [Steam Liunus shared libary][6h] could not be found in your path.

Be sure to use `su - steam -c` to load the full steam user profile.

Link to the local `steamclient.so` file, or copy it to where your server binary
is executed. The default location is in the steam user directory:

```bash
/steam/.steam/steamcmd/linux{32,64}/steamclient.so
```

`ln -s -f /steam/.steam/steamcmd/linux32/steamclient.so /steam/.steam/sdk32/steamclient.so`

## Licensing
Steam Logo, SteamCMD ©2019 Valve Corporation. Steam and the Steam logo are
trademarks and/or registered trademarks of Valve Corporation in the U.S.
and/or other countries.

[3n]: https://github.com/alinmear/docker-conanexiles/blob/master/src/etc/supervisor/conf.d/conanexiles.conf
[2k]: https://docs.docker.com/compose/compose-file/#stop_grace_period
[6h]: https://developer.valvesoftware.com/wiki/SteamCMD
[f8]: https://raw.githubusercontent.com/r-pufky/steam/master/media/steam-icon-logo.png
4 changes: 2 additions & 2 deletions docs/examples/conan-exiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ and handling gracefully in coordination with `stop_grace_period`.
#
# Runs as root. Drop privileges.
#
# Capture kill/term signals and send SIGINT to gracefully shutdown conan server.
# Capture kill/term signal and send SIGINT to gracefully shutdown conan server.
PROCESS_WAIT_TIME=25
WATCHDOG_TIME=300

Expand All @@ -76,7 +76,7 @@ function shutdown() {
trap shutdown SIGINT SIGKILL SIGTERM

function start_server() {
su steam -c "xvfb-run --auto-servernum wine64 ${SERVER_DIR}/ConanSandbox/Binaries/Win64/ConanSandboxServer-Win64-Test.exe -nosteamclient -game -server -log"
su - steam -c "xvfb-run --auto-servernum wine64 ${SERVER_DIR}/ConanSandbox/Binaries/Win64/ConanSandboxServer-Win64-Test.exe -nosteamclient -game -server -log"
}

function watch_server() {
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/left-4-dead-2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Left 4 Dead 2
Dedicated Linux server example running Left 4 Dead 2 with sourcemod and metamod.
Dedicated Linux server example running Left 4 Dead 2 with sourcemod & metamod.

Assumes all files are based in `/d/games/l4d2` and have
`UID/GID` of `50520`.
Expand Down Expand Up @@ -57,7 +57,7 @@ directory` error.
# Runs as root. Drop privileges.
#
ln -s /d/games/l4d2/server.cfg /d/games/l4d2/data/server/left4dead2/cfg/server.cfg 2> /dev/null
su steam -c "/data/server/srcds_run -console -game left4dead2 -map c1m1_hotel -port 27015 +maxplayers 4 -nohltv +exec /data/server/left4dead2/cfg/server.cfg -pidfile /data/server/l4d2.pid"
su - steam -c "/data/server/srcds_run -console -game left4dead2 -map c1m1_hotel -port 27015 +maxplayers 4 -nohltv +exec /data/server/left4dead2/cfg/server.cfg -pidfile /data/server/l4d2.pid"
```

### Add custom server configuration.
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/left-4-dead.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Left 4 Dead
Dedicated Linux server example running Left 4 Dead with sourcemod and metamod.
Dedicated Linux server example running Left 4 Dead with sourcemod & metamod.

Assumes all files are based in `/d/games/l4d` and have
`UID/GID` of `50510`.
Expand Down Expand Up @@ -58,7 +58,7 @@ directory` error.
# Runs as root. Drop privileges.
#
ln -s /d/games/l4d/server.cfg /d/games/l4d/data/server/left4dead/cfg/server.cfg 2> /dev/null
su steam -c "/data/server/srcds_run -console -game left4dead -map l4d_hospital01_apartment -port 27015 +maxplayers 4 -nohltv +exec /data/server/left4dead/cfg/server.cfg -pidfile /data/server/l4d.pid"
su - steam -c "/data/server/srcds_run -console -game left4dead -map l4d_hospital01_apartment -port 27015 +maxplayers 4 -nohltv +exec /data/server/left4dead/cfg/server.cfg -pidfile /data/server/l4d.pid"
```

### Add custom server configuration.
Expand Down
2 changes: 1 addition & 1 deletion source/startup
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

CUSTOM=/data/custom_server

set -x -e
set -u -e
echo '--------------------------------------'
echo 'Propagating steam user permissions ...'
PUID=${PUID:-911}
Expand Down

0 comments on commit 142ad09

Please sign in to comment.