Skip to content

Commit

Permalink
Merge pull request #36 from kir68k/srcds-64bit
Browse files Browse the repository at this point in the history
Added 64-bit and 32-bit tags
  • Loading branch information
CM2Walki authored May 1, 2024
2 parents 8f4176d + 2c6244c commit 70bfa4a
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 6 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Or if you want to explicitly specify a server config file, use the `SRCDS_CFG` e
If you want to learn more about configuring a TF2 server check this [documentation](https://wiki.teamfortress.com/wiki/Dedicated_server_configuration).

# Image Variants:
The `tf2` images come in three flavors, each designed for a specific use case.
The `tf2` images come in three flavors, each designed for a specific use case, with a 64-bit version if needed.

## `tf2:latest`
This is the defacto image. If you are unsure about what your needs are, you probably want to use this one. It is a bare-minimum TF2 dedicated server containing no 3rd party plugins.<br/>
Expand All @@ -85,5 +85,10 @@ This is a specialized image. It contains the plugin environment [Metamod:Source]
## `tf2:sourcemod`
This is another specialized image. It contains both [Metamod:Source](https://www.sourcemm.net) and the popular server plugin [SourceMod](https://www.sourcemod.net) which can be found in the addons directory. [SourceMod](https://www.sourcemod.net) supports a wide variety of additional plugins that can be found [here](https://www.sourcemod.net/plugins.php).

## `tf2:[variant]-x64`
A 64-bit version of all three variants, i.e. `latest-x64`, `metamod-x64`, and `sourcemod-x64`. This will run a fully 64-bit server, `srcds_linux64`, with a 64-bit version of Metamod or SourceMod.
### Which to use?
If you require SourceMod and aren't fully sure whether your plugins work on 64-bit servers, it's better to use the normal 32-bit variant, `tf2:sourcemod`. If you want to run a server without any plugins, `tf2:latest-x64` is preferred.

# Contributors
[![Contributors Display](https://badges.pufler.dev/contributors/CM2Walki/tf2?size=50&padding=5&bots=false)](https://github.com/CM2Walki/tf2/graphs/contributors)
15 changes: 10 additions & 5 deletions bookworm/hooks/build
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/bash
BUILD_PATH=$(echo ${DOCKERFILE_PATH}| sed 's#/#..#g' | sed 's#[a-zA-Z0-9]\+#/#g' | cut -c 2- )

docker build --target=bookworm-base -f $(basename ${DOCKERFILE_PATH}) -t $DOCKER_REPO:latest -t $DOCKER_REPO:base ${BUILD_PATH}.
docker build --target=bookworm-metamod -f $(basename ${DOCKERFILE_PATH}) -t $DOCKER_REPO:metamod ${BUILD_PATH}.
docker build --target=bookworm-sourcemod -f $(basename ${DOCKERFILE_PATH}) -t $DOCKER_REPO:sourcemod ${BUILD_PATH}.
BUILD_PATH=$(echo ${DOCKERFILE_PATH} | sed 's#/#..#g' | sed 's#[a-zA-Z0-9]\+#/#g' | cut -c 2- )

docker build --target=bookworm-base -f "x32/$(basename ${DOCKERFILE_PATH})" -t $DOCKER_REPO:latest -t $DOCKER_REPO:latest-x32 -t $DOCKER_REPO:base-x32 -t $DOCKER_REPO:base "${BUILD_PATH}".
docker build --target=bookworm-metamod -f "x32/$(basename ${DOCKERFILE_PATH})" -t $DOCKER_REPO:metamod -t $DOCKER_REPO:metamod-x32 "${BUILD_PATH}".
docker build --target=bookworm-sourcemod -f "x32/$(basename ${DOCKERFILE_PATH})" -t $DOCKER_REPO:sourcemod -t $DOCKER_REPO:sourcemod-x32 "${BUILD_PATH}".

docker build --target=bookworm-base -f "x64/$(basename ${DOCKERFILE_PATH})" -t $DOCKER_REPO:latest-x64 -t $DOCKER_REPO:base-x64 ${BUILD_PATH}.
docker build --target=bookworm-metamod -f "x64/$(basename ${DOCKERFILE_PATH})" -t $DOCKER_REPO:metamod-x64 ${BUILD_PATH}.
docker build --target=bookworm-sourcemod -f "x64/$(basename ${DOCKERFILE_PATH})" -t $DOCKER_REPO:sourcemod-x64 ${BUILD_PATH}.

File renamed without changes.
81 changes: 81 additions & 0 deletions bookworm/x64/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
###########################################################
# Dockerfile that builds a TF2 Gameserver
###########################################################
FROM cm2network/steamcmd:root AS build_stage

LABEL maintainer="[email protected]"

ENV STEAMAPPID 232250
ENV STEAMAPP tf
ENV STEAMAPPDIR "${HOMEDIR}/${STEAMAPP}-dedicated"

COPY "etc/entry_x64.sh" "${HOMEDIR}/entry_x64.sh"
COPY "etc/cfg" "${STEAMAPPDIR}/${STEAMAPP}/cfg/"

RUN set -x \
# Install, update & upgrade packages
&& apt-get update \
&& apt-get install -y --no-install-recommends --no-install-suggests \
wget=1.21.3-1+b2 \
ca-certificates=20230311 \
zlib1g=1:1.2.13.dfsg-1 \
libncurses5=6.4-4 \
libbz2-1.0=1.0.8-5+b1 \
libtinfo5=6.4-4 \
libcurl3-gnutls=7.88.1-10+deb12u5 \
&& mkdir -p "${STEAMAPPDIR}" \
# Create autoupdate config
&& { \
echo '@ShutdownOnFailedCommand 1'; \
echo '@NoPromptForPassword 1'; \
echo 'force_install_dir '"${STEAMAPPDIR}"''; \
echo 'login anonymous'; \
echo 'app_update '"${STEAMAPPID}"''; \
echo 'quit'; \
} > "${HOMEDIR}/${STEAMAPP}_update.txt" \
&& chmod +x "${HOMEDIR}/entry_x64.sh" \
&& chown -R "${USER}:${USER}" "${HOMEDIR}/entry_x64.sh" "${STEAMAPPDIR}" "${HOMEDIR}/${STEAMAPP}_update.txt" \
# Clean up
&& rm -rf /var/lib/apt/lists/*

FROM build_stage AS bookworm-base

ENV SRCDS_FPSMAX=300 \
SRCDS_TICKRATE=66 \
SRCDS_PORT=27015 \
SRCDS_TV_PORT=27020 \
SRCDS_NET_PUBLIC_ADDRESS="0" \
SRCDS_IP="0" \
SRCDS_MAXPLAYERS=16 \
SRCDS_TOKEN=0 \
SRCDS_RCONPW="changeme" \
SRCDS_PW="changeme" \
SRCDS_STARTMAP="ctf_2fort" \
SRCDS_REGION=3 \
SRCDS_HOSTNAME="New \"${STEAMAPP}\" Server" \
SRCDS_WORKSHOP_START_MAP=0 \
SRCDS_HOST_WORKSHOP_COLLECTION=0 \
SRCDS_WORKSHOP_AUTHKEY="" \
SRCDS_CFG="server.cfg" \
SRCDS_MAPCYCLE="mapcycle.txt" \
SRCDS_SECURED=1

# Switch to user
USER ${USER}

WORKDIR ${HOMEDIR}

CMD ["bash", "entry_x64.sh"]

# Expose ports
EXPOSE 27015/tcp \
27015/udp \
27020/udp

FROM bookworm-base AS bookworm-metamod

ENV METAMOD_VERSION 1.12

FROM bookworm-metamod AS bookworm-sourcemod

ENV SOURCEMOD_VERSION 1.12
55 changes: 55 additions & 0 deletions etc/entry_x64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
mkdir -p "${STEAMAPPDIR}" || true

bash "${STEAMCMDDIR}/steamcmd.sh" +force_install_dir "${STEAMAPPDIR}" \
+login anonymous \
+app_update "${STEAMAPPID}" \
+quit

# Are we in a metamod container and is the metamod folder missing?
if [ ! -z "$METAMOD_VERSION" ] && [ ! -d "${STEAMAPPDIR}/${STEAMAPP}/addons/metamod" ]; then
LATESTMM=$(wget -qO- https://mms.alliedmods.net/mmsdrop/"${METAMOD_VERSION}"/mmsource-latest-linux)
wget -qO- https://mms.alliedmods.net/mmsdrop/"${METAMOD_VERSION}"/"${LATESTMM}" | tar xvzf - -C "${STEAMAPPDIR}/${STEAMAPP}"
fi

# Are we in a sourcemod container and is the sourcemod folder missing?
if [ ! -z "$SOURCEMOD_VERSION" ] && [ ! -d "${STEAMAPPDIR}/${STEAMAPP}/addons/sourcemod" ]; then
LATESTSM=$(wget -qO- https://sm.alliedmods.net/smdrop/"${SOURCEMOD_VERSION}"/sourcemod-latest-linux)
wget -qO- https://sm.alliedmods.net/smdrop/"${SOURCEMOD_VERSION}"/"${LATESTSM}" | tar xvzf - -C "${STEAMAPPDIR}/${STEAMAPP}"
fi

# Is the config missing?
if [ ! -f "${STEAMAPPDIR}/${STEAMAPP}/cfg/server.cfg" ]; then
# Change hostname on first launch (you can comment this out if it has done its purpose)
sed -i -e 's/{{SERVER_HOSTNAME}}/'"${SRCDS_HOSTNAME}"'/g' "${STEAMAPPDIR}/${STEAMAPP}/cfg/server.cfg"
fi

# Believe it or not, if you don't do this srcds_run shits itself
cd "${STEAMAPPDIR}"

SERVER_SECURITY_FLAG="";

if [ "$SRCDS_SECURED" -eq 0 ]; then
SERVER_SECURITY_FLAG="-insecure";
fi

bash "${STEAMAPPDIR}/srcds_run_64" -game "${STEAMAPP}" -console -autoupdate \
-steam_dir "${STEAMCMDDIR}" \
-steamcmd_script "${HOMEDIR}/${STEAMAPP}_update.txt" \
-usercon \
+fps_max "${SRCDS_FPSMAX}" \
-tickrate "${SRCDS_TICKRATE}" \
-port "${SRCDS_PORT}" \
+tv_port "${SRCDS_TV_PORT}" \
+clientport "${SRCDS_CLIENT_PORT}" \
+maxplayers "${SRCDS_MAXPLAYERS}" \
+map "${SRCDS_STARTMAP}" \
+sv_setsteamaccount "${SRCDS_TOKEN}" \
+rcon_password "${SRCDS_RCONPW}" \
+sv_password "${SRCDS_PW}" \
+sv_region "${SRCDS_REGION}" \
-ip "${SRCDS_IP}" \
-authkey "${SRCDS_WORKSHOP_AUTHKEY}" \
+servercfgfile "${SRCDS_CFG}" \
+mapcyclefile "${SRCDS_MAPCYCLE}" \
${SERVER_SECURITY_FLAG}

0 comments on commit 70bfa4a

Please sign in to comment.