Skip to content

Commit

Permalink
Merge pull request #62 from Diyagi/patch-1
Browse files Browse the repository at this point in the history
Refactor and improvements
  • Loading branch information
arguser authored Nov 1, 2024
2 parents c740975 + 7e11af1 commit 4feea26
Show file tree
Hide file tree
Showing 15 changed files with 435 additions and 187 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ensure the scripts use LF line endings, not CRLF
*.sh text eol=lf
1 change: 1 addition & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
external-sources=true
101 changes: 63 additions & 38 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,82 @@ FROM cm2network/steamcmd:root

LABEL maintainer="[email protected]"

ENV STEAMAPPID 1007
ENV STEAMAPPID_TOOL 1963720
ENV STEAMAPP core-keeper
ENV STEAMAPPDIR "${HOMEDIR}/${STEAMAPP}-dedicated"
ENV STEAMAPPDATADIR "${HOMEDIR}/${STEAMAPP}-data"
ENV DLURL https://raw.githubusercontent.com/escapingnetwork/core-keeper-dedicated

COPY ./entry.sh ${HOMEDIR}/entry.sh
COPY ./launch.sh ${HOMEDIR}/launch.sh
ENV STEAMAPPID=1007
ENV STEAMAPPID_TOOL=1963720
ENV STEAMAPP=core-keeper
ENV STEAMAPPDIR="${HOMEDIR}/${STEAMAPP}-dedicated"
ENV STEAMAPPDATADIR="${HOMEDIR}/${STEAMAPP}-data"
ENV SCRIPTSDIR="${HOMEDIR}/scripts"
ENV MODSDIR="${STEAMAPPDATADIR}/StreamingAssets/Mods"
ENV DLURL=https://raw.githubusercontent.com/escapingnetwork/core-keeper-dedicated

RUN dpkg --add-architecture i386

# Install Core Keeper server dependencies and clean up
# libx32gcc-s1 lib32gcc-s1 build-essential <- fixes tile generation bug (obsidian wall around spawn) without graphic cards mounted to server
# need all 3 + dpkg i do not know why but every other combination would run the server at an extreme speed - that combination worked for me.
# Thanks to https://www.reddit.com/r/CoreKeeperGame/comments/uym86p/comment/iays04w/?utm_source=share&utm_medium=web2x&context=3
RUN set -x \
&& apt-get update \
&& apt-get install -y --no-install-recommends --no-install-suggests \
xvfb mesa-utils libx32gcc-s1 lib32gcc-s1 build-essential libxi6 x11-utils tini \
&& mkdir -p "${STEAMAPPDIR}" \
&& mkdir -p "${STEAMAPPDATADIR}" \
&& chmod +x "${HOMEDIR}/entry.sh" \
&& chmod +x "${HOMEDIR}/launch.sh" \
&& chown -R "${USER}:${USER}" "${HOMEDIR}/entry.sh" "${HOMEDIR}/launch.sh" "${STEAMAPPDIR}" "${STEAMAPPDATADIR}" \
&& rm -rf /var/lib/apt/lists/*
&& apt-get update \
&& apt-get install -y --no-install-recommends --no-install-suggests \
xvfb \
libxi6 \
tini \
tzdata \
gosu \
jo \
gettext-base \
&& rm -rf /var/lib/apt/lists/*

# Setup X11 Sockets folder
RUN mkdir /tmp/.X11-unix \
&& chown -R "${USER}:${USER}" /tmp/.X11-unix

&& chmod 1777 /tmp/.X11-unix \
&& chown root /tmp/.X11-unix

ENV WORLD_INDEX=0 \
WORLD_NAME="Core Keeper Server" \
WORLD_SEED=0 \
WORLD_MODE=0 \
GAME_ID="" \
DATA_PATH="${STEAMAPPDATADIR}" \
MAX_PLAYERS=10 \
SEASON=-1 \
SERVER_IP="" \
SERVER_PORT=""
# Setup folders
COPY ./scripts ${SCRIPTSDIR}
RUN set -x \
&& chmod +x -R "${SCRIPTSDIR}" \
&& mkdir -p "${STEAMAPPDIR}" \
&& mkdir -p "${STEAMAPPDATADIR}" \
&& chown -R "${USER}:${USER}" "${SCRIPTSDIR}" "${STEAMAPPDIR}" "${STEAMAPPDATADIR}"

# Switch to user
USER ${USER}
# Declare envs and their default values
ENV PUID=1000 \
PGID=1000 \
WORLD_INDEX=0 \
WORLD_NAME="Core Keeper Server" \
WORLD_SEED=0 \
WORLD_MODE=0 \
GAME_ID="" \
DATA_PATH="${STEAMAPPDATADIR}" \
MAX_PLAYERS=10 \
SEASON="" \
SERVER_IP="" \
SERVER_PORT="" \
DISCORD_WEBHOOK_URL="" \
# Player Join
DISCORD_PLAYER_JOIN_ENABLED=true \
DISCORD_PLAYER_JOIN_MESSAGE='${char_name} (${steamid}) has joined the server.' \
DISCORD_PLAYER_JOIN_TITLE="Player Joined" \
DISCORD_PLAYER_JOIN_COLOR="47456" \
# Player Leave
DISCORD_PLAYER_LEAVE_ENABLED=true \
DISCORD_PLAYER_LEAVE_MESSAGE='${char_name} (${steamid}) has disconnected. Reason: ${reason}.' \
DISCORD_PLAYER_LEAVE_TITLE="Player Left" \
DISCORD_PLAYER_LEAVE_COLOR="11477760" \
# Server Start
DISCORD_SERVER_START_ENABLED=true \
DISCORD_SERVER_START_MESSAGE='**World:** ${world_name}\n**GameID:** ${gameid}' \
DISCORD_SERVER_START_TITLE="Server Started" \
DISCORD_SERVER_START_COLOR="2013440" \
# Server Stop
DISCORD_SERVER_STOP_ENABLED=true \
DISCORD_SERVER_STOP_MESSAGE="" \
DISCORD_SERVER_STOP_TITLE="Server Stopped" \
DISCORD_SERVER_STOP_COLOR="12779520"

# Switch to workdir
WORKDIR ${HOMEDIR}

VOLUME ${STEAMAPPDIR}

# Use tini as the entrypoint for signal handling
ENTRYPOINT ["/usr/bin/tini", "--"]

CMD ["bash", "entry.sh"]
CMD ["bash", "scripts/entry.sh"]
91 changes: 64 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ Create two directories where you want to run your server :
### Using Docker Compose
Create a `docker-compose.yml` with the following content:

```
version: "3"
```yml
services:
core-keeper:
container_name: core-keeper-dedicated
Expand All @@ -45,19 +43,40 @@ volumes:
```
Create a `core.env` file, it should contain the environment variables for the dedicated server, see configuration for reference. Example:
```
```env
PUID=1000
PGID=1000
WORLD_INDEX=0
WORLD_NAME=Core Keeper Server
WORLD_NAME="Core Keeper Server"
WORLD_SEED=0
WORLD_MODE=0
GAME_ID=
DATA_PATH=/home/steam/core-keeper-data
GAME_ID=""
DATA_PATH="${STEAMAPPDATADIR}"
MAX_PLAYERS=10
DISCORD=1
DISCORD_HOOK=https://discord.com/api/webhooks/{id}/{token}
SEASON=-1
SERVER_IP=
SERVER_PORT=
SEASON=""
SERVER_IP=""
SERVER_PORT=""
DISCORD_WEBHOOK_URL=""
# Player Join
DISCORD_PLAYER_JOIN_ENABLED=true
DISCORD_PLAYER_JOIN_MESSAGE="$${char_name} ($${steamid}) has joined the server."
DISCORD_PLAYER_JOIN_TITLE="Player Joined"
DISCORD_PLAYER_JOIN_COLOR="47456"
# Player Leave
DISCORD_PLAYER_LEAVE_ENABLED=true
DISCORD_PLAYER_LEAVE_MESSAGE="$${char_name} ($${steamid}) has disconnected. Reason: $${reason}."
DISCORD_PLAYER_LEAVE_TITLE="Player Left"
DISCORD_PLAYER_LEAVE_COLOR="11477760"
# Server Start
DISCORD_SERVER_START_ENABLED=true
DISCORD_SERVER_START_MESSAGE="**World:** $${world_name}\n**GameID:** $${gameid}"
DISCORD_SERVER_START_TITLE="Server Started"
DISCORD_SERVER_START_COLOR="2013440"
# Server Stop
DISCORD_SERVER_STOP_ENABLED=true
DISCORD_SERVER_STOP_MESSAGE=""
DISCORD_SERVER_STOP_TITLE="Server Stopped"
DISCORD_SERVER_STOP_COLOR="12779520"
```

On the folder which contains the files run `docker-compose up -d`.
Expand All @@ -70,21 +89,39 @@ To query the game ID run:
## Configuration

These are the arguments you can use to customize server behavior with default values.
```
WORLD_INDEX Which world index to use.
WORLD_NAME The name to use for the server.
WORLD_SEED The seed to use for a new world. Set to 0 to generate random seed.
WORLD_MODE Sets the world mode for the world. Can be Normal (0), Hard (1), Creative (2), Casual (4). NOTE: Changing between Creative and non-Creative worlds not currently supported.
GAME_ID Game ID to use for the server. Need to be at least 28 characters and alphanumeric, excluding Y,y,x,0,O. Empty or not valid means a new ID will be generated at start.
DATA_PATH Save file location. If not set it defaults to a sub-folder named "DedicatedServer" at the default Core Keeper save location.
MAX_PLAYERS Maximum number of players that will be allowed to connect to server.
DISCORD Enables discord webhook features which sends GameID to a channel.
DISCORD_HOOK Webhook url (Edit channel > Integrations > Create Webhook).
DISCORD_PRINTF_STR The format string used to generate the content of the Discord webook. Default is `%s`, simply sending the GameID.
SEASON Overrides current season by setting to any of None (0), Easter (1), Halloween (2), Christmas (3), Valentine (4), Anniversary (5), CherryBlossom (6), LunarNewYear(7). -1 is default setting where it is set depending on system date.
SERVER_IP Only used if port is set. Sets the address that the server will bind to.
SERVER_PORT What port to bind to. If not set, then the server will use the Steam relay network. If set the clients will connect to the server directly and the port needs to be open.
```

| Argument | Default | Description |
| :---: | :---: | :---: |
| PUID | 1000 | The user ID on the host that the container should use for file ownership and permissions. |
| PGID | 1000 | The group ID on the host that the container should use for file ownership and permissions. |
| WORLD_INDEX | 0 | Which world index to use. |
| WORLD_NAME | "Core Keeper Server" | The name to use for the server. |
| WORLD_SEED | 0 | The seed to use for a new world. Set to 0 to generate random seed. |
| WORLD_MODE | 0 | Sets the world mode for the world. Can be Normal (0), Hard (1), Creative (2), Casual (4). |
| SEASON | No Default | Overrides current season by setting to any of None (0), Easter (1), Halloween (2), Christmas (3), Valentine (4), Anniversary (5), CherryBlossom (6), LunarNewYear(7).<br/>**Do not set this env var if you want real date season.** |
| GAME_ID | "" | Game ID to use for the server. Need to be at least 28 characters and alphanumeric, excluding Y,y,x,0,O. Empty or not valid means a new ID will be generated at start. |
| MAX_PLAYERS | 10 | Maximum number of players that will be allowed to connect to server. |
| DATA_PATH | "/home/steam/core-keeper-data" | Save file location. |
| SERVER_IP | No Default | Only used if port is set. Sets the address that the server will bind to. |
| SERVER_PORT | No Default | What port to bind to. If not set, then the server will use the Steam relay network. If set the clients will connect to the server directly and the port needs to be open. |
| DISCORD_WEBHOOK_URL | "" | Webhook url (Edit channel > Integrations > Create Webhook). |
| DISCORD_PLAYER_JOIN_ENABLED | true | Enable/Disable message on player join |
| DISCORD_PLAYER_JOIN_MESSAGE | `"$${char_name} ($${steamid}) has joined the server."` | Embed message |
| DISCORD_PLAYER_JOIN_TITLE | "Player Joined" | Embed title |
| DISCORD_PLAYER_JOIN_COLOR | "47456" | Embed color |
| DISCORD_PLAYER_LEAVE_ENABLED | true | Enable/Disable message on player leave |
| DISCORD_PLAYER_LEAVE_MESSAGE | `"$${char_name} ($${steamid}) has disconnected. Reason: $${reason}."` | Embed message |
| DISCORD_PLAYER_LEAVE_TITLE | "Player Left" | Embed title |
| DISCORD_PLAYER_LEAVE_COLOR | "11477760" | Embed color |
| DISCORD_SERVER_START_ENABLED | true | Enable/Disable message on server start |
| DISCORD_SERVER_START_MESSAGE | `"**World:** $${world_name}\n**GameID:** $${gameid}"` | Embed message |
| DISCORD_SERVER_START_TITLE | "Server Started" | Embed title |
| DISCORD_SERVER_START_COLOR | "2013440" | Embed color |
| DISCORD_SERVER_STOP_ENABLED | true | Enable/Disable message on server stop |
| DISCORD_SERVER_STOP_MESSAGE | "" | Embed message |
| DISCORD_SERVER_STOP_TITLE | "Server Stopped" | Embed title |
| DISCORD_SERVER_STOP_COLOR | "12779520" | Embed color |


### Contributors
<a href="https://github.com/escapingnetwork/core-keeper-dedicated/graphs/contributors">
Expand Down
36 changes: 30 additions & 6 deletions docker-compose-example/core.env
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
GAME_ID=
PUID=1000
PGID=1000
WORLD_INDEX=0
WORLD_NAME=Core Keeper Server
WORLD_NAME="Core Keeper Server"
WORLD_SEED=0
WORLD_MODE=0
GAME_ID=""
DATA_PATH="${STEAMAPPDATADIR}"
MAX_PLAYERS=10
DATA_PATH=/home/steam/core-keeper-data
DISCORD=1
DISCORD_HOOK=https://discord.com/api/webhooks/id/token
SEASON=0
SEASON=""
SERVER_IP=""
SERVER_PORT=""
DISCORD_WEBHOOK_URL=""
# Player Join
DISCORD_PLAYER_JOIN_ENABLED=true
DISCORD_PLAYER_JOIN_MESSAGE="$${char_name} ($${steamid}) has joined the server."
DISCORD_PLAYER_JOIN_TITLE="Player Joined"
DISCORD_PLAYER_JOIN_COLOR="47456"
# Player Leave
DISCORD_PLAYER_LEAVE_ENABLED=true
DISCORD_PLAYER_LEAVE_MESSAGE="$${char_name} ($${steamid}) has disconnected. Reason: $${reason}."
DISCORD_PLAYER_LEAVE_TITLE="Player Left"
DISCORD_PLAYER_LEAVE_COLOR="11477760"
# Server Start
DISCORD_SERVER_START_ENABLED=true
DISCORD_SERVER_START_MESSAGE="**World:** $${world_name}\n**GameID:** $${gameid}"
DISCORD_SERVER_START_TITLE="Server Started"
DISCORD_SERVER_START_COLOR="2013440"
# Server Stop
DISCORD_SERVER_STOP_ENABLED=true
DISCORD_SERVER_STOP_MESSAGE=""
DISCORD_SERVER_STOP_TITLE="Server Stopped"
DISCORD_SERVER_STOP_COLOR="12779520"
2 changes: 0 additions & 2 deletions docker-compose-example/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3"

services:
core-keeper:
container_name: core-keeper-dedicated
Expand Down
15 changes: 0 additions & 15 deletions entry.sh

This file was deleted.

Loading

0 comments on commit 4feea26

Please sign in to comment.