OnsetDocker

From Onset Developer Wiki
Revision as of 16:22, 30 September 2020 by Soljian (talk | contribs) (Created page with "Docker can be really helpful while developing your own server but it can be awesome when you are managing servers : cpu and ram limitations and reservations, crash management,...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Docker can be really helpful while developing your own server but it can be awesome when you are managing servers : cpu and ram limitations and reservations, crash management, auto restart, security and isolation. Let's see how we can deal with it.

Development stack

For this guide we are going to create a brand new server folder.

1. Start with creation of the Dockerfile file and put the content below

# The image we start from (a basic debian with SteamCMD)
FROM cm2network/steamcmd:root

# We'll use the "steam" user because run the server with "root" is a bad idea
USER steam

# We create our onset folder and set the base location for the image
RUN mkdir /home/steam/onset
WORKDIR /home/steam/onset

# We install Onset files with SteamCMD and delete the base packages folder
RUN /home/steam/steamcmd/steamcmd.sh +login anonymous +force_install_dir /home/steam/onset +app_update 1204170 +quit && \
    rm -r /home/steam/onset/packages/

# We launch the server at start
CMD ./start_linux.sh

2. Next, we need a docker-compose.yml file to setup our environment

version: '3.7'

services:
  onset:
    image: steam_onset
    # Tell docker where to find the Dockerfile
    build: 
      context: .
    # We need to run the container as steam user
    user: "steam:steam"
    # Open some ports
    ports:
      - "7777:7777/udp"
      - "7776:7776/udp"
      - "7775:7775/tcp"

2.b. We can run the server now. You can use docker-compose up --build to try it out but we are going to have a error :

This is because of the new console input feature. To disable it, let's add a start_linux.sh to replace the base one :

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.
./OnsetServer --noinput