diff --git a/Dockerfile b/Dockerfile index 5768e43..8c40553 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -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 diff --git a/README.md b/README.md index bc38690..ece8d57 100644 --- a/README.md +++ b/README.md @@ -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/) @@ -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="" @@ -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) diff --git a/example.env b/example.env index 2f7bfb9..ee1adeb 100644 --- a/example.env +++ b/example.env @@ -3,4 +3,10 @@ STEAM_PASS="YourSteamPassword" BETA_CODE="SteamBetaCode" STEAM_BRANCH="headless" LOG_RETENTION="30" -ENABLE_MODS="false" \ No newline at end of file +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" diff --git a/portainer/environment-portainer-examples b/portainer/environment-portainer-examples index 60372d0..1735674 100644 --- a/portainer/environment-portainer-examples +++ b/portainer/environment-portainer-examples @@ -2,4 +2,11 @@ STEAM_USER=usernamehere STEAM_PASS=steampasswordhere BETA_CODE=betacodehere STEAM_BRANCH=headless -LOG_RETENTION=30 \ No newline at end of file +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 \ No newline at end of file diff --git a/scripts/update-resonite.sh b/scripts/update-resonite.sh index 5011bda..89a3b9d 100644 --- a/scripts/update-resonite.sh +++ b/scripts/update-resonite.sh @@ -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 @@ -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 $*