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

initial proton image #42

Merged
merged 6 commits into from
Jan 31, 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
7 changes: 2 additions & 5 deletions .github/workflows/publish_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@ name: Build and push Docker image
on:
release:
types: [published]

jobs:
build-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build image
id: buildah
uses: redhat-actions/buildah-build@v2
with:
image: enshrouded-dedicated-server
context: ./container
containerfiles: ./container/Containerfile
context: ./container/wine
containerfiles: ./container/wine/Containerfile
tags: latest ${{ github.event.release.tag_name }} # Use latest and the release tag

- name: Push image to Docker Hub
uses: redhat-actions/push-to-registry@v2
with:
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/publish_proton_image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Build and push GE-Proton based image
on: workflow_dispatch
jobs:
build-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build image
id: buildah
uses: redhat-actions/buildah-build@v2
with:
image: enshrouded-dedicated-server
context: ./container/proton
containerfiles: ./container/proton/Containerfile
tags: proton-latest
- name: Push image to Docker Hub
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.buildah.outputs.image }}
tags: ${{ steps.buildah.outputs.tags }}
registry: docker.io/${{ secrets.DOCKERHUB_USERNAME }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ docker run \

### Docker Compose

To use Docker Compose, either clone this repo or copy the `compose.yaml` and the `default.env` file out of the `container` directory to your local machine. Edit the `default.env` file to change the environment variables to the values you desire and then save the changes. You should only need to edit the `compose.yaml` if you intend to change the game and query port. Once you have made your changes, from the same directory that contains the compose and the env files, simply run:
To use Docker Compose, either clone this repo or copy the `compose.yaml` file out of the `container` directory to your local machine. Edit the compose file to change the environment variables to the values you desire and then save the changes. Once you have made your changes, from the same directory that contains the compose and the env files, simply run:

```bash
docker-compose up -d
Expand All @@ -74,22 +74,19 @@ services:
ports:
- "15636:15636/udp"
- "15637:15637/udp"
env_file:
- default.env
environment:
- SERVER_NAME=Enshrouded Containerized
- SERVER_PASSWORD=PleaseChangeMe
- GAME_PORT=15636
- QUERY_PORT=15637
- SERVER_SLOTS=16
- SERVER_IP=0.0.0.0
volumes:
- enshrouded-persistent-data:/home/steam/enshrouded/savegame

volumes:
enshrouded-persistent-data:
```
default.env file:
```bash
SERVER_NAME=Enshrouded Containerized
SERVER_PASSWORD=PleaseChangeMe
GAME_PORT=15636
QUERY_PORT=15637
SERVER_SLOTS=16
SERVER_IP=0.0.0.0

```

### Podman
Expand Down
9 changes: 7 additions & 2 deletions container/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ services:
ports:
- "15636:15636/udp"
- "15637:15637/udp"
env_file:
- default.env
environment:
- SERVER_NAME=Enshrouded Containerized
- SERVER_PASSWORD=PleaseChangeMe
- GAME_PORT=15636
- QUERY_PORT=15637
- SERVER_SLOTS=16
- SERVER_IP=0.0.0.0
volumes:
- enshrouded-persistent-data:/home/steam/enshrouded/savegame

Expand Down
6 changes: 0 additions & 6 deletions container/default.env

This file was deleted.

68 changes: 68 additions & 0 deletions container/proton/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
FROM debian:12-slim

ARG CONTAINER_GID=10000
ARG CONTAINER_UID=10000

ENV DEBIAN_FRONTEND "noninteractive"
ENV STEAM_APP_ID "2278520"
ENV HOME "/home/steam"
ENV STEAM_PATH "/home/steam/Steam"
ENV ENSHROUDED_PATH "/home/steam/enshrouded"
ENV ENSHROUDED_CONFIG "${ENSHROUDED_PATH}/enshrouded_server.json"
ENV GE_PROTON_VERSION "8-30"
ENV GE_PROTON_URL "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton${GE_PROTON_VERSION}/GE-Proton${GE_PROTON_VERSION}.tar.gz"
ENV STEAM_COMPAT_CLIENT_INSTALL_PATH "$STEAM_PATH"
ENV STEAM_COMPAT_DATA_PATH "${STEAM_PATH}/steamapps/compatdata/${STEAM_APP_ID}"
ENV ULWGL_ID 0

RUN groupadd -g $CONTAINER_GID steam \
&& useradd -g $CONTAINER_GID -u $CONTAINER_UID -m steam \
&& sed -i 's#^Components: .*#Components: main non-free contrib#g' /etc/apt/sources.list.d/debian.sources \
&& echo steam steam/question select "I AGREE" | debconf-set-selections \
&& echo steam steam/license note '' | debconf-set-selections \
&& dpkg --add-architecture i386 \
&& apt-get update \
&& apt-get install --no-install-recommends -y \
procps \
ca-certificates \
winbind \
dbus \
libfreetype6 \
curl \
wget \
jq \
locales \
lib32gcc-s1 \
steamcmd \
&& ln -s /usr/games/steamcmd /usr/bin/steamcmd \
&& echo 'LANG="en_US.UTF-8"' > /etc/default/locale \
&& echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \
&& locale-gen \
&& rm -f /etc/machine-id \
&& dbus-uuidgen --ensure=/etc/machine-id \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean \
&& apt-get autoremove -y

USER steam

RUN mkdir "$ENSHROUDED_PATH" \
&& mkdir -p "${ENSHROUDED_PATH}/savegame" \
&& mkdir -p "${STEAM_PATH}/compatibilitytools.d" \
&& mkdir -p "${STEAM_PATH}/steamapps/compatdata/${STEAM_APP_ID}" \
&& mkdir -p "${HOME}/.steam" \
&& steamcmd +quit \
&& ln -s "${HOME}/.local/share/Steam/steamcmd/linux32" "${HOME}/.steam/sdk32" \
&& ln -s "${HOME}/.local/share/Steam/steamcmd/linux64" "${HOME}/.steam/sdk64" \
&& ln -s "${HOME}/.steam/sdk32/steamclient.so" "${HOME}/.steam/sdk32/steamservice.so" \
&& ln -s "${HOME}/.steam/sdk64/steamclient.so" "${HOME}/.steam/sdk64/steamservice.so" \
&& wget "$GE_PROTON_URL" -O "/home/steam/GE-Proton${GE_PROTON_VERSION}.tgz" \
&& tar -x -C "${STEAM_PATH}/compatibilitytools.d/" -f "/home/steam/GE-Proton${GE_PROTON_VERSION}.tgz" \
&& rm "/home/steam/GE-Proton${GE_PROTON_VERSION}.tgz"

COPY entrypoint.sh /home/steam/entrypoint.sh
COPY enshrouded_server_example.json /home/steam/enshrouded_server_example.json

WORKDIR /home/steam

CMD ["/home/steam/entrypoint.sh"]
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
{

"name": "Enshrouded Server",

"password": "",

"saveDirectory": "./savegame",

"logDirectory": "./logs",

"ip": "0.0.0.0",

"gamePort": 15636,

"queryPort": 15637,

"slotCount": 16

}
118 changes: 118 additions & 0 deletions container/proton/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#!/bin/bash

# Quick function to generate a timestamp
timestamp () {
date +"%Y-%m-%d %H:%M:%S,%3N"
}

# Validate arguments
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME='Enshrouded Containerized'
echo "$(timestamp) WARN: SERVER_NAME not set, using default: Enshrouded Containerized"
fi

if [ -z "$SERVER_PASSWORD" ]; then
echo "$(timestamp) ERROR: SERVER_PASSWORD not set, exitting"
exit 1
fi

if [ -z "$GAME_PORT" ]; then
GAME_PORT='15636'
echo "$(timestamp) WARN: GAME_PORT not set, using default: 15636"
fi

if [ -z "$QUERY_PORT" ]; then
QUERY_PORT='15637'
echo "$(timestamp) WARN: QUERY_PORT not set, using default: 15637"
fi

if [ -z "$SERVER_SLOTS" ]; then
SERVER_SLOTS='16'
echo "$(timestamp) WARN: SERVER_SLOTS not set, using default: 16"
fi

if [ -z "$SERVER_IP" ]; then
SERVER_IP='0.0.0.0'
echo "$(timestamp) WARN: SERVER_IP not set, using default: 0.0.0.0"
fi

# Install/Update Enshrouded
echo "$(timestamp) INFO: Updating Enshrouded Dedicated Server"
steamcmd +@sSteamCmdForcePlatformType windows +force_install_dir "$ENSHROUDED_PATH" +login anonymous +app_update ${STEAM_APP_ID} validate +quit

# Check that steamcmd was successful
if [ $? != 0 ]; then
echo "$(timestamp) ERROR: steamcmd was unable to successfully initialize and update Enshrouded"
exit 1
fi

# Copy example server config if not already present
if ! [ -f "${ENSHROUDED_PATH}/enshrouded_server.json" ]; then
echo "$(timestamp) INFO: Enshrouded server config not present, copying example"
cp /home/steam/enshrouded_server_example.json ${ENSHROUDED_PATH}/enshrouded_server.json
fi

# Check for proper save permissions
if ! touch "${ENSHROUDED_PATH}/savegame/test"; then
echo ""
echo "$(timestamp) ERROR: The ownership of /home/steam/enshrouded/savegame is not correct and the server will not be able to save..."
echo "the directory that you are mounting into the container needs to be owned by 10000:10000"
echo "from your container host attempt the following command 'chown -R 10000:10000 /your/enshrouded/folder'"
echo ""
exit 1
fi

rm "${ENSHROUDED_PATH}/savegame/test"

# Modify server config to match our arguments
echo "$(timestamp) INFO: Updating Enshrouded Server configuration"
tmpfile=$(mktemp)
jq --arg n "$SERVER_NAME" '.name = $n' ${ENSHROUDED_CONFIG} > "$tmpfile" && mv "$tmpfile" $ENSHROUDED_CONFIG
jq --arg p "$SERVER_PASSWORD" '.password = $p' ${ENSHROUDED_CONFIG} > "$tmpfile" && mv "$tmpfile" $ENSHROUDED_CONFIG
jq --arg g "$GAME_PORT" '.gamePort = ($g | tonumber)' ${ENSHROUDED_CONFIG} > "$tmpfile" && mv "$tmpfile" $ENSHROUDED_CONFIG
jq --arg q "$QUERY_PORT" '.queryPort = ($q | tonumber)' ${ENSHROUDED_CONFIG} > "$tmpfile" && mv "$tmpfile" $ENSHROUDED_CONFIG
jq --arg s "$SERVER_SLOTS" '.slotCount = ($s | tonumber)' ${ENSHROUDED_CONFIG} > "$tmpfile" && mv "$tmpfile" $ENSHROUDED_CONFIG
jq --arg i "$SERVER_IP" '.ip = $i' ${ENSHROUDED_CONFIG} > "$tmpfile" && mv "$tmpfile" $ENSHROUDED_CONFIG

# Wine talks too much and it's annoying
#export WINEDEBUG=-all

# Check that log directory exists, if not create
if ! [ -d "${ENSHROUDED_PATH}/logs" ]; then
mkdir -p "${ENSHROUDED_PATH}/logs"
fi

# Check that log file exists, if not create
if ! [ -f "${ENSHROUDED_PATH}/logs/enshrouded_server.log" ]; then
touch "${ENSHROUDED_PATH}/logs/enshrouded_server.log"
fi

# Link logfile to stdout of pid 1 so we can see logs
ln -sf /proc/1/fd/1 "${ENSHROUDED_PATH}/logs/enshrouded_server.log"

# Launch Enshrouded
echo "$(timestamp) INFO: Starting Enshrouded Dedicated Server"

${STEAM_PATH}/compatibilitytools.d/GE-Proton${GE_PROTON_VERSION}/proton run ${ENSHROUDED_PATH}/enshrouded_server.exe &

# Find pid for enshrouded_server.exe
timeout=0
while [ $timeout -lt 11 ]; do
if ps -e | grep "enshrouded_serv"; then
enshrouded_pid=$(ps -e | grep "enshrouded_serv" | awk '{print $1}')
break
elif [ $timeout -eq 10 ]; then
echo "$(timestamp) ERROR: Timed out waiting for enshrouded_server.exe to be running"
exit 1
fi
sleep 6
timeout+=1
echo "$(timestamp) INFO: Waiting for enshrouded_server.exe to be running"
done

# I don't love this but I can't use `wait` because it's not a child of our shell
tail --pid=$enshrouded_pid -f /dev/null

# If we lose our pid, exit container
echo "$(timestamp) ERROR: He's dead, Jim"
exit 1
4 changes: 2 additions & 2 deletions container/Containerfile → container/wine/Containerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:12
FROM debian:12-slim

ARG CONTAINER_GID=10000
ARG CONTAINER_UID=10000
Expand All @@ -13,7 +13,7 @@ RUN groupadd -g $CONTAINER_GID steam \
&& useradd -g $CONTAINER_GID -u $CONTAINER_UID -m steam \
&& dpkg --add-architecture i386 \
&& apt-get update \
&& apt-get install -y \
&& apt-get install --no-install-recommends -y \
ca-certificates \
curl \
wget \
Expand Down
10 changes: 10 additions & 0 deletions container/wine/enshrouded_server_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "Enshrouded Server",
"password": "",
"saveDirectory": "./savegame",
"logDirectory": "./logs",
"ip": "0.0.0.0",
"gamePort": 15636,
"queryPort": 15637,
"slotCount": 16
}
Loading