This commit is contained in:
John Edwards 2023-11-29 22:16:49 +00:00
parent 9802ea3edd
commit da6155afc5
4 changed files with 11 additions and 3 deletions

View file

@ -13,19 +13,19 @@ This Docker image contains the dedicated server of the game.
Running using Docker: Running using Docker:
```console ```console
$ docker run -d --name=cs2 -p 27015:27015/tcp -p 27015:27015/udp -p 27020:27020/tcp joedwards32/cs2 $ docker run -d --name=cs2 -e SRCDS_TOKEN={YOURTOKEN} -p 27015:27015/tcp -p 27015:27015/udp -p 27020:27020/tcp joedwards32/cs2
``` ```
Running using a bind mount for data persistence on container recreation: Running using a bind mount for data persistence on container recreation:
```console ```console
$ mkdir -p $(pwd)/cs2-data $ mkdir -p $(pwd)/cs2-data
$ chmod 777 $(pwd)/cs2-data # Makes sure the directory is writeable by the unprivileged container user $ chmod 777 $(pwd)/cs2-data # Makes sure the directory is writeable by the unprivileged container user
$ docker run -d --name=cs2 -v $(pwd)/cs2-data:/home/steam/cs2-dedicated/ -p 27015:27015/tcp -p 27015:27015/udp -p 27020:27020/tcp joedwards32/cs2 $ docker run -d --name=cs2 -e SRCDS_TOKEN={YOURTOKEN} -v $(pwd)/cs2-data:/home/steam/cs2-dedicated/ -p 27015:27015/tcp -p 27015:27015/udp -p 27020:27020/tcp joedwards32/cs2
``` ```
or using docker-compose, see [examples](https://github.com/joedwards32/CS2/blob/main/examples/docker-compose.yml): or using docker-compose, see [examples](https://github.com/joedwards32/CS2/blob/main/examples/docker-compose.yml):
```console ```console
# Remember to update passwords in your compose file # Remember to update passwords and SRCDS_TOKEN in your compose file
$ docker compose --file examples/docker-compose.yml up -d cs2-server $ docker compose --file examples/docker-compose.yml up -d cs2-server
``` ```
@ -49,6 +49,7 @@ Feel free to overwrite these environment variables, using -e (--env):
### Server Configuration ### Server Configuration
```dockerfile ```dockerfile
SRCDS_TOKEN="" Game Server Token from https://steamcommunity.com/dev/managegameservers
CS2_SERVERNAME="changeme" (Set the visible name for your private server) CS2_SERVERNAME="changeme" (Set the visible name for your private server)
CS2_IP="" (CS2 server listening IP address, 0.0.0.0 - all IP addresses on the local machine, empty - IP identified automatically) CS2_IP="" (CS2 server listening IP address, 0.0.0.0 - all IP addresses on the local machine, empty - IP identified automatically)
CS2_PORT=27015 (CS2 server listen port tcp_udp) CS2_PORT=27015 (CS2 server listen port tcp_udp)

View file

@ -59,6 +59,7 @@ ENV CS2_SERVERNAME="cs2 private server" \
TV_RELAY_PW="changeme" \ TV_RELAY_PW="changeme" \
TV_MAXRATE=0 \ TV_MAXRATE=0 \
TV_DELAY=0 \ TV_DELAY=0 \
SRCDS_TOKEN="" \
CS2_ADDITIONAL_ARGS="" CS2_ADDITIONAL_ARGS=""
# Set permissions on STEAMAPPDIR # Set permissions on STEAMAPPDIR

View file

@ -70,6 +70,10 @@ else
CS2_IP_ARGS="-ip ${CS2_IP}" CS2_IP_ARGS="-ip ${CS2_IP}"
fi fi
if [[ ! -z $SRCDS_TOKEN ]]; then
SV_SETSTEAMACCOUNT_ARGS="+sv_setsteamaccount ${SRCDS_TOKEN}"
fi
# Start Server # Start Server
if [[ ! -z $CS2_RCON_PORT ]]; then if [[ ! -z $CS2_RCON_PORT ]]; then
@ -86,6 +90,7 @@ eval "./cs2" -dedicated \
+mapgroup "${CS2_MAPGROUP}" \ +mapgroup "${CS2_MAPGROUP}" \
+map "${CS2_STARTMAP}" \ +map "${CS2_STARTMAP}" \
+rcon_password "${CS2_RCONPW}" \ +rcon_password "${CS2_RCONPW}" \
"${SV_SETSTEAMACCOUNT_ARGS}" \
+sv_password "${CS2_PW}" \ +sv_password "${CS2_PW}" \
+sv_lan "${CS2_LAN}" \ +sv_lan "${CS2_LAN}" \
"${CS2_ADDITIONAL_ARGS}" "${CS2_ADDITIONAL_ARGS}"

View file

@ -5,6 +5,7 @@ services:
container_name: cs2-dedicated container_name: cs2-dedicated
environment: environment:
# Server configuration # Server configuration
- SRCDS_TOKEN # Game Server Token from https://steamcommunity.com/dev/managegameservers
- CS2_SERVERNAME=changeme # (Set the visible name for your private server) - CS2_SERVERNAME=changeme # (Set the visible name for your private server)
- CS2_PORT=27015 # (CS2 server listen port tcp_udp) - CS2_PORT=27015 # (CS2 server listen port tcp_udp)
- CS2_RCON_PORT # (Optional, use a simple TCP proxy to have RCON listen on an alternative port. Useful for services like AWS Fargate which do not support mixed protocol ports.) - CS2_RCON_PORT # (Optional, use a simple TCP proxy to have RCON listen on an alternative port. Useful for services like AWS Fargate which do not support mixed protocol ports.)