OnsetDocker: Difference between revisions
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,..." |
No edit summary |
||
Line 56: | Line 56: | ||
./OnsetServer --noinput | ./OnsetServer --noinput | ||
</syntaxhighlight> | </syntaxhighlight> | ||
2.c. We now have to copy this file in our container at build. Update the <code>Dockerfile</code> at line 12. | |||
<syntaxhighlight> | |||
# We install Onset files with SteamCMD and delete the base packages folder and start_linux.sh file | |||
RUN /home/steam/steamcmd/steamcmd.sh +login anonymous +force_install_dir /home/steam/onset +app_update 1204170 +quit && \ | |||
rm -r /home/steam/onset/packages/ start_linux.sh | |||
# Copy the start_linux file as steam user and make it executable | |||
COPY --chown=steam:steam start_linux.sh /home/steam/onset/start_linux.sh | |||
RUN chmod +x start_linux.sh | |||
# We launch the server at start | |||
CMD ./start_linux.sh | |||
</syntaxhighlight> | |||
We are not fine ;) | |||
[[File:good1.png|800px|none]] |
Revision as of 16:30, 30 September 2020
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
2.c. We now have to copy this file in our container at build. Update the Dockerfile
at line 12.
# We install Onset files with SteamCMD and delete the base packages folder and start_linux.sh file
RUN /home/steam/steamcmd/steamcmd.sh +login anonymous +force_install_dir /home/steam/onset +app_update 1204170 +quit && \
rm -r /home/steam/onset/packages/ start_linux.sh
# Copy the start_linux file as steam user and make it executable
COPY --chown=steam:steam start_linux.sh /home/steam/onset/start_linux.sh
RUN chmod +x start_linux.sh
# We launch the server at start
CMD ./start_linux.sh
We are not fine ;)