-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6edcbd9
Showing
8 changed files
with
248 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* | ||
!entrypoint.sh | ||
!config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
name: Build and Deploy container to GHCR | ||
|
||
on: | ||
schedule: | ||
- cron: '49 3 * * *' | ||
push: | ||
branches: [ "main" ] | ||
# Publish semver tags as releases. | ||
tags: [ 'v*.*.*' ] | ||
workflow_dispatch: | ||
|
||
env: | ||
# Use docker.io for Docker Hub if empty | ||
REGISTRY: ghcr.io | ||
# github.repository as <account>/<repo> | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
|
||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
# This is used to complete the identity challenge | ||
# with sigstore/fulcio when running outside of PRs. | ||
id-token: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
# Install the cosign tool except on PR | ||
# https://github.com/sigstore/cosign-installer | ||
- name: Install cosign | ||
if: github.event_name != 'pull_request' | ||
uses: sigstore/cosign-installer@v3 #v3.7.0 | ||
with: | ||
cosign-release: 'v2.4.1' | ||
|
||
# Set up BuildKit Docker container builder to be able to build | ||
# multi-platform images and export cache | ||
# https://github.com/docker/setup-buildx-action | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 # v3.7.1 | ||
|
||
# Login against a Docker registry except on PR | ||
# https://github.com/docker/login-action | ||
- name: Log into registry ${{ env.REGISTRY }} | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v3 # v3.3.0 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Extract metadata (tags, labels) for Docker | ||
# https://github.com/docker/metadata-action | ||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 # v5.6.1 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
flavor: | | ||
latest=auto | ||
tags: | | ||
type=ref,event=branch,suffix=-{{ sha }} | ||
type=semver,pattern={{version}} | ||
type=raw,value=latest,enable={{is_default_branch}} | ||
# Build and push Docker image with Buildx (don't push on PR) | ||
# https://github.com/docker/build-push-action | ||
- name: Build and push Docker image | ||
id: build-and-push | ||
uses: docker/build-push-action@v6 # v6.10.0 | ||
with: | ||
context: . | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
# Sign the resulting Docker image digest except on PRs. | ||
# This will only write to the public Rekor transparency log when the Docker | ||
# repository is public to avoid leaking data. If you would like to publish | ||
# transparency data even for private images, pass --force to cosign below. | ||
# https://github.com/sigstore/cosign | ||
- name: Sign the published Docker image | ||
if: ${{ github.event_name != 'pull_request' }} | ||
env: | ||
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable | ||
TAGS: ${{ steps.meta.outputs.tags }} | ||
DIGEST: ${{ steps.build-and-push.outputs.digest }} | ||
# This step uses the identity token to provision an ephemeral certificate | ||
# against the sigstore community Fulcio instance. | ||
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.env | ||
compose.yml | ||
local.dedicatedserver.cfg | ||
local.ownerswhitelist.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Set the base image to Ubuntu | ||
FROM steamcmd/steamcmd:ubuntu-24 | ||
|
||
# File Author / Maintainer | ||
LABEL maintainer="edemirkan" | ||
|
||
# Set environment variables | ||
ENV TIMEZONE=America/Toronto | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
ENV USER=forest | ||
ENV HOME=/forest | ||
ENV PUID=1000 | ||
|
||
################## BEGIN INSTALLATION ###################### | ||
|
||
# Create the application user | ||
RUN userdel -r $(getent passwd $PUID | cut -d: -f1) \ | ||
&& useradd -u $PUID -m -d $HOME $USER | ||
|
||
# Create required directories | ||
RUN mkdir -p $HOME/userdata | ||
|
||
# Install prerequisites | ||
RUN apt-get update -y \ | ||
&& apt-get install -y winbind wine-stable xvfb \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Download the application via steamcmd | ||
RUN steamcmd +@sSteamCmdForcePlatformType windows +force_install_dir $HOME +login anonymous +app_update 2465200 validate +quit | ||
|
||
# Copy configuration | ||
COPY config/dedicatedserver.cfg $HOME/userdata/dedicatedserver.cfg | ||
COPY config/ownerswhitelist.txt $HOME/userdata/ownerswhitelist.txt | ||
COPY entrypoint.sh $HOME/entrypoint.sh | ||
|
||
##################### INSTALLATION END ##################### | ||
|
||
# Expose the default ports | ||
EXPOSE 8766/udp 27016/udp 9700/udp | ||
|
||
# Correct file permissions | ||
RUN chown -R $USER $HOME/userdata \ | ||
&& chmod +x $HOME/entrypoint.sh \ | ||
&& ln -snf /usr/share/zoneinfo/$TIMEZONE /etc/localtime \ | ||
&& echo $TIMEZONE > /etc/timezone | ||
|
||
# Switch to user | ||
USER $USER | ||
|
||
# Working directory | ||
WORKDIR $HOME | ||
|
||
# Set default container command | ||
ENTRYPOINT ["/bin/sh", "entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# The Sons of the Forest Dedicated Server Image | ||
Dedicated server for the Sons of the Forest. The server software is only available on Windows and therefore running with Wine in this image. | ||
|
||
## Configuration | ||
|
||
The configuration of the server can be done in the [`dedicateddedicatedserver.cfg`](config/dedicatedserver.cfg) file. The settings can be overwritten by copying a custom version to `/data/userdata/dedicatedserver.cfg` or changing the config file and rebuilding the image. | ||
|
||
|
||
### Sample compose.yml: | ||
|
||
```yaml | ||
services: | ||
sons-of-the-forest-server: | ||
image: ghcr.io/edemirkan/sons-of-the-forest-docker:latest | ||
container_name: sons_of_the_forest_server | ||
cap_add: | ||
- sys_nice | ||
volumes: | ||
- "/data/sons-of-the-forest/userdata:/forest/userdata" | ||
- "./config/dedicatedserver.cfg:/forest/userdata/dedicatedserver.cfg" | ||
- "./config/ownerswhitelist.txt:/forest/userdata/ownerswhitelist.txt" | ||
ports: | ||
- 0.0.0.0:8766:8766/udp | ||
- 0.0.0.0:27016:27016/udp | ||
- 0.0.0.0:9700:9700/udp | ||
restart: unless-stopped | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"IpAddress": "0.0.0.0", | ||
"GamePort": 8766, | ||
"QueryPort": 27016, | ||
"BlobSyncPort": 9700, | ||
"ServerName": "Sons Of The Forest Server (dedicated)", | ||
"MaxPlayers": 8, | ||
"Password": "", | ||
"LanOnly": false, | ||
"SaveSlot": 1, | ||
"SaveMode": "Continue", | ||
"GameMode": "Normal", | ||
"SaveInterval": 600, | ||
"IdleDayCycleSpeed": 0.0, | ||
"IdleTargetFramerate": 5, | ||
"ActiveTargetFramerate": 60, | ||
"LogFilesEnabled": false, | ||
"TimestampLogFilenames": true, | ||
"TimestampLogEntries": true, | ||
"GameSettings": { | ||
"Gameplay.TreeRegrowth": true, | ||
"Structure.Damage": true | ||
}, | ||
"CustomGameModeSettings": { | ||
"GameSetting.Vail.EnemySpawn": true, | ||
"GameSetting.Vail.EnemyHealth": "Normal", | ||
"GameSetting.Vail.EnemyDamage": "Normal", | ||
"GameSetting.Vail.EnemyArmour": "Normal", | ||
"GameSetting.Vail.EnemyAggression": "Normal", | ||
"GameSetting.Vail.AnimalSpawnRate": "Normal", | ||
"GameSetting.Environment.StartingSeason": "Summer", | ||
"GameSetting.Environment.SeasonLength": "Default", | ||
"Structure.Damage": "true", | ||
"GameSetting.Environment.DayLength": "Default", | ||
"GameSetting.Environment.PrecipitationFrequency": "Default", | ||
"GameSetting.Survival.ConsumableEffects": "Normal", | ||
"GameSetting.Survival.PlayerStatsDamage": "Off", | ||
"GameSetting.Survival.ColdPenalties": "Off", | ||
"GameSetting.Survival.ReducedFoodInContainers": false, | ||
"GameSetting.Survival.SingleUseContainers": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# In order to be able to administrate your server from in game directly, you will need to set up server ownership. | ||
# Add below the steam ids of every server owner, one steam id per line. | ||
# To find your SteamID, open Steam and click on your name on the top right, then go to Account Details. | ||
# You can use # to comment out a line. That can be helpful to keep track of SteamIDs, you can include their name in the line above or below, starting with a #. | ||
# Sons of the Forest Server Owner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env sh | ||
|
||
# Script variables | ||
GAME_DIR="$(pwd)" | ||
GAME_BIN="SonsOfTheForestDS.exe" | ||
GAME_USERDATA="$GAME_DIR/userdata" | ||
GAME_ARGS="-batchmode -dedicated -nographics -userdatapath $GAME_USERDATA" | ||
|
||
# Check if required files exist | ||
if [ ! -f "$GAME_BIN" ]; then | ||
echo "Error: Game binary not found: $GAME_BIN" | ||
exit 1 | ||
fi | ||
|
||
# Start the game server | ||
xvfb-run --auto-servernum --server-args="-screen 0 640x480x24:32" wine $GAME_BIN $GAME_ARGS |