Giter Site home page Giter Site logo

cm2walki / tf2 Goto Github PK

View Code? Open in Web Editor NEW
63.0 6.0 23.0 133 KB

Dockerfile for automated build of a TF2 gameserver: https://hub.docker.com/r/cm2network/tf2/

Home Page: https://CM2.Network

License: MIT License

Dockerfile 40.25% Shell 59.75%
tf2 metamod sourcemod game game-server docker dockerfile

tf2's Introduction

Code Quality Docker Build Status Docker Stars Docker Pulls Discord

Supported tags and respective Dockerfile links

What is Team Fortress 2?

Nine distinct classes provide a broad range of tactical abilities and personalities. Constantly updated with new game modes, maps, equipment and, most importantly, hats! This Docker image contains the dedicated server of the game.

TF2

logo

How to use this image

Hosting a simple game server

Running on the host interface (recommended):

$ docker run -d --net=host --name=tf2-dedicated -e SRCDS_TOKEN={YOURTOKEN} cm2network/tf2

Running using a bind mount for data persistence on container recreation:

$ mkdir -p $(pwd)/tf2-data
$ chmod 777 $(pwd)/tf2-data # Makes sure the directory is writeable by the unprivileged container user
$ docker run -d --net=host -v $(pwd)/tf2-data:/home/steam/tf-dedicated/ --name=tf2-dedicated -e SRCDS_TOKEN={YOURTOKEN} cm2network/tf2

Running multiple instances (increment SRCDS_PORT and SRCDS_TV_PORT):

$ docker run -d --net=host --name=tf2-dedicated2 -e SRCDS_PORT=27016 -e SRCDS_TV_PORT=27021 -e SRCDS_TOKEN={YOURTOKEN} cm2network/tf2

SRCDS_TOKEN is required to be listed & reachable. Generate one here using AppID 440:
https://steamcommunity.com/dev/managegameservers

SRCDS_WORKSHOP_AUTHKEY is required to use workshop features:
https://steamcommunity.com/dev/apikey

It's also recommended to use "--cpuset-cpus=" to limit the game server to a specific core & thread.
The container will automatically update the game on startup, so if there is a game update just restart the container.

Configuration

Environment Variables

Feel free to overwrite these environment variables, using -e (--env):

SRCDS_TOKEN="changeme" (value is is required to be listed & reachable, retrieve token here (AppID 440): https://steamcommunity.com/dev/managegameservers)
SRCDS_RCONPW="changeme" (value can be overwritten by tf/cfg/server.cfg) 
SRCDS_PW="changeme" (value can be overwritten by tf/cfg/server.cfg) 
SRCDS_PORT=27015
SRCDS_TV_PORT=27020
SRCDS_IP="0" (local ip to bind)
SRCDS_FPSMAX=300
SRCDS_TICKRATE=66
SRCDS_MAXPLAYERS=14
SRCDS_REGION=3
SRCDS_STARTMAP="ctf_2fort"
SRCDS_HOSTNAME="New TF Server" (first launch only)
SRCDS_WORKSHOP_AUTHKEY="" (required to load workshop maps)
SRCDS_CFG="server.cfg"
SRCDS_MAPCYCLE="mapcycle_default.txt" (value can be overwritten by tf/cfg/server.cfg)
SRCDS_SECURED=1 (0 to start the server as insecured)

Config

The image contains static copies of the competitive config files from UGC League and RGL.gg.

You can edit the config using this command:

$ docker exec -it tf2-dedicated nano /home/steam/tf-dedicated/tf/cfg/server.cfg

Or if you want to explicitly specify a server config file, use the SRCDS_CFG environment variable.

If you want to learn more about configuring a TF2 server check this documentation.

Image Variants:

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.

tf2:metamod

This is a specialized image. It contains the plugin environment Metamod:Source which can be found in the addons directory. You can find additional plugins here.

tf2:sourcemod

This is another specialized image. It contains both Metamod:Source and the popular server plugin SourceMod which can be found in the addons directory. SourceMod supports a wide variety of additional plugins that can be found here.

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

tf2's People

Contributors

aaronsilber avatar agrastios avatar biltongza avatar cm2walki avatar cosminperram avatar joelzwarrington avatar kir68k avatar withgod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tf2's Issues

SRCDS_RCONPW is not working

When I start container with SRCDS_RCONPW, server uses default password from server.cfg file.
I fixed variables in server.cfg and restarted container - and rcon works correctly.

Probably add
sed -i -e 's/changeme/'"${SRCDS_RCONPW}"'/g' "${STEAMAPPDIR}/${STEAMAPP}/cfg/server.cfg"

to /etc/entry.sh:27?

Buffer Overflow Detected

When trying to launch the container I am getting a "buffer overflow detected" message

*** buffer overflow detected ***: terminated
Add "-debug" to the /home/steam/tf-dedicated/srcds_run command line to generate a debug.log to help with solving this problem
/home/steam/tf-dedicated/srcds_run: line 324:   173 Aborted                 (core dumped) $HL_CMD

It restarts the server and every time it loops around it gives a higher number aborted.
I have tried deleting local files and pulling again, but no change
I am using cm2network/tf2:sourcemod

I attached the logs, but let me know if you need any more info
_TF2_logs.txt

srcds_run: No such file or directory

Started the container using this command (as per docker hub, with SRCDS token subbed in):

$ docker run -d --net=host --name=tf2-dedicated -e SRCDS_TOKEN={TOKEN} cm2network/tf2

I see this in the logs:

$ docker logs -f tf2-dedicated
WARNING: setlocale('en_US.UTF-8') failed, using locale: 'C'. International characters may not work.
Redirecting stderr to '/home/steam/Steam/logs/stderr.txt'
[  0%] Checking for available updates...
[----] Verifying installation...
[  0%] Downloading update...
[  0%] Checking for available updates...
[----] Download complete.
[----] Extracting package...
[----] Extracting package...
[----] Extracting package...
[----] Extracting package...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Cleaning up...
[----] Update complete, launching Steamcmd...
CWorkThreadPool::~CWorkThreadPool: work processing queue not empty: 3 items discarded.
WARNING: setlocale('en_US.UTF-8') failed, using locale: 'C'. International characters may not work.
Redirecting stderr to '/home/steam/Steam/logs/stderr.txt'
[  0%] Checking for available updates...
[----] Verifying installation...
Steam Console Client (c) Valve Corporation
-- type 'quit' to exit --
Loading Steam API...Warning: failed to init SDL thread priority manager: SDL not found
OK.

Connecting anonymously to Steam Public...Logged in OK
Waiting for user info...OK
 Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
 Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
Error! App '232250' state is 0x202 after update job.
CWorkThreadPool::~CWorkThreadPool: work processing queue not empty: 2 items discarded.
CWorkThreadPool::~CWorkThreadPool: work processing queue not empty: 1 items discarded.
bash: /home/steam/tf-dedicated/srcds_run: No such file or directory

and then the container exits.

Looks like this might be caused by the change yesterday as I can see entry.sh is new, so will see if I can figure out how to fix this one.

Support appending/editing startup commands to the launch script

Hi there, just want to start off by saying I appreciate the work that you and every other contributor has done to make this image a thing - as it's great for spinning up and distributing servers quickly versus working with something like LinuxGSM.

I would like to be able to append the +randommap command line argument instead of manually specifying +map ${SRCDS_STARTMAP} as defined here, which unfortunately is hardcoded. I'm unsure what the best way to do this would be, as I believe the commands are mutally exclusive, but I prefer my server being able to pick a random map out of the mapcyclefile as opposed to always starting with a specific map.

I'm unsure if it would add unnecessary complexity, but maybe the following two things could be simultaneously added:

  • if SRCDS_STARTMAP is empty, don't append it to the startup command
  • support maybe an additional SRCDS_EXTRAARGS envvar which is simply appended to the end, if possible?

Dev build of sourcemod

Hey, I was just wondering whether it's possible to implement this? Instead of using normal sourcemod releases, ship with the latest dev build. My docker knowledge is limited, so asking here.

Auto update

I have to manually restart the container every time valvo pushes an update. When they push the update, players cant play on my server. Anyway to automate that with this image? Thanks

Image corruption

I'm finding that on 2 of the 8 machines I've pulled the image on, I have consistent file corruption issues with some map or resource. Forcing an integrity check with docker save cm2network/tf2 > /dev/null will yield some broken resource, or the connecting TF2 clients will see Your map (map_name.bsp) differs from the server's or some similar error. I'm not sure what will cause these issues, but on the machines it appears on, some resource will consistently error every time I purge and re-download the image, infuriatingly a different resource every time. Docker doesn't throw any errors with the pull, it only discovers issues after forcing a check.

All 8 machines are Ubuntu 18.04 LTS, the only commonality I can see with the 2 erroring machines is that they are physical boxes, rather than VPC's or EC2 instances.

I think I've fixed the issue on each machine by entering the Docker container, reinstalling steamcmd and forcing a verify-and-update of appid 232250, but it was a messy process.

Is anyone else seeing these same issues? Is there a way to package steamcmd in a way that the "validate" command can be run without needing a reinstall?

Issue using mapped folder volume

I have tried several forms of -v /srv/somedir/:/home/steam/tf-dedicated/ and I have been unable to launch the container. Launching with with just the volume command (no mapped folder) or no volume works. I even tried mapping -v /srv/somedir/:/home/ and it still gives me the error:

bash: entry.sh: No such file or directory

There is something going on with entry.sh being located within the /home/steam/tf-dedicated folder.... would it be possible to have entry.sh copied to the / directory?

Unable to start Sourcemod image

I'm unable to a sourcemod image at this time. Whenever I attempt to start a new container using the sourcemod image, the container log will hang at random times, never actually starting the server. I was able to start the base image with no issues, but trying to start a sourcemod image with the exact same settings does not work.

Typically the server will freeze at enabling logs or stating the sv_pure value.

I'd be happy to provide any info to better describe what is going on.

Error trying to start container

I'm sorry in advance if this is because of my unfamiliarity with docker, but whenever I try to run the image, pulled from docker hub, I get

exec /bin/bash: no such file or directory

This happens both if I try to use the command from readme (then the error is in container logs), or if I just start it using docker run -it
Please advise if there's some common docker pitfall I'm unaware of or if it's something wrong with the image.
If you need more details, I'll provide them, I'm just not sure what exatly you might need.

Constant Core Dump

My Docker image constantly dumps core and reboots since the last updated pull.

Is anyone else having this issue?

Create tf-dedicated/tf/cfg

It's a pretty niche usecase, but I run latest on k8s and want to mount files to tf-dedicated/tf/cfg. If tf/cfg doesn't exist, it's mounted as root, so I have to use a separate container to create tf/cfg on new volumes. This would be great to have built-in to this image

Bind to dualstack hosts

I would like to setup a private tf2 server for my friends and I and before I start digging for hours I wonder if IPv6 could work alongside IPv4 and if IPv6 is even supported by Steam/Team Fortress 2

If so, could you indicate me a way to do achieve this with the configuration file ?

Something seems wrong with the logs.

When I used it a month ago, there was no problem, but when I used it recently, the logs were not displayed correctly.

problem log.
(This log uses sourcemod variants, but I encountered the same problem with latest.)
https://gist.github.com/withgod/515a31a572e24c1e56704a018d9a6b54#file-docker-logs-error-server-txt-L24
good log.
https://gist.github.com/withgod/515a31a572e24c1e56704a018d9a6b54#file-docker-logs-good-server-txt-L21

There is less display compared to a normal server.

I've tried it on my macbook and another server, and the logs are low on all of them.

The client can still connect and play in this state, but there is no connection log.
I can also do changelevel via rcon, but no log is displayed.

The server I built a month ago is still running without any problems.

Is it just my environment?

thanks.

error loop

I'm using this command to run the server:
docker run -d --net=host --name=tf2 -e SRCDS_TOKEN={***} -v /srv/c7c67d06-a5c3-4586-be6a-af277ae13aa2/tf2/tf-dedicated:/home/steam/tf-dedicated -e SRCDS_PORT=26015 -e SRCDS_TV_PORT=26020 -e SRCDS_HOSTNAME="{***}" -e SRCDS_RCONPW="{***}" -e SRCDS_PW="{***}" --memory=8g cm2network/tf2

I tried both with and without the --memory option. Either way, I get through the download and then get stuck in an error loop. Example output:

WARNING: setlocale('en_US.UTF-8') failed, using locale: 'C'. International characters may not work.
Redirecting stderr to '/home/steam/Steam/logs/stderr.txt'
[  0%] Checking for available updates...
[----] Downloading update (48 of 53196 KB)...
[  0%] Downloading update (1998 of 53196 KB)...
[  3%] Downloading update (4222 of 53196 KB)...
[  7%] Downloading update (6158 of 53196 KB)...
[ 11%] Downloading update (7662 of 53196 KB)...
[ 14%] Downloading update (8994 of 53196 KB)...
[ 16%] Downloading update (10330 of 53196 KB)...
[ 19%] Downloading update (11611 of 53196 KB)...
[ 21%] Downloading update (13027 of 53196 KB)...
[ 24%] Downloading update (14343 of 53196 KB)...
[ 26%] Downloading update (15669 of 53196 KB)...
[ 29%] Downloading update (16997 of 53196 KB)...
[ 31%] Downloading update (18524 of 53196 KB)...
[ 34%] Downloading update (19879 of 53196 KB)...
[ 37%] Downloading update (21177 of 53196 KB)...
[ 39%] Downloading update (22504 of 53196 KB)...
[ 42%] Downloading update (23917 of 53196 KB)...
[ 44%] Downloading update (25242 of 53196 KB)...
[ 47%] Downloading update (26567 of 53196 KB)...
[ 49%] Downloading update (27913 of 53196 KB)...
[ 52%] Downloading update (29491 of 53196 KB)...
[ 55%] Downloading update (30846 of 53196 KB)...
[ 57%] Downloading update (32198 of 53196 KB)...
[ 60%] Downloading update (33713 of 53196 KB)...
[ 63%] Downloading update (34369 of 53196 KB)...
[ 64%] Downloading update (35020 of 53196 KB)...
[ 65%] Downloading update (35670 of 53196 KB)...
[ 67%] Downloading update (36409 of 53196 KB)...
[ 68%] Downloading update (37067 of 53196 KB)...
[ 69%] Downloading update (37741 of 53196 KB)...
[ 70%] Downloading update (38440 of 53196 KB)...
[ 72%] Downloading update (39113 of 53196 KB)...
[ 73%] Downloading update (39792 of 53196 KB)...
[ 74%] Downloading update (40561 of 53196 KB)...
[ 76%] Downloading update (41244 of 53196 KB)...
[ 77%] Downloading update (41923 of 53196 KB)...
[ 78%] Downloading update (42602 of 53196 KB)...
[ 80%] Downloading update (43309 of 53196 KB)...
[ 81%] Downloading update (43976 of 53196 KB)...
[ 82%] Downloading update (44644 of 53196 KB)...
[ 83%] Downloading update (45385 of 53196 KB)...
[ 85%] Downloading update (46041 of 53196 KB)...
[ 86%] Downloading update (46686 of 53196 KB)...
[ 87%] Downloading update (47337 of 53196 KB)...
[ 88%] Downloading update (48035 of 53196 KB)...
[ 90%] Downloading update (48685 of 53196 KB)...
[ 91%] Downloading update (49335 of 53196 KB)...
[ 92%] Downloading update (50078 of 53196 KB)...
[ 94%] Downloading update (50724 of 53196 KB)...
[ 95%] Downloading update (51379 of 53196 KB)...
[ 96%] Downloading update (52072 of 53196 KB)...
[ 97%] Downloading update (52743 of 53196 KB)...
[ 99%] Downloading update (53196 of 53196 KB)...
[100%] Download complete.
[----] Installing update...
[----] Extracting package...
[----] Extracting package...
[----] Extracting package...
[----] Extracting package...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Cleaning up...
[----] Update complete, launching Steamcmd...
WARNING: setlocale('en_US.UTF-8') failed, using locale: 'C'. International characters may not work.
Redirecting stderr to '/home/steam/Steam/logs/stderr.txt'
/tmp/dumps insufficient permissions - delete and recreate
[  0%] Checking for available updates...
[----] Verifying installation...
Steam Console Client (c) Valve Corporation
-- type 'quit' to exit --
Loading Steam API...OK.

Connecting anonymously to Steam Public...Logged in OK
Waiting for user info...OK
Success! App '232250' already up to date.
Auto detecting CPU
Using default binary: ./srcds_linux
Server will auto-restart if there is a crash.
Updating server using Steam.
----------------------------
WARNING: setlocale('en_US.UTF-8') failed, using locale: 'C'. International characters may not work.
Redirecting stderr to '/home/steam/Steam/logs/stderr.txt'
[  0%] Checking for available updates...
[----] Verifying installation...
Steam Console Client (c) Valve Corporation
-- type 'quit' to exit --
Loading Steam API...OK.
@ShutdownOnFailedCommand 1
"@ShutdownOnFailedCommand" = "1"
@NoPromptForPassword 1
"@NoPromptForPassword" = "1"

Connecting anonymously to Steam Public...Logged in OK
Waiting for user info...OK
force_install_dir /home/steam/tf-dedicated
app_update 232250
Success! App '232250' already up to date.
quit
----------------------------
Setting breakpad minidump AppID = 232250
Using breakpad crash handler
Add "-debug" to the /home/steam/tf-dedicated/srcds_run command line to generate a debug.log to help with solving this problem
Sat Jun  5 16:26:45 UTC 2021: Server restart in 10 seconds

And then the following section repeats indefinitely:

Updating server using Steam.
----------------------------
WARNING: setlocale('en_US.UTF-8') failed, using locale: 'C'. International characters may not work.
Redirecting stderr to '/home/steam/Steam/logs/stderr.txt'
[  0%] Checking for available updates...
[----] Verifying installation...
Steam Console Client (c) Valve Corporation
-- type 'quit' to exit --
Loading Steam API...OK.
@ShutdownOnFailedCommand 1
"@ShutdownOnFailedCommand" = "1"
@NoPromptForPassword 1
"@NoPromptForPassword" = "1"

Connecting anonymously to Steam Public...Logged in OK
Waiting for user info...OK
force_install_dir /home/steam/tf-dedicated
app_update 232250
Success! App '232250' already up to date.
quit
----------------------------
Setting breakpad minidump AppID = 232250
Using breakpad crash handler
Add "-debug" to the /home/steam/tf-dedicated/srcds_run command line to generate a debug.log to help with solving this problem
Sat Jun  5 16:27:02 UTC 2021: Server restart in 10 seconds

I tried editing entry.sh to include the -debug argument and restarting the container, but that didn't change the output at all.

Then I tried exec'ing into the running container and copy/pasting the last command from entry.sh into the shell - I got "Out of memory or address space", but that might be because the entry.sh script was still running in this perpetual crash loop...

[Request] Insecured ENV variable

I wanted to run a server in insecure mode and I see that there's no easy wait to do that, I had to modify the scrds_run file to run the server in insecure mode, an env variable stating to run the server in insecure mode would be nice.

Impossible to switch channel or update mods

The current entry logic is as follows:
if, and only if, there isn't already a server config file, check to determine if metamod/sourcemod should be pulled in

This logic has some major issues:

  1. if a user switches varient, for exmaple a user installs vanilla but they decide later that they want sourcemod, the entry script will never check for it
  2. the entry script will never check for updates, leaving both metamod and sourcemod variants out of date

As it is, it's possible to work around, as the user can move important files out of cfg, allow the image to re-generate them, then move their files back, however this is a very hacky workflow, and it would be more ideal if the entry point could handle this itself. As a suggested solution, perhaps move those two ifs outside of the "does config exist" check, always check the current version, and install it if it doesn't match what's on disk. Additionally, ideally the entry would clean up older versions and clean up if the user has switched variant.

It may also be good to bake the latest version tar files for metamod/sourcemod into the respective image(s), and just do the extraction if necessary in the entrypoint

Unrecognised startup commands

[snip]
Unknown command "net_public_adr"
Unknown command "host_workshop_collection"
Unknown command "workshop_start_map"
Unknown command "startupmenu"
[snip]

Server throws these errors on startup (they don't cause a crash).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.