Skip to content

Commit

Permalink
Merge pull request #10 from sveken/main
Browse files Browse the repository at this point in the history
Add git support for config and mod files.
  • Loading branch information
bredo228 authored Jul 28, 2024
2 parents 224b5dd + 8f48836 commit ad04da1
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 8 deletions.
13 changes: 8 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
FROM ghcr.io/voxelbonecloud/debian-dotnet:main

LABEL author="Voxel Bone Cloud" maintainer="github@voxelbone.cloud"
LABEL org.opencontainers.image.source https://github.com/voxelbonecloud/headless-docker
LABEL org.opencontainers.image.description "Docker image based on Debian Bookworm Slim image with dotnet8 for hosting Resonite Headless servers. Supports automatic modding of the Headless."
LABEL org.opencontainers.image.licenses MIT-0
LABEL org.opencontainers.image.authors "Voxel Bone Cloud"
LABEL org.opencontainers.image.source=https://github.com/voxelbonecloud/headless-docker
LABEL org.opencontainers.image.description="Docker image based on Debian Bookworm Slim image with dotnet8 for hosting Resonite Headless servers. Supports automatic modding of the Headless."
LABEL org.opencontainers.image.licenses=MIT-0
LABEL org.opencontainers.image.authors="Voxel Bone Cloud"

RUN apt update \
&& dpkg --add-architecture i386 \
&& apt install curl lib32gcc-s1 libfreetype6 -y \
&& apt install curl git lib32gcc-s1 libfreetype6 -y \
&& useradd -m -d /home/container -s /bin/bash container

COPY ./scripts /scripts
Expand All @@ -18,6 +18,9 @@ RUN chmod +x /scripts/*
RUN mkdir /Logs \
&& chown -R container:container /Logs

RUN mkdir /Config \
&& chown -R container:container /Config

RUN mkdir -p /RML /RML/rml_mods /RML/rml_libs /RML/rml_config \
&& chown -R container:container /RML
USER container
Expand Down
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Resonite Headless

Docker image based on Debian Bookworm Slim image with dotnet8 for hosting Resonite Headless servers. Supports automatic modding of the Headless.
Docker image based on Debian Bookworm Slim image with dotnet8 for hosting Resonite Headless servers. Supports automatic modding of the Headless and updating config and mod files from git repos.

You can find examples for Portainer deployments in the [Portainer folder](portainer/)

Expand Down Expand Up @@ -51,16 +51,28 @@ volumes:

The environment variables supported by this can be found in [example.env](example.env). Otherwise, they can be found below:

Required variables
```
STEAM_USER="YourSteamUsername"
STEAM_PASS="YourSteamPassword"
BETA_CODE="SteamBetaCode"
STEAM_BRANCH="headless"
```
Optional variables
```
LOG_RETENTION="30"
ENABLE_GIT_CONFIG="false"
ENABLE_GIT_MODS="false"
GIT_URL="URL"
GIT_REPOSITORY_PRIVATE="false"
GIT_USERNAME="username"
GIT_ACCESS_TOKEN="ACCESS-TOKEN"
KEEP_IN_SYNC="false"
```

LOG_RETENTION will default to 30 days if left unset or removed.


```
CONFIG_FILE="Config.json"
ADDITIONAL_ARGUMENTS=""
Expand Down Expand Up @@ -89,3 +101,10 @@ By default containers have no resource limits and will consume as much cpu and m
To enable mods, change the environment variable `ENABLE_MODS` to true.

Copy your mod files into the corresponding folders inside the RML volume. Read our [Modding section](modding) for more info and how to use

## Enable Repo Sync
On startup this headless can be configured to pull new or updated config files and mod files from Public/Private Git repos such as github. This allows you to move compose files around to different hosts easily, or quickly scale up additional headless with set configs or mods.

Additionally it allows easy tracking of changes and potentially make multi user access easier depending on your setup. The Headless just needs to be restarted for changes to be pulled down.

To configure this please visit the example template repo [found here](https://github.com/sveken/Headless-repo-template)
8 changes: 7 additions & 1 deletion example.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ STEAM_PASS="YourSteamPassword"
BETA_CODE="SteamBetaCode"
STEAM_BRANCH="headless"
LOG_RETENTION="30"
ENABLE_MODS="false"
ENABLE_GIT_CONFIG="false"
ENABLE_GIT_MODS="false"
GIT_URL="URL"
GIT_REPOSITORY_PRIVATE="false"
GIT_USERNAME="username"
GIT_ACCESS_TOKEN="ACCESS-TOKEN"
KEEP_IN_SYNC="false"
9 changes: 8 additions & 1 deletion portainer/environment-portainer-examples
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@ STEAM_USER=usernamehere
STEAM_PASS=steampasswordhere
BETA_CODE=betacodehere
STEAM_BRANCH=headless
LOG_RETENTION=30
LOG_RETENTION=30
ENABLE_GIT_CONFIG=false
ENABLE_GIT_MODS=false
GIT_URL=URL
GIT_REPOSITORY_PRIVATE=false
GIT_USERNAME=username
GIT_ACCESS_TOKEN=ACCESS-TOKEN
KEEP_IN_SYNC=false
51 changes: 51 additions & 0 deletions scripts/update-resonite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ HEADLESS_DIRECTORY="/home/container/Headless/net8.0"

#Mod installation if ENABLE_MODS is true. Heavily inspired and pulled from work by Spex. Thank you
if [ "${ENABLE_MODS}" = "true" ]; then
echo "Modding Headless files"

# Create Libraries directory for RML to live in
mkdir -p ${HEADLESS_DIRECTORY}/Libraries
Expand All @@ -31,4 +32,54 @@ if [ "${ENABLE_MODS}" = "true" ]; then

fi

#Pull github/git repository into staging folder if either ENABLE_GITPULL_CONFIG or ENABLE_GITPULL_MODS is set to true
if [ "${ENABLE_GITPULL_CONFIG}" = "true" ] || ["${ENABLE_GITPULL_MODS}" = "true" ]; then
#Make the Staging folder for pulling down the repository
mkdir -p /home/container/gitstaging
cd /home/container/gitstaging
if [ "${GIT_REPOSITORY_PRIVATE}" = "true" ]; then
if [ -d ".git" ]; then
# Pull Latest changes if repository already cloned
git pull https://${GIT_USERNAME}:${GIT_ACCESS_TOKEN}@${GIT_URL#https://}
echo "Repo has been pulled"
else
#If no existing files clone into staging directory. Keep the . at the end plz.
git clone https://${GIT_USERNAME}:${GIT_ACCESS_TOKEN}@${GIT_URL#https://} .
echo "Repo has been cloned"
fi
else
if [ -d ".git" ]; then
# Pull Latest changes if repository already cloned
git pull "${GIT_URL}"
echo "Repo has been pulled"
else
#If no existing files clone into staging directory
git clone "${GIT_URL}" .
echo "Repo has been cloned"
fi
fi
fi

#If KEEP_IN_SYNC is true. The rml_mods, rml_config and the main /Config Folder will be wiped before coping the repo files. This ensures no additional files are added or kept.
#For example if you manually added a config file directly. This would be removed so everything is in sync with the repo.
if [ "${KEEP_IN_SYNC}" = "true" ]; then
rm -r /Config/*
rm -r ${HEADLESS_DIRECTORY}/rml_config/*
rm -r ${HEADLESS_DIRECTORY}/rml_mods/*
echo "Deleted old files to stay in sync"
fi
#Copy Config files from git staging folder into /Config if ENABLE_GITPULL_CONFIG is true
if [ "${ENABLE_GITPULL_CONFIG}" = "true" ]; then
cp -r config/*.json /Config
echo "Config File copied from git staging folder"
fi

#Copy Mod files from git staging folder into correct folders if ENABLE_GITPULL_MODS is true and modding is enabled.
if [ "${ENABLE_GITPULL_MODS}" = "true" ] && [ "${ENABLE_MODS}" = "true" ]; then
cp -r rml_mods/* ${HEADLESS_DIRECTORY}/rml_mods
cp -r rml_config/* ${HEADLESS_DIRECTORY}/rml_config
cp -r rml_libs/* ${HEADLESS_DIRECTORY}/rml_libs
echo "Mod files copied from git staging folder"
fi

exec $*

0 comments on commit ad04da1

Please sign in to comment.