Skip to content

Commit

Permalink
Add Healthcheck (#273)
Browse files Browse the repository at this point in the history
* Added healthcheck and fixed indentation for Docker Compose in README.md

---------

Co-authored-by: Robert Thomas <[email protected]>
  • Loading branch information
dieser-niko and wolveix authored Sep 10, 2024
1 parent 59f700d commit 2b1724e
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 62 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ FROM steamcmd/steamcmd:ubuntu-18
# hadolint ignore=DL3008
RUN set -x \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y gosu xdg-user-dirs --no-install-recommends\
&& DEBIAN_FRONTEND=noninteractive apt-get install -y gosu xdg-user-dirs curl --no-install-recommends\
&& rm -rf /var/lib/apt/lists/* \
&& useradd -ms /bin/bash steam \
&& gosu nobody true

RUN mkdir -p /config \
&& chown steam:steam /config

COPY init.sh /
COPY init.sh healthcheck.sh /
COPY --chown=steam:steam *.ini run.sh /home/steam/

WORKDIR /config
Expand Down
155 changes: 96 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,31 @@
![Docker Stars](https://img.shields.io/docker/stars/wolveix/satisfactory-server)
![Image Size](https://img.shields.io/docker/image-size/wolveix/satisfactory-server)

This is a Dockerized version of the [Satisfactory](https://store.steampowered.com/app/526870/Satisfactory/) dedicated server.
This is a Dockerized version of the [Satisfactory](https://store.steampowered.com/app/526870/Satisfactory/) dedicated
server.

If the server feels too buggy for you, you can try the [saveshare](saveshare/README.md) instead (which relies on client-hosting).
If the server feels too buggy for you, you can try the [saveshare](saveshare/README.md) instead (which relies on
client-hosting).

## Setup

Recent updates consume 4GB - 6GB RAM, but [the official wiki](https://satisfactory.wiki.gg/wiki/Dedicated_servers#Requirements) recommends allocating 12GB - 16GB RAM.
Recent updates consume 4GB - 6GB RAM,
but [the official wiki](https://satisfactory.wiki.gg/wiki/Dedicated_servers#Requirements) recommends allocating 12GB -
16GB RAM.

You'll need to bind a local directory to the Docker container's `/config` directory. This directory will hold the following directories:
You'll need to bind a local directory to the Docker container's `/config` directory. This directory will hold the
following directories:

- `/backups` - the server will automatically backup your saves when the container first starts
- `/gamefiles` - this is for the game's files. They're stored outside of the container to avoid needing to redownload 8GB+ every time you want to rebuild the container
- `/overrides` - this is for custom `.ini` configuration file overrides
- `/saved` - this contains the game's blueprints, saves, and server configuration
- `/backups` - the server will automatically backup your saves when the container first starts
- `/gamefiles` - this is for the game's files. They're stored outside of the container to avoid needing to redownload
8GB+ every time you want to rebuild the container
- `/overrides` - this is for custom `.ini` configuration file overrides
- `/saved` - this contains the game's blueprints, saves, and server configuration

Before running the server image, you should find your user ID that will be running the container. This isn't necessary in most cases, but it's good to find out regardless. If you're seeing `permission denied` errors, then this is probably why. Find your ID in `Linux` by running the `id` command. Then grab the user ID (usually something like `1000`) and pass it into the `-e PGID=1000` and `-e PUID=1000` environment variables.
Before running the server image, you should find your user ID that will be running the container. This isn't necessary
in most cases, but it's good to find out regardless. If you're seeing `permission denied` errors, then this is probably
why. Find your ID in `Linux` by running the `id` command. Then grab the user ID (usually something like `1000`) and pass
it into the `-e PGID=1000` and `-e PUID=1000` environment variables.

Run the Satisfactory server image like this (this is one command, make sure to copy all of it):<br>

Expand All @@ -47,16 +56,18 @@ wolveix/satisfactory-server:latest
<summary>Explanation of the command</summary>

* `--detach` -> Starts the container detached from your terminal<br>
If you want to see the logs replace it with `--sig-proxy=false`
If you want to see the logs replace it with `--sig-proxy=false`
* `--name` -> Gives the container a unqiue name
* `--hostname` -> Changes the hostname of the container
* `--restart unless-stopped` -> Automatically restarts the container unless the container was manually stopped
* `--volume` -> Binds the Satisfactory config folder to the folder you specified
Allows you to easily access your savegames
* For the environment (`--env`) variables please see [here](https://github.com/wolveix/satisfactory-server#environment-variables)
Allows you to easily access your savegames
* For the environment (`--env`) variables please
see [here](https://github.com/wolveix/satisfactory-server#environment-variables)
* `--memory-reservation=4G` -> Reserves 4GB RAM from the host for the container's use
* `--memory 6G` -> Restricts the container to 6GB RAM
* `--publish` -> Specifies the ports that the container exposes<br>

</details>

### Docker Compose
Expand All @@ -65,37 +76,48 @@ If you're using [Docker Compose](https://docs.docker.com/compose/):

```yaml
services:
satisfactory-server:
container_name: 'satisfactory-server'
hostname: 'satisfactory-server'
image: 'wolveix/satisfactory-server:latest'
ports:
- '7777:7777/udp'
- '7777:7777/tcp'
volumes:
- './satisfactory-server:/config'
environment:
MAXPLAYERS: 4
PGID: 1000
PUID: 1000
ROOTLESS: false
STEAMBETA: false
restart: unless-stopped
deploy:
resources:
limits:
memory: 6G
reservations:
memory: 4G
satisfactory-server:
container_name: 'satisfactory-server'
hostname: 'satisfactory-server'
image: 'wolveix/satisfactory-server:latest'
ports:
- '7777:7777/udp'
- '7777:7777/tcp'
volumes:
- './satisfactory-server:/config'
environment:
- MAXPLAYERS=4
- PGID=1000
- PUID=1000
- ROOTLESS=false
- STEAMBETA=false
restart: unless-stopped
healthcheck:
test: bash /healthcheck.sh
interval: 30s
timeout: 10s
retries: 3
start_period: 120s
deploy:
resources:
limits:
memory: 6G
reservations:
memory: 4G
```
### Kubernetes
If you are running a [Kubernetes](https://kubernetes.io) cluster, we do have a [service.yaml](https://github.com/wolveix/satisfactory-server/tree/main/cluster/service.yaml) and [statefulset.yaml](https://github.com/wolveix/satisfactory-server/tree/main/cluster/statefulset.yaml) available under the [cluster](https://github.com/wolveix/satisfactory-server/tree/main/cluster) directory of this repo, along with an example [values.yaml](https://github.com/wolveix/satisfactory-server/tree/main/cluster/values.yaml) file.
If you are running a [Kubernetes](https://kubernetes.io) cluster, we do have
a [service.yaml](https://github.com/wolveix/satisfactory-server/tree/main/cluster/service.yaml)
and [statefulset.yaml](https://github.com/wolveix/satisfactory-server/tree/main/cluster/statefulset.yaml) available
under the [cluster](https://github.com/wolveix/satisfactory-server/tree/main/cluster) directory of this repo, along with
an example [values.yaml](https://github.com/wolveix/satisfactory-server/tree/main/cluster/values.yaml) file.
If you are using [Helm](https://helm.sh), you can find charts for this repo on
[ArtifactHUB](https://artifacthub.io/packages/search?ts_query_web=satisfactory&sort=relevance&page=1). The
[k8s-at-home](https://github.com/k8s-at-home/charts) helm chart for Satisfactory can be installed with the below (please see `cluster/values.yaml` for more information).
[k8s-at-home](https://github.com/k8s-at-home/charts) helm chart for Satisfactory can be installed with the below (please
see `cluster/values.yaml` for more information).

```bash
helm repo add k8s-at-home https://k8s-at-home.com/charts/
Expand Down Expand Up @@ -124,54 +146,69 @@ helm install satisfactory k8s-at-home/satisfactory -f values.yaml

## Experimental Branch

If you want to run a server for the Experimental version of the game, set the `STEAMBETA` environment variable to `true`.
If you want to run a server for the Experimental version of the game, set the `STEAMBETA` environment variable to
`true`.

## Configuration Overrides

While we've made most of the common configuration options through the `.ini` files configurable through environment variables, you may have a niche requirement that we hadn't considered or may not be used by most people. In which case, please place your version of the `.ini` file into the `/config/overrides` directory and the container will use this instead.
While we've made most of the common configuration options through the `.ini` files configurable through environment
variables, you may have a niche requirement that we hadn't considered or may not be used by most people. In which case,
please place your version of the `.ini` file into the `/config/overrides` directory and the container will use this
instead.

**Do note that doing this disables the environment variables specific to the file in question.**

## Modding

Mod support is still a little rough around the edges, but they do now work. This Docker container functions the same as a standalone installation, so you can follow the excellent technical documentation from the community [here](https://docs.ficsit.app/satisfactory-modding/latest/ForUsers/DedicatedServerSetup.html).
Mod support is still a little rough around the edges, but they do now work. This Docker container functions the same as
a standalone installation, so you can follow the excellent technical documentation from the
community [here](https://docs.ficsit.app/satisfactory-modding/latest/ForUsers/DedicatedServerSetup.html).

The container does **NOT** have an S/FTP server installed directly, as Docker images are intended to carry a single function/process. You can either SFTP into your host that houses the Satisfactory server (trivial to do if you're running Linux), or alternatively you can spin up an S/FTP server through the use of another Docker container using the Docker Compose example listed below:
The container does **NOT** have an S/FTP server installed directly, as Docker images are intended to carry a single
function/process. You can either SFTP into your host that houses the Satisfactory server (trivial to do if you're
running Linux), or alternatively you can spin up an S/FTP server through the use of another Docker container using the
Docker Compose example listed below:

```yaml
services:
# only needed for mods
sftp-server:
container_name: 'sftp-server'
image: 'atmoz/sftp:latest'
volumes:
- './satisfactory-server:/home/your-ftp-user'
ports:
- '2222:22'
# set the user and password, and the user's UID (this should match the PUID and PGID of the satisfactory-server container)
command: 'your-ftp-user:your-ftp-password:1000'
# only needed for mods
sftp-server:
container_name: 'sftp-server'
image: 'atmoz/sftp:latest'
volumes:
- './satisfactory-server:/home/your-ftp-user'
ports:
- '2222:22'
# set the user and password, and the user's UID (this should match the PUID and PGID of the satisfactory-server container)
command: 'your-ftp-user:your-ftp-password:1000'
```

With this, you'll be able to SFTP into your server and access your game files via `/home/your-ftp-user/gamefiles`.

## IPv6 Support

If you want to use IPv6, set the `SERVERIP` variable to empty or to your IPv6 address. By default, we set this to `0.0.0.0` which means that the server will bind to IPv4.
If you want to use IPv6, set the `SERVERIP` variable to empty or to your IPv6 address. By default, we set this to
`0.0.0.0` which means that the server will bind to IPv4.

## How to Improve the Multiplayer Experience

The [Satisfactory Wiki](https://satisfactory.wiki.gg/wiki/Multiplayer#Engine.ini) recommends a few config tweaks to really get the best out of multiplayer. These changes are already applied to the server, but they need to be applied to your local config too:
The [Satisfactory Wiki](https://satisfactory.wiki.gg/wiki/Multiplayer#Engine.ini) recommends a few config tweaks to
really get the best out of multiplayer. These changes are already applied to the server, but they need to be applied to
your local config too:

- Press `WIN + R`
- Enter `%localappdata%/FactoryGame/Saved/Config/WindowsNoEditor`
- Copy the config data from the wiki into the respective files
- Right-click each of the 3 config files (Engine.ini, Game.ini, Scalability.ini)
- Go to Properties > tick Read-only under the attributes
- Press `WIN + R`
- Enter `%localappdata%/FactoryGame/Saved/Config/WindowsNoEditor`
- Copy the config data from the wiki into the respective files
- Right-click each of the 3 config files (Engine.ini, Game.ini, Scalability.ini)
- Go to Properties > tick Read-only under the attributes

## Known Issues

- The container is run as `root`. This is pretty common for Docker images, but is bad practice for security reasons. This change was made to address [permissions issues](https://github.com/wolveix/satisfactory-server/issues/44)
- The server log will show various errors; most of which can be safely ignored. As long as the container continues to run and your log looks similar to the example log, the server should be functioning just fine: [example log](https://github.com/wolveix/satisfactory-server/blob/main/server.log)
- The container is run as `root`. This is pretty common for Docker images, but is bad practice for security reasons.
This change was made to address [permissions issues](https://github.com/wolveix/satisfactory-server/issues/44)
- The server log will show various errors; most of which can be safely ignored. As long as the container continues to
run and your log looks similar to the example log, the server should be functioning just
fine: [example log](https://github.com/wolveix/satisfactory-server/blob/main/server.log)

## Star History

Expand Down
8 changes: 7 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ services:
- ROOTLESS=false
- STEAMBETA=false
restart: unless-stopped
healthcheck:
test: bash /healthcheck.sh
interval: 30s
timeout: 10s
retries: 3
start_period: 120s
deploy:
resources:
limits:
memory: 6G
reservations:
memory: 4G
memory: 4G
6 changes: 6 additions & 0 deletions healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

curl -k -f -X POST "https://127.0.0.1:${SERVERGAMEPORT}/api/v1" \
-H "Content-Type: application/json" \
-d '{"function":"HealthCheck","data":{"clientCustomData":""}}' \
| grep -q '{"data":{"health":"healthy"'

0 comments on commit 2b1724e

Please sign in to comment.