Skip to content

Commit

Permalink
feat(tf2-base): add 64-bit image (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
garrappachc authored Jul 24, 2024
1 parent 3a95b76 commit 7a440c6
Show file tree
Hide file tree
Showing 5 changed files with 176 additions and 16 deletions.
70 changes: 61 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ permissions:
packages: write

jobs:
tf2-base:
tf2-base-i386:
runs-on: ubuntu-latest
outputs:
tf2-base-tag: ${{ steps.docker_meta.outputs.version }}
tf2-base-i386-tag: ${{ steps.docker_meta.outputs.version }}

steps:
- name: Checkout
Expand All @@ -32,7 +32,9 @@ jobs:
id: docker_meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/melkortf/tf2-base
images: |
${{ env.REGISTRY }}/melkortf/tf2-base
${{ env.REGISTRY }}/melkortf/tf2-base/i386
tags: |
type=sha,format=long
type=schedule,pattern=nightly
Expand All @@ -54,14 +56,56 @@ jobs:
uses: docker/build-push-action@v6
with:
context: ./packages/tf2-base
file: ./packages/tf2-base/i386.Dockerfile
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
push: true
platforms: linux/amd64

tf2-base-amd64:
runs-on: ubuntu-latest
outputs:
tf2-base-amd64-tag: ${{ steps.docker_meta.outputs.version }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/melkortf/tf2-base/amd64
tags: |
type=sha,format=long
type=schedule,pattern=nightly
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./packages/tf2-base
file: ./packages/tf2-base/amd64.Dockerfile
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
push: true
platforms: linux/amd64

tf2-sourcemod:
runs-on: ubuntu-latest
needs: tf2-base
needs: tf2-base-i386
outputs:
tf2-sourcemod-tag: ${{ steps.docker_meta.outputs.version }}

Expand All @@ -73,7 +117,9 @@ jobs:
id: docker_meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/melkortf/tf2-sourcemod
images: |
${{ env.REGISTRY }}/melkortf/tf2-sourcemod
${{ env.REGISTRY }}/melkortf/tf2-sourcemod/i386
tags: |
type=sha,format=long
type=schedule,pattern=nightly
Expand All @@ -96,7 +142,7 @@ jobs:
with:
context: ./packages/tf2-sourcemod
build-args: |
TF2_BASE_TAG=${{ needs.tf2-base.outputs.tf2-base-tag }}
TF2_BASE_TAG=${{ needs.tf2-base-i386.outputs.tf2-base-i386-tag }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
push: true
Expand All @@ -114,7 +160,9 @@ jobs:
id: docker_meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/melkortf/tf2-mge
images: |
${{ env.REGISTRY }}/melkortf/tf2-mge
${{ env.REGISTRY }}/melkortf/tf2-mge/i386
tags: |
type=sha,format=long
type=schedule,pattern=nightly
Expand Down Expand Up @@ -155,7 +203,9 @@ jobs:
id: docker_meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/melkortf/tf2-competitive
images: |
${{ env.REGISTRY }}/melkortf/tf2-competitive
${{ env.REGISTRY }}/melkortf/tf2-competitive/i386
tags: |
type=sha,format=long
type=schedule,pattern=nightly
Expand Down Expand Up @@ -196,7 +246,9 @@ jobs:
id: docker_meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/melkortf/tf2-dm
images: |
${{ env.REGISTRY }}/melkortf/tf2-dm
${{ env.REGISTRY }}/melkortf/tf2-dm/i386
tags: |
type=sha,format=long
type=schedule,pattern=nightly
Expand Down
32 changes: 26 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,16 @@ rcon_password "123456"

There are many more configuration options, you will find them all below.

## tf2-base
#### tf2-base

```
$ docker pull ghcr.io/melkortf/tf2-base
```

| 32-bit | 64-bit |
| ------------------------------------------------------------- | --------------------------------- |
| `ghcr.io/melkortf/tf2-base`, `ghcr.io/melkortf/tf2-base/i386` | `ghcr.io/melkortf/tf2-base/amd64` |

The base image for all other images; pure TF2 server, without any add-ons and plugins.

| Environment variable | Default value | Used in | Description |
Expand All @@ -75,20 +79,28 @@ The base image for all other images; pure TF2 server, without any add-ons and pl
| STV_PASSWORD | | `tv_password "${STV_PASSWORD}"` | SourceTV password. |
| DOWNLOAD_URL | https://fastdl.serveme.tf/ | `sv_downloadurl "${DOWNLOAD_URL}"` | Download URL for the [FastDL](https://developer.valvesoftware.com/wiki/Sv_downloadurl). |

## tf2-sourcemod
#### tf2-sourcemod

```
$ docker pull ghcr.io/melkortf/tf2-sourcemod
```

| 32-bit | 64-bit |
| ----------------------------------------------------------------------- | ------ |
| `ghcr.io/melkortf/tf2-sourcemod`, `ghcr.io/melkortf/tf2-sourcemod/i386` | - |

TF2 server with [Metamod:Source](https://www.sourcemm.net/) and [SourceMod](https://www.sourcemod.net/) installed.

## tf2-competitive
#### tf2-competitive

```
$ docker pull ghcr.io/melkortf/tf2-competitive
```

| 32-bit | 64-bit |
| --------------------------------------------------------------------------- | ------ |
| `ghcr.io/melkortf/tf2-competitive`, `ghcr.io/melkortf/tf2-competitive/i386` | - |

TF2 server configured to be used in competitive matches. The following plugins, add-ons and configs are installed:

- [TF2 competitive fixes](https://github.com/ldesgoui/tf2-comp-fixes)
Expand All @@ -114,23 +126,31 @@ TF2 server configured to be used in competitive matches. The following plugins,
| DEMOS_TF_APIKEY | | `sm_demostf_apikey ${DEMOS_TF_APIKEY}` | The API key used to upload the demo to [demos.tf](https://demos.tf/). |
| LOGS_TF_APIKEY | | `logstf_apikey ${LOGS_TF_APIKEY}` | The API key used to upload logs to logs.tf. |

## tf2-dm
#### tf2-dm

```
$ docker pull ghcr.io/melkortf/tf2-dm
```

| 32-bit | 64-bit |
| --------------------------------------------------------- | ------ |
| `ghcr.io/melkortf/tf2-dm`, `ghcr.io/melkortf/tf2-dm/i386` | - |

TF2 dedicated server for DeathMatch gameplay.

## tf2-mge
#### tf2-mge

```
$ docker pull ghcr.io/melkortf/tf2-mge
```

| 32-bit | 64-bit |
| ----------------------------------------------------------- | ------ |
| `ghcr.io/melkortf/tf2-mge`, `ghcr.io/melkortf/tf2-mge/i386` | - |

TF2 dedicated server for MGE 1v1 training mod.

## Maps
### Maps

In order to make the image as small as possible, the only map shipped with the image is _cp_badlands_. This has also the advantage of letting you maintain only one directory
with all the maps and share it between all the containers. Just mount `/home/tf2/server/tf/maps` to your local directory that contains all the maps you need:
Expand Down
87 changes: 87 additions & 0 deletions packages/tf2-base/amd64.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
FROM ubuntu:20.04 AS rcon-build
WORKDIR /build

RUN export DEBIAN_FRONTEND=noninteractive \
&& export TZ=Etc/UTC \
&& apt-get -y update \
&& apt-get install -y build-essential git cmake check pkg-config libglib2.0-dev libbsd-dev \
&& rm -rf /var/lib/apt/lists/* \
&& git clone https://github.com/n0la/rcon.git \
&& mkdir rcon/build \
&& cd rcon/build \
&& cmake .. \
&& make


FROM steamcmd/steamcmd:ubuntu-20
LABEL maintainer="[email protected]"

RUN export DEBIAN_FRONTEND=noninteractive \
&& export TZ=Etc/UTC \
&& apt-get -y update \
&& apt-get install -y software-properties-common \
&& add-apt-repository multiverse \
&& apt-get -y update \
&& apt-get install -y --no-install-recommends --no-install-suggests \
libncurses5 \
libbz2-1.0 \
libcurl3-gnutls \
wget \
unzip \
gettext-base \
libbsd0 \
&& rm -rf /var/lib/apt/lists/*

ARG USER=tf2
ARG HOME=/home/$USER
ARG SERVER_DIR=$HOME/server
ARG APP_ID=232250

ENV USER=$USER
ENV HOME=$HOME
ENV SERVER_DIR=$SERVER_DIR
ENV APP_ID=$APP_ID
ENV SRCDS_EXEC=srcds_run_64

RUN useradd --home-dir $HOME --create-home --shell /bin/bash $USER
USER $USER
WORKDIR $HOME

COPY maps_to_keep tf2.txt.template $HOME/
RUN envsubst < $HOME/tf2.txt.template > $HOME/tf2.txt \
&& steamcmd +runscript $HOME/tf2.txt \
&& find $SERVER_DIR/tf/maps -type f | grep -v "$(cat maps_to_keep)" | xargs rm -rf \
&& rm maps_to_keep \
&& mkdir $HOME/.steam/sdk64 \
&& ln -s $HOME/.steam/steamcmd/linux64/steamclient.so $HOME/.steam/sdk64/

COPY server.cfg.template ${SERVER_DIR}/tf/cfg/server.cfg.template
COPY --from=rcon-build /build/rcon/build/rcon ${SERVER_DIR}/rcon

ENV IP=0.0.0.0
ENV PORT=27015
ENV CLIENT_PORT=27016
ENV STEAM_PORT=27018
ENV STV_PORT=27020
ENV SERVER_TOKEN=""

ENV RCON_PASSWORD="123456"
ENV SERVER_HOSTNAME="A Team Fortress 2 server"
ENV SERVER_PASSWORD=
ENV STV_NAME="Source TV"
ENV STV_TITLE="A Team Fortress 2 server Source TV"
ENV STV_PASSWORD=
ENV DOWNLOAD_URL="https://fastdl.serveme.tf/"

WORKDIR $SERVER_DIR
COPY entrypoint.sh .
COPY healthcheck.sh .

ENTRYPOINT ["./entrypoint.sh"]
CMD ["+sv_pure", "1", "+map", "cp_badlands", "+maxplayers", "24"]

EXPOSE $PORT/tcp
EXPOSE $PORT/udp
EXPOSE $STV_PORT/udp

HEALTHCHECK --interval=30s --timeout=30s --start-period=20s --retries=3 CMD [ "./healthcheck.sh" ]
2 changes: 1 addition & 1 deletion packages/tf2-base/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ trap 'quit' SIGTERM

auto_envsubst

faketty $SERVER_DIR/srcds_run \
faketty $SERVER_DIR/$SRCDS_EXEC \
-game tf \
-secured \
-steam_dir ${HOME}/.steam/steamcmd \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ ARG USER=tf2
ARG HOME=/home/$USER
ARG SERVER_DIR=$HOME/server
ARG APP_ID=232250
ENV SRCDS_EXEC=srcds_run

ENV USER=$USER
ENV HOME=$HOME
Expand Down

0 comments on commit 7a440c6

Please sign in to comment.