From 0483cb44cda2f8ee0fae16c3d6bcc327b9d0ca3c Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 14 Jun 2026 10:38:06 +0200 Subject: [PATCH] Initial commit --- .github/workflows/build.yml | 39 ++++++++++ Dockerfile | 46 ++++++++++++ README.md | 143 ++++++++++++++++++++++++++++++++++++ 3 files changed, 228 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 Dockerfile create mode 100644 README.md diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..e2764f2 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,39 @@ +name: Build +on: + push: + branches: + - master + + schedule: + - cron: 0 4 * * 7 + + workflow_dispatch: + +jobs: + latest: + runs-on: [runner] + container: git.sh-edraft.de/sh-edraft.de/act-runner:latest + steps: + - name: Clone Repository + uses: https://github.com/actions/checkout@v3 + with: + token: ${{ secrets.CI_ACCESS_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Login to registry git.sh-edraft.de + uses: https://github.com/docker/login-action@v1 + with: + registry: git.sh-edraft.de + username: ${{ secrets.CI_USERNAME }} + password: ${{ secrets.CI_ACCESS_TOKEN }} + + - name: Build docker + run: | + docker build -t git.sh-edraft.de/sh-edraft.de/garrysmod . + + - name: Push image + run: | + docker push git.sh-edraft.de/sh-edraft.de/garrysmod + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8af3a98 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,46 @@ +FROM hackebein/srcds + +ENV \ + # App + APPS="4020 -validate -language en,232330 -validate -language en" \ + # + # API + # http://steamcommunity.com/dev/apikey + AUTHKEY="" \ + # + # Public access + # automatic via API + GLSTAPP="4000" \ + # manual + # APPID: 4000 + # http://steamcommunity.com/dev/managegameservers + GLST="" \ + # + # Workshop server download (require API) + WORKSHOP="\${WORKSHOPCOLLECTIONID:-}" \ + # + # Workshop client download (require API) + WORKSHOPDL="" \ + # + # Server config + GAME="garrysmod" \ + TICKRATE="66" \ + MAXPLAYERS="16" \ + GAMEMODE="sandbox" \ + GAMETYPE="0" \ + MAP="gm_flatgrass" \ + MAPGROUP="mg_active" \ + CONFIG="server.cfg" \ + # + # Start parameters + SRCDSPARAMS="\ + -game \${GAME} \ + -tickrate \${TICKRATE} \ + -maxplayers \${MAXPLAYERS} \ + -authkey \${AUTHKEY} \ + +host_workshop_collection \${WORKSHOP} \ + +gamemode \${GAMEMODE} \ + +map \${MAP} \ + +servercfgfile \${CONFIG} \ + \${CUSTOMPARAMETERS} \ + " diff --git a/README.md b/README.md new file mode 100644 index 0000000..bdc34e0 --- /dev/null +++ b/README.md @@ -0,0 +1,143 @@ +# docker-garrysmod + +A Docker image for running a [Garry's Mod](https://gmod.facepunch.com/) dedicated server, based on [hackebein/docker-srcds](https://github.com/Hackebein/docker-srcds). + +This repository is a fork of [Hackebein/docker-garrysmod](https://github.com/Hackebein/docker-garrysmod). + +Garry's Mod is a physics sandbox. There aren't any predefined aims or goals. The game gives you the tools and leaves you to play. + +The image is automatically built and pushed to: + +```text +git.sh-edraft.de/sh-edraft.de/garrysmod +``` + +## Table of Contents + +- [Quick Start](#quick-start) +- [Enabling the Steam API](#enabling-the-steam-api) +- [Public Listing](#public-listing) +- [Workshop Collections](#workshop-collections) +- [Custom Server Configuration](#custom-server-configuration) +- [Example: Trouble in Terrorist Town (TTT)](#example-trouble-in-terrorist-town-ttt) +- [Environment Variables](#environment-variables) +- [Overlay Folder](#overlay-folder) +- [Further Configuration](#further-configuration) + +## Quick Start + +Start a basic sandbox server on the default port (`27015`): + +```bash +docker run -it \ + -p 27015:27015/tcp \ + -p 27015:27015/udp \ + git.sh-edraft.de/sh-edraft.de/garrysmod +``` + +## Enabling the Steam API + +Some features (public server listing, Workshop downloads) require a Steam Web API key. + +```bash +docker run -it \ + -p 27015:27015/tcp \ + -p 27015:27015/udp \ + -e "AUTHKEY=..." \ + git.sh-edraft.de/sh-edraft.de/garrysmod +``` + +Get your `AUTHKEY` from . + +## Public Listing + +If you've set `AUTHKEY`, your server is automatically listed publicly. Alternatively, you can register a Game Server Login Token (GLST) manually: + +```bash +docker run -it \ + -p 27015:27015/tcp \ + -p 27015:27015/udp \ + -e "GLST=..." \ + git.sh-edraft.de/sh-edraft.de/garrysmod +``` + +Get your `GLST` from (App ID: `4000`). + +## Workshop Collections + +Downloading Workshop content requires `AUTHKEY` to be set. + +```bash +docker run -it \ + -p 27015:27015/tcp \ + -p 27015:27015/udp \ + -e "AUTHKEY=..." \ + -e "WORKSHOPCOLLECTIONID=..." \ + git.sh-edraft.de/sh-edraft.de/garrysmod +``` + +## Custom Server Configuration + +Mount your own `server.cfg` into the container: + +```bash +docker run -it \ + -p 27015:27015/tcp \ + -p 27015:27015/udp \ + -v ./server.cfg:/opt/steam/garrysmod/cfg/server.cfg \ + git.sh-edraft.de/sh-edraft.de/garrysmod +``` + +## Example: Trouble in Terrorist Town (TTT) + +```bash +# make sure the server.cfg file exists +touch ./server.cfg + +# start the container +docker run -it \ + -p 27015:27015/tcp \ + -p 27015:27015/udp \ + -e "AUTHKEY=..." \ + -e "GAMEMODE=terrortown" \ + -e "MAP=ttt_minecraft_b5" \ + -e "WORKSHOP=843519054" \ + -e "WORKSHOPDL=843519054" \ + -v ./server.cfg:/opt/steam/garrysmod/cfg/server.cfg \ + -v ./overlay:/opt/overlay \ + git.sh-edraft.de/sh-edraft.de/garrysmod +``` + +This uses the [TTT Workshop Collection](https://steamcommunity.com/sharedfiles/filedetails/?id=843519054), downloaded both server-side (`WORKSHOP`) and client-side (`WORKSHOPDL`). + +## Environment Variables + +| Variable | Description | Default | +| --- | --- | --- | +| `AUTHKEY` | Steam Web API key. Required for the public server list and Workshop downloads. Get one at | _(empty)_ | +| `GLST` | Game Server Login Token for public listing. Get one at (App ID `4000`). Not needed if `AUTHKEY` is set | _(empty)_ | +| `GAME` | Game mod directory | `garrysmod` | +| `GAMEMODE` | Gamemode to run on server start | `sandbox` | +| `MAP` | Map to load on server start | `gm_flatgrass` | +| `MAPGROUP` | Map group / map cycle group | `mg_active` | +| `GAMETYPE` | Game type passed to the server | `0` | +| `MAXPLAYERS` | Maximum number of players | `16` | +| `TICKRATE` | Server tickrate. **Note:** changing this is not recommended | `66` | +| `CONFIG` | Server config file, relative to `cfg/`. **Note:** changing this is not recommended | `server.cfg` | +| `WORKSHOP` | Workshop collection ID to download for the server | _(empty)_ | +| `WORKSHOPDL` | Workshop collection ID for clients to download before joining | _(empty)_ | +| `CUSTOMPARAMETERS` | Additional raw command-line parameters appended to the server start command | _(empty)_ | + +## Overlay Folder + +You can use an overlay folder to add or overwrite files provided by Steam (e.g. addons, configs, maps) without rebuilding the image: + +```bash +-v ./overlay:/opt/overlay +``` + +See [hackebein/docker-srcds: Overlay folder](https://github.com/Hackebein/docker-srcds#overlay-folder) for details. + +## Further Configuration + +This image inherits all environment variables and options from the parent image. See [hackebein/docker-srcds](https://github.com/Hackebein/docker-srcds) for the full list of available configuration options.