Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use custom base image #3

Merged
merged 2 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ When starting the server for the first time:

* The config files and folders will be automatically created in the `config/` folder.
* The server will download the latest version of the game from Steam to the `data/` folder.
* The server might need to be restarted once to apply the latest game update.

> You have to restart after the first start.

To restart the server after making changes to the configuration, use the following command:

Expand Down
56 changes: 5 additions & 51 deletions container-data/Containerfile
Original file line number Diff line number Diff line change
@@ -1,53 +1,7 @@
# Use latest Ubuntu as base image
FROM ubuntu:devel
FROM rouhim/steamcmd-wine:latest
USER $USER

# Define environment variables
ENV USER_HOME "/home/ubuntu"
ENV STEAMCMD "$USER_HOME/steamcmd/steamcmd.sh"
ENV SERVER_DIR "/data"
ENV SERVER_CONFIG_DIR "/config"
ENV STEAM_APP_ID "2465200"
ENV STARTUP_COMMAND "wine SonsOfTheForestDS.exe -userdatapath $SERVER_CONFIG_DIR"

# Use default non root user ubuntu (1000)
WORKDIR $USER_HOME

# Install steamcmd and its dependencies
RUN apt update && \
apt install -y wget ca-certificates lib32gcc-s1 && \
mkdir -p $USER_HOME/steamcmd && \
wget -qO- 'https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz' | tar zxf - -C $USER_HOME/steamcmd && \
chown -R ubuntu:ubuntu $USER_HOME/steamcmd

# Install wine and its dependencies and do a full system upgrade to get the latest and greatest packages
RUN apt update && \
apt install -y --no-install-recommends wine wine64 winbind xvfb && \
apt upgrade -y

# Cleanup, remove wget
RUN apt remove -y wget && \
apt clean && \
rm -rf /var/lib/apt/lists

# Create game server and config directory
RUN mkdir -p $SERVER_DIR $SERVER_CONFIG_DIR
VOLUME $SERVER_DIR
VOLUME $SERVER_CONFIG_DIR

# Copy steam-game.script to container
COPY steam-game.script $USER_HOME/steam-game.script

# Change user to non-root user
RUN chown -R ubuntu:ubuntu $USER_HOME && \
chown -R nobody:nogroup $SERVER_DIR $SERVER_CONFIG_DIR && \
chmod 777 -R $SERVER_DIR $SERVER_CONFIG_DIR
USER ubuntu

# Game port
EXPOSE 8766/udp
# Query port
EXPOSE 27016/udp
# Blobsync port
EXPOSE 9700/udp

# Define entrypoint
COPY --chown=ubuntu:ubuntu --chmod=755 entrypoint.sh /sons-of-the-forest-server.sh
ENTRYPOINT ["/sons-of-the-forest-server.sh"]
COPY pre.sh $USER_HOME/pre.sh
57 changes: 0 additions & 57 deletions container-data/entrypoint.sh

This file was deleted.

6 changes: 6 additions & 0 deletions container-data/pre.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh


# Set skip network accessibility test to true
echo "🔧 Adjust server config..."
sed -i 's/"SkipNetworkAccessibilityTest": false/"SkipNetworkAccessibilityTest": true/g' "$SERVER_CONFIG_DIR"/dedicatedserver.cfg
9 changes: 0 additions & 9 deletions container-data/steam-game.script

This file was deleted.