From a2fe226e839f159018eabfa0627888ac2f677f46 Mon Sep 17 00:00:00 2001 From: James Ives Date: Thu, 3 Oct 2024 13:12:58 -0400 Subject: [PATCH] =?UTF-8?q?build:=20=E2=9A=99=EF=B8=8F=20Bump=20to=20Ubunt?= =?UTF-8?q?u=2024,=20improve=20unit=20test=20coverage=20(#50)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #minor Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JamesIves --- .github/dependabot.yml | 5 ++ .github/workflows/beta.yml | 101 +++++++++++++++++++++++++++++++-- .github/workflows/publish.yml | 100 +++++++++++++++++++++++++++++--- .github/workflows/validate.yml | 77 ++++++++++++++++++++++++- README.md | 1 - config/README.md | 9 +-- container/Dockerfile | 19 +++++-- container/config/README.md | 26 +-------- container/mods/README.md | 37 +----------- docker-compose.yml | 2 +- mods/README.md | 4 +- 11 files changed, 293 insertions(+), 88 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5ace460..34b0dc0 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,3 +4,8 @@ updates: directory: "/" schedule: interval: "weekly" + + - package-ecosystem: "docker" + directory: "/container" + schedule: + interval: "weekly" diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 429ec74..21d5546 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -1,10 +1,12 @@ name: Publish Beta Docker Images πŸ‹ πŸ“¦ +concurrency: ci-${{ github.ref }} on: push: branches: - beta jobs: build: + name: Build Beta Docker Image 🐳 runs-on: ubuntu-latest permissions: packages: write @@ -56,7 +58,7 @@ jobs: GAME=${GAME%-legacy} echo "GAME=$GAME" >> $GITHUB_ENV - - name: Replace fallback value in Dockerfile and entrypoint.sh + - name: Replace fallback value in Dockerfile and entrypoint.sh πŸ“ working-directory: ./container run: | sed -i "s/\${GAME:-valve}/\${GAME:-${{ env.GAME }}}/g" Dockerfile @@ -66,6 +68,84 @@ jobs: if: contains(matrix.game, 'legacy') run: echo "FLAG=-beta steam_legacy" >> $GITHUB_ENV + - name: Build Docker Image 🐳 + uses: docker/build-push-action@v6 + env: + GAME: ${{ env.GAME }} + FLAG: ${{ env.FLAG }} + VERSION: beta + IMAGE: jives/hlds:${{ matrix.game }}-beta + with: + context: ./container + push: false + load: true + tags: jives/hlds:${{ matrix.game }}-beta + build-args: | + GAME=${{ env.GAME }} + FLAG=${{ env.FLAG }} + IMAGE=jives/hlds:${{ matrix.game }}-beta + VERSION=beta + + - name: Get Docker Image ID πŸ†” + id: get_image_id + run: echo "image_id=$(docker images -q | head -n 1)" >> $GITHUB_ENV + + - name: Add Custom Mod Content πŸ“‚ + run: | + mkdir -p ./mods/decay + touch ./mods/decay/plugin.ini + + - name: Add Configuration πŸ“‚ + run: | + mkdir -p ./config + mkdir -p ./config/maps + touch ./config/test.cfg + touch ./config/maps/crazytank.bsp + + - name: Run Docker Container 🐳 + run: | + docker run -d -ti \ + --name hlds \ + -v "./config:/temp/config" \ + -v "./mods:/temp/mods" \ + -p 27015:27015/udp \ + -p 27015:27015 \ + -p 26900:26900/udp \ + -e GAME=${GAME} \ + ${{ env.image_id }} \ + "+log on +rcon_password changeme +maxplayers 12" + sleep 5 + + - name: Validate Directory Mappings πŸ“‚ + run: | + # Check if plugin.ini exists in the decay directory + if [ "$(docker exec hlds ls /opt/steam/hlds/decay | grep -c 'plugin.ini')" -eq 0 ]; then + echo "plugin.ini file is missing in the decay directory!" + exit 1 + fi + + # Check if test.cfg exists in the game directory + if [ "$(docker exec hlds ls /opt/steam/hlds/${{ env.GAME }} | grep -c 'test.cfg')" -eq 0 ]; then + echo "test.cfg file is missing in the ${{ env.GAME }} directory!" + exit 1 + fi + + # Check if crazytank.bsp exists in the maps directory + if [ "$(docker exec hlds ls /opt/steam/hlds/${{ env.GAME }}/maps | grep -c 'crazytank.bsp')" -eq 0 ]; then + echo "crazytank.bsp file is missing in the maps directory!" + exit 1 + fi + + echo "Volume mappings work as expectected!" + + - name: Validate Game Data Is Available πŸ“‚ + run: | + GAME_NAME=$(echo "${{ env.GAME }}" | sed 's/-legacy//') + if [ "$(docker exec hlds ls /opt/steam/hlds | grep -c "$GAME_NAME")" -eq 0 ]; then + echo "$GAME_NAME directory is missing!" + exit 1 + fi + - name: Build and Push Docker Image to DockerHub 🐳 uses: docker/build-push-action@v6 env: @@ -83,9 +163,11 @@ jobs: IMAGE=jives/hlds:${{ matrix.game }}-beta VERSION=beta - - name: Set repo owner to lowercase + - name: Set repo owner to lowercase πŸ“ id: repo_owner - run: echo "::set-output name=repo_owner::$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}')" + run: | + REPO_OWNER=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}') + echo "repo_owner=$REPO_OWNER" >> $GITHUB_ENV - name: Build and Push Docker Image to GitHub Container Registry 🐳 uses: docker/build-push-action@v6 @@ -93,13 +175,20 @@ jobs: GAME: ${{ env.GAME }} FLAG: ${{ env.FLAG }} VERSION: beta - IMAGE: ghcr.io/${{ steps.repo_owner.outputs.repo_owner }}/hlds:${{ matrix.game }}-beta + IMAGE: ghcr.io/${{ env.repo_owner }}/hlds:${{ matrix.game }}-beta with: context: ./container push: true - tags: ghcr.io/${{ steps.repo_owner.outputs.repo_owner }}/hlds:${{ matrix.game }}-beta + tags: ghcr.io/${{ env.repo_owner }}/hlds:${{ matrix.game }}-beta build-args: | GAME=${{ env.GAME }} FLAG=${{ env.FLAG }} VERSION=beta - IMAGE=ghcr.io/${{ steps.repo_owner.outputs.repo_owner }}/hlds:${{ matrix.game }}-beta + IMAGE=ghcr.io/${{ env.repo_owner }}/hlds:${{ matrix.game }}-beta + + - name: Cleanup 🧹 + if: always() + run: | + docker stop hlds + docker rm hlds + docker system prune --all --force diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 86fc987..ddd0dbd 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,10 +1,12 @@ name: Publish Docker Images πŸ‹ πŸ“¦ +concurrency: ci-${{ github.ref }} on: push: branches: - main jobs: version: + name: Bump Version 🏷️ runs-on: ubuntu-latest outputs: version: ${{ steps.create_tag.outputs.new_tag }} @@ -23,6 +25,7 @@ jobs: DRY_RUN: true build: + name: Build Docker Image 🐳 needs: version runs-on: ubuntu-latest permissions: @@ -75,7 +78,7 @@ jobs: GAME=${GAME%-legacy} echo "GAME=$GAME" >> $GITHUB_ENV - - name: Replace fallback value in Dockerfile and entrypoint.sh + - name: Replace fallback value in Dockerfile and entrypoint.sh πŸ“ working-directory: ./container run: | sed -i "s/\${GAME:-valve}/\${GAME:-${{ env.GAME }}}/g" Dockerfile @@ -85,6 +88,86 @@ jobs: if: contains(matrix.game, 'legacy') run: echo "FLAG=-beta steam_legacy" >> $GITHUB_ENV + - name: Build Docker Image 🐳 + uses: docker/build-push-action@v6 + env: + GAME: ${{ env.GAME }} + FLAG: ${{ env.FLAG }} + VERSION: ${{ needs.version.outputs.version }} + IMAGE: jives/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }} + with: + context: ./container + push: false + load: true + tags: | + jives/hlds:${{ matrix.game }} + jives/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }} + build-args: | + GAME=${{ env.GAME}} + FLAG=${{ env.FLAG }} + VERSION=${{ needs.version.outputs.version }} + IMAGE=jives/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }} + + - name: Get Docker Image ID πŸ†” + id: get_image_id + run: echo "image_id=$(docker images -q | head -n 1)" >> $GITHUB_ENV + + - name: Add Custom Mod Content πŸ“‚ + run: | + mkdir -p ./mods/decay + touch ./mods/decay/plugin.ini + + - name: Add Configuration πŸ“‚ + run: | + mkdir -p ./config + mkdir -p ./config/maps + touch ./config/test.cfg + touch ./config/maps/crazytank.bsp + + - name: Run Docker Container 🐳 + run: | + docker run -d -ti \ + --name hlds \ + -v "./config:/temp/config" \ + -v "./mods:/temp/mods" \ + -p 27015:27015/udp \ + -p 27015:27015 \ + -p 26900:26900/udp \ + -e GAME=${GAME} \ + ${{ env.image_id }} \ + "+log on +rcon_password changeme +maxplayers 12" + sleep 5 + + - name: Validate Directory Mappings πŸ“‚ + run: | + # Check if plugin.ini exists in the decay directory + if [ "$(docker exec hlds ls /opt/steam/hlds/decay | grep -c 'plugin.ini')" -eq 0 ]; then + echo "plugin.ini file is missing in the decay directory!" + exit 1 + fi + + # Check if test.cfg exists in the game directory + if [ "$(docker exec hlds ls /opt/steam/hlds/${{ env.GAME }} | grep -c 'test.cfg')" -eq 0 ]; then + echo "test.cfg file is missing in the ${{ env.GAME }} directory!" + exit 1 + fi + + # Check if crazytank.bsp exists in the maps directory + if [ "$(docker exec hlds ls /opt/steam/hlds/${{ env.GAME }}/maps | grep -c 'crazytank.bsp')" -eq 0 ]; then + echo "crazytank.bsp file is missing in the maps directory!" + exit 1 + fi + + echo "Volume mappings work as expectected!" + + - name: Validate Game Data Is Available πŸ“‚ + run: | + GAME_NAME=$(echo "${{ env.GAME }}" | sed 's/-legacy//') + if [ "$(docker exec hlds ls /opt/steam/hlds | grep -c "$GAME_NAME")" -eq 0 ]; then + echo "$GAME_NAME directory is missing!" + exit 1 + fi + - name: Build and Push Docker Image to DockerHub 🐳 uses: docker/build-push-action@v6 env: @@ -104,9 +187,11 @@ jobs: VERSION=${{ needs.version.outputs.version }} IMAGE=jives/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }} - - name: Set repo owner to lowercase + - name: Set repo owner to lowercase πŸ“ id: repo_owner - run: echo "::set-output name=repo_owner::$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}')" + run: | + REPO_OWNER=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}') + echo "repo_owner=$REPO_OWNER" >> $GITHUB_ENV - name: Build and Push Docker Image to GitHub Container Registry 🐳 uses: docker/build-push-action@v6 @@ -114,20 +199,21 @@ jobs: GAME: ${{ matrix.game }} FLAG: ${{ env.FLAG }} VERSION: ${{ needs.version.outputs.version }} - IMAGE: ghcr.io/${{ steps.repo_owner.outputs.repo_owner }}/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }} + IMAGE: ghcr.io/${{ env.repo_owner }}/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }} with: context: ./container push: true tags: | - ghcr.io/${{ steps.repo_owner.outputs.repo_owner }}/hlds:${{ matrix.game }} - ghcr.io/${{ steps.repo_owner.outputs.repo_owner }}/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }} + ghcr.io/${{ env.repo_owner }}/hlds:${{ matrix.game }} + ghcr.io/${{ env.repo_owner }}/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }} build-args: | GAME=${{ env.GAME }} FLAG=${{ env.FLAG }} VERSION=${{ needs.version.outputs.version }} - IMAGE=ghcr.io/${{ steps.repo_owner.outputs.repo_owner }}/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }} + IMAGE=ghcr.io/${{ env.repo_owner }}/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }} publish: + name: Publish GitHub Release πŸš€ needs: build runs-on: ubuntu-latest permissions: diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 27906a6..ee8d2f1 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -7,8 +7,11 @@ on: workflow_dispatch: jobs: build: + name: Build and Validate 🏁 runs-on: ubuntu-latest - + concurrency: ci-${{ github.ref }} + env: + GAME: cstrike steps: - name: Checkout πŸ›ŽοΈ uses: actions/checkout@v4 @@ -19,7 +22,75 @@ jobs: - name: Build Docker Image 🐳 uses: docker/build-push-action@v6 env: - GAME: cstrike + GAME: ${{ env.GAME }} with: context: ./container - build-args: GAME=cstrike + build-args: | + GAME=${{ env.GAME }} + load: true + + - name: Get Docker Image ID πŸ†” + id: get_image_id + run: echo "image_id=$(docker images -q | head -n 1)" >> $GITHUB_ENV + + - name: Add Custom Mod Content πŸ“‚ + run: | + mkdir -p ./mods/decay + touch ./mods/decay/plugin.ini + + - name: Add Configuration πŸ“‚ + run: | + mkdir -p ./config + mkdir -p ./config/maps + touch ./config/test.cfg + touch ./config/maps/crazytank.bsp + + - name: Run Docker Container 🐳 + run: | + docker run -d -ti \ + --name hlds \ + -v "./config:/temp/config" \ + -v "./mods:/temp/mods" \ + -p 27015:27015/udp \ + -p 27015:27015 \ + -p 26900:26900/udp \ + -e GAME=${GAME} \ + ${{ env.image_id }} \ + "+log on +rcon_password changeme +maxplayers 12 +map cs_italy" + + - name: Validate Directory Mappings πŸ“‚ + run: | + # Check if plugin.ini exists in the decay directory + if [ "$(docker exec hlds ls /opt/steam/hlds/decay | grep -c 'plugin.ini')" -eq 0 ]; then + echo "plugin.ini file is missing in the decay directory!" + exit 1 + fi + + # Check if test.cfg exists in the game directory + if [ "$(docker exec hlds ls /opt/steam/hlds/${{ env.GAME }} | grep -c 'test.cfg')" -eq 0 ]; then + echo "test.cfg file is missing in the ${{ env.GAME }} directory!" + exit 1 + fi + + # Check if crazytank.bsp exists in the maps directory + if [ "$(docker exec hlds ls /opt/steam/hlds/${{ env.GAME }}/maps | grep -c 'crazytank.bsp')" -eq 0 ]; then + echo "crazytank.bsp file is missing in the maps directory!" + exit 1 + fi + + echo "Volume mappings work as expectected!" + + - name: Validate Game Data Is Available πŸ“‚ + run: | + GAME_NAME=$(echo "${{ env.GAME }}" | sed 's/-legacy//') + if [ "$(docker exec hlds ls /opt/steam/hlds | grep -c "$GAME_NAME")" -eq 0 ]; then + echo "$GAME_NAME directory is missing!" + exit 1 + fi + + - name: Cleanup 🧹 + if: always() + run: | + docker stop hlds + docker rm hlds + docker system prune --all --force diff --git a/README.md b/README.md index e644c8f..c2b2496 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,6 @@ docker run -d -ti \ -p 27015:27015/udp \ -p 27015:27015 \ -p 26900:26900/udp \ - -e GAME=${GAME} \ jives/hlds:valve \ "+log on +rcon_password changeme +maxplayers 12 +map crossfire" # πŸ“£ Modify your server startup commands here. You can specify the image with the desired game you want the server to run in the line above. ``` diff --git a/config/README.md b/config/README.md index 5aeb626..0f986e7 100644 --- a/config/README.md +++ b/config/README.md @@ -12,9 +12,10 @@ If you wish to add server configurations, such as add-ons, plugins, map rotation | β”‚ | β”œβ”€β”€ πŸ“œ crazytank.bsp ``` - The `config` directory is volume-mapped within the directory for the game for which you're starting the container. For example, if you're starting a container for `cstrike`, you can add things like `mapcycle.txt` or `motd.txt` here, and it would appear within the corresponding `cstrike` directory within the container. +The config directory should be volume mapped to `/temp/config`, for example `./config:/temp/config"`, once the container starts it will re-write the files into the correct place so the Half-Life Dedicated Server client recognizes them. + > [!NOTE] > The startup examples posted in the project README already have this directory volume mapped accordingly. If you've strayed from the suggested setup, [please refer back to it to get started](../../README.md). @@ -30,8 +31,8 @@ The `config` directory is volume-mapped within the directory for the game for wh > [!TIP] > You can use this method to install server plugins such as AMX Mod, Meta Mod, etc., as the directory can handle nested folders too; for example, these can be placed in `config/addons/amxmodx` etc. -1. Create a folder called `config` alongside where you would typically start the server process. If you've cloned this project locally, you'd place your files alongside this README file. -2. Add your config files to the directory. -3. Start the image as you usually would, either with `docker run` or `docker compose up`. +1. Create a folder called `config` alongside where you would typically start the server process. If you've cloned this project locally, you'd place your files alongside this README file. If you're building a custom image, place them alongside the equivalent README in the `container` directory. +1. Add your config files to the directory. +1. Start the image as you usually would, either with `docker run` or `docker compose up`. For a list of all the available server configuration types, [refer to the Valve Developer Wiki](https://developer.valvesoftware.com/wiki/Main_Page). diff --git a/container/Dockerfile b/container/Dockerfile index 3cc9d6f..1892842 100644 --- a/container/Dockerfile +++ b/container/Dockerfile @@ -1,13 +1,13 @@ -FROM ubuntu:18.04 +FROM ubuntu:24.04 # Sets an environment variable for the game to install. # Supported games: valve, cstrike, czero, dod, dmc, gearbox, ricochet, tfc -# Default is valve. This get replaced when building the image with --build-arg GAME= +# Default is valve. This gets replaced when building the image with --build-arg GAME= ARG GAME=valve ENV GAME ${GAME} # Sets an environment variable for any additional flag that should be passed to the SteamCMD installer. -# Default is an empty string. This get replaced when building the image with --build-arg FLAG= +# Default is an empty string. This gets replaced when building the image with --build-arg FLAG= # For example, you may set this to "-beta steam_legacy". ARG FLAG ENV FLAG ${FLAG} @@ -31,27 +31,36 @@ LABEL org.opencontainers.image.documentation="https://github.com/jamesives/hlds- LABEL org.opencontainers.image.source="https://github.com/jamesives/hlds-docker" LABEL org.opencontainers.image.version="${VERSION}" +# Installs the necessary dependencies for the SteamCMD installer. RUN dpkg --add-architecture i386 && \ apt-get update && \ apt-get install -y --no-install-recommends curl rsync file libc6:i386 lib32stdc++6 ca-certificates && \ rm -rf /var/lib/apt/lists/* +# Creates a new user and group for the SteamCMD installer. RUN groupadd -r steam && \ useradd -r -g steam -m -d /opt/steam steam +# Creates the necessary directories for the Half-Life Dedicated Server, including the configuration and mods directories. RUN mkdir /config RUN mkdir /mods +RUN mkdir /temp +RUN mkdir /temp/config +RUN mkdir /temp/mods +# Sets the user to the steam user. USER steam WORKDIR /opt/steam +# Copies the hlds.txt file to the container. COPY ./hlds.txt /opt/steam # Replaces $GAME with the requested mod to install in hlds.txt. -# Additionally replaces $FLAG with any additional FLAG that should be passed to the SteamCMD installer to support betas. +# Additionally replaces $FLAG with any additional flags that should be passed to the SteamCMD installer to support betas. RUN sed -i "s/\$GAME/${GAME}/g" /opt/steam/hlds.txt RUN sed -i "s/\$FLAG/${FLAG}/g" /opt/steam/hlds.txt +# Downloads and extracts the SteamCMD installer. RUN curl -v -sL media.steampowered.com/client/installer/steamcmd_linux.tar.gz | tar xzvf - && \ file /opt/steam/linux32/steamcmd && \ ./steamcmd.sh +runscript /opt/steam/hlds.txt @@ -64,10 +73,12 @@ RUN mkdir -p $HOME/.steam \ WORKDIR /opt/steam/hlds +# Copies the entrypoint script to the container and sets the necessary permissions. COPY --chown=steam:steam ./entrypoint.sh ./entrypoint.sh COPY --chown=steam:steam config $GAME COPY --chown=steam:steam mods . +# Sets the entrypoint script as executable. RUN chmod +x ./entrypoint.sh diff --git a/container/config/README.md b/container/config/README.md index bf0c3bc..911d431 100644 --- a/container/config/README.md +++ b/container/config/README.md @@ -1,27 +1,3 @@ # Configs and Plugins -> [!WARNING] -> Configs added here will be included in the distributed image. This means users must override them on startup when using a distributed version. - -If you wish to add server configurations, such as add-ons, plugins, map rotations, etc, you can add them to theΒ `config` directory. The `config` directory is volume-mapped within the directory for the game for which you're starting the container. For example, if you're starting a container for `cstrike`, you can add things like `mapcycle.txt` or `motd.txt` here, and it would appear within the corresponding `cstrike` directory on the server. - -> [!NOTE] -> The startup examples posted in the project README already have this directory volume mapped accordingly. If you've strayed from the suggested setup, [please refer back to it to get started](../../README.md). - -``` -β”œβ”€β”€ hlds -β”‚ β”œβ”€β”€ cstrike -β”‚ β”‚ β”œβ”€β”€ models -β”‚ β”‚ β”œβ”€β”€ maps -β”‚ β”‚ β”œβ”€β”€ mapcycle.txt -β”‚ β”‚ β”œβ”€β”€ motd.txt -``` - -> [!TIP] -> You can use this method to install server plugins such as AMX Mod, Meta Mod, etc., as the directory can handle nested folders too; for example, these can be placed in `config/addons/amxmodx` etc. - -1. Create a folder called `config` alongside where you would typically start the server process. If you've cloned this project locally, you'd place it alongside this README file. -2. Add your config files to the directory. -3. Start the image as you usually would, either with `docker run` or `docker compose up`. - -For a list of all the available server configuration types, [refer to the Valve Developer Wiki](https://developer.valvesoftware.com/wiki/Main_Page). +[For setup instructions, please refer to the following README](../../config/README.md). diff --git a/container/mods/README.md b/container/mods/README.md index 237c201..ef72598 100644 --- a/container/mods/README.md +++ b/container/mods/README.md @@ -1,38 +1,3 @@ # Custom Mods -> [!WARNING] -> Mods added here will be included in the distributed image. This means users must override them on startup when using a distributed version. - -If you want to run a custom mod, you can do so with the `mods` directory. The `mods` directory is volume mapped within the root directory of the Half-Life Dedicated Server client on startup. For example, if you wanted to add a mod named `decay`, you'd place it as a subfolder here, i.e., `mods/decay`. Once the container starts, it would be placed in the following directory. - -``` -β”œβ”€β”€ hlds -β”‚ β”œβ”€β”€ cstrike -β”‚ β”‚ β”œβ”€β”€ models -β”‚ β”‚ β”œβ”€β”€ maps -β”‚ β”‚ β”œβ”€β”€ autoexec.cfg -β”‚ β”œβ”€β”€ valve -β”‚ β”‚ β”œβ”€β”€ models -β”‚ β”‚ β”œβ”€β”€ maps -β”‚ β”‚ β”œβ”€β”€ autoexec.cfg -β”‚ β”œβ”€β”€ decay -β”‚ β”‚ β”œβ”€β”€ models -β”‚ β”‚ β”œβ”€β”€ maps -β”‚ β”‚ β”œβ”€β”€ autoexec.cfg -``` - -> [!NOTE] -> The startup examples posted in the project README already have this directory volume mapped accordingly. If you've strayed from the suggested setup, [please refer back to it to get started](../README.md). - -1. Create a folder called `mods` alongside where you would normally start the server process. If you've cloned this project locally, you'd place it alongside this README file. -2. Add your mod files as a sub-directory of `mods`. For example if the mod name is `decay`, you'd place it in `mods/decay`. -3. Define the `GAME` environment variable for your mod name. The dedicated server client will use this to ensure that it starts a server for the correct mod, which corresponds with the directory name that was just created. - -```bash -export GAME=decay -``` - -4. Start the image as you usually would, either with `docker run` or `docker compose up`. Most Half-Life mods require specific startup arguments. For more details, refer to the [Valve Developer Wiki](https://developer.valvesoftware.com/wiki/Half-Life_Dedicated_Server) and the instructions for the mod you're trying to run. - -> [!TIP] -> When using a pre-built image, you'll likely want to use the `valve` base image (`jives/hlds:valve`). +[For setup instructions, please refer to the following README](../../mods/README.md). diff --git a/docker-compose.yml b/docker-compose.yml index b8b1bdb..1568921 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,7 +23,7 @@ services: - "26900:2690/udp" environment: - GAME=${GAME} - # πŸ“£ Modify your server startup commands here, you can add more FLAG as needed (see: https://developer.valvesoftware.com/wiki/Half-Life_Dedicated_Server), + # πŸ“£ Modify your server startup commands here, you can add more flags as needed (see: https://developer.valvesoftware.com/wiki/Half-Life_Dedicated_Server), # πŸ“£ Remember: Stating map is based on the game, and will likely be different between images. # πŸ“£ You should also modify the rcon_password value so you can use server admin commands. command: +log on +rcon_password "changeme" +maxplayers 12 +map crossfire diff --git a/mods/README.md b/mods/README.md index f3043bf..0fcb9b0 100644 --- a/mods/README.md +++ b/mods/README.md @@ -15,6 +15,8 @@ If you want to run a custom mod, you can do so with the `mods` directory. Your d The `mods` directory is volume mapped within the root directory of the Half-Life Dedicated Server client on startup. For example, if you wanted to add a mod named `decay`, you'd place it as a subfolder here, i.e., `mods/decay`. Once the container starts, it would be placed in the following directory within the container. +The mods directory should be volume mapped to `/temp/mods`, for example `./mods:/temp/mods"`, once the container starts it will re-write the files into the correct place so the Half-Life Dedicated Server client recognizes them. + ``` β”œβ”€β”€ πŸ“¦ hlds β”‚ β”œβ”€β”€ πŸ“‚ cstrike @@ -38,7 +40,7 @@ The `mods` directory is volume mapped within the root directory of the Half-Life > [!NOTE] > The startup examples posted in the project README already have this directory volume mapped accordingly. If you've strayed from the suggested setup, [please refer back to it to get started](../README.md). -1. Create a folder called `mods` alongside where you would normally start the server process. If you've cloned this project locally, you'd place your files longside this README file. +1. Create a folder called `mods` alongside where you would normally start the server process. If you've cloned this project locally, you'd place your files longside this README file. If you're building a custom image, place them alongside the equivalent README in the `container` directory. 2. Add your mod files as a sub-directory of `mods`. For example if the mod name is `decay`, you'd place it in `mods/decay`. 3. Define the `GAME` environment variable for your mod name. The dedicated server client will use this to ensure that it starts a server for the correct mod, which corresponds with the directory name that was just created.