From 2c501ac5ab3f310913362ead519c2d663af107fa Mon Sep 17 00:00:00 2001 From: bredo Date: Thu, 18 Jul 2024 12:17:54 +1200 Subject: [PATCH 01/10] enhancement: change STOPSIGNAL --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index 14706ea..8c99428 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,4 +23,7 @@ WORKDIR /home/container COPY ./entrypoint.sh /entrypoint.sh COPY ./scripts /scripts + +STOPSIGNAL SIGINT + CMD [ "/bin/bash", "/entrypoint.sh" ] From 83a6d8a054737dd15b80fabc82eb38e90ec59315 Mon Sep 17 00:00:00 2001 From: bredo Date: Thu, 18 Jul 2024 12:18:30 +1200 Subject: [PATCH 02/10] temp: gh workflow change to build nice-shutdown --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 4c6392f..bf71b20 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -4,7 +4,7 @@ on: schedule: - cron: '24 1 * * 1' push: - branches: [ "main" ] + branches: [ "nice-shutdown" ] paths: - 'scripts/**' - 'Dockerfile' From 1d7c7b34b2b88d7f6f70c1eee607206c865b2537 Mon Sep 17 00:00:00 2001 From: bredo Date: Thu, 18 Jul 2024 12:25:15 +1200 Subject: [PATCH 03/10] enhancement: use exec to run headless --- scripts/launch-resonite.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/launch-resonite.sh b/scripts/launch-resonite.sh index baedf0c..cf5b6ee 100644 --- a/scripts/launch-resonite.sh +++ b/scripts/launch-resonite.sh @@ -7,7 +7,7 @@ find /Logs -type f -name *.log -atime +${LOG_RETENTION:-30} -delete cd /home/container/Headless/net8.0 if [ "${ENABLE_MODS}" = "true" ]; then - dotnet Resonite.dll -HeadlessConfig /Config/${CONFIG_FILE} -Logs /Logs/ -LoadAssembly Libraries/ResoniteModLoader.dll ${ADDITIONAL_ARGUMENTS} + exec dotnet Resonite.dll -HeadlessConfig /Config/${CONFIG_FILE} -Logs /Logs/ -LoadAssembly Libraries/ResoniteModLoader.dll ${ADDITIONAL_ARGUMENTS} else - dotnet Resonite.dll -HeadlessConfig /Config/${CONFIG_FILE} -Logs /Logs/ ${ADDITIONAL_ARGUMENTS} + exec dotnet Resonite.dll -HeadlessConfig /Config/${CONFIG_FILE} -Logs /Logs/ ${ADDITIONAL_ARGUMENTS} fi From 510ae085e9fb48bb184a42e1023e5a70fff8aa7f Mon Sep 17 00:00:00 2001 From: bredo Date: Thu, 18 Jul 2024 12:30:10 +1200 Subject: [PATCH 04/10] entrypoint: exec shell scripts --- entrypoint.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index c8d2993..f86a597 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,5 @@ #!/bin/bash -sh /scripts/setup-steamcmd.sh -sh /scripts/update-resonite.sh -sh /scripts/launch-resonite.sh +exec sh /scripts/setup-steamcmd.sh +exec sh /scripts/update-resonite.sh +exec sh /scripts/launch-resonite.sh From 6501750feaa624538d4851e9d5cb203bbe75c788 Mon Sep 17 00:00:00 2001 From: bredo Date: Thu, 18 Jul 2024 12:34:03 +1200 Subject: [PATCH 05/10] dockerfile: change to ENTRYPOINT --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8c99428..d9e516f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,6 +24,8 @@ WORKDIR /home/container COPY ./entrypoint.sh /entrypoint.sh COPY ./scripts /scripts +RUN chmod +x /entrypoint.sh + STOPSIGNAL SIGINT -CMD [ "/bin/bash", "/entrypoint.sh" ] +ENTRYPOINT ["/entrypoint.sh"] From 0a3b9f3fe7e3e3fdd46885054c3f3c3667f2a154 Mon Sep 17 00:00:00 2001 From: bredo Date: Thu, 18 Jul 2024 12:35:08 +1200 Subject: [PATCH 06/10] dockerfile: move copy operations to before user swap --- Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index d9e516f..1d54edd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,11 @@ RUN apt update \ && apt install curl lib32gcc-s1 libfreetype6 -y \ && useradd -m -d /home/container -s /bin/bash container +COPY ./entrypoint.sh /entrypoint.sh +COPY ./scripts /scripts + +RUN chmod +x /entrypoint.sh + RUN mkdir /Logs \ && chown -R container:container /Logs @@ -21,11 +26,6 @@ ENV DEBIAN_FRONTEND=noninteractive WORKDIR /home/container -COPY ./entrypoint.sh /entrypoint.sh -COPY ./scripts /scripts - -RUN chmod +x /entrypoint.sh - STOPSIGNAL SIGINT ENTRYPOINT ["/entrypoint.sh"] From e4bfacfbf891554e3362ddf78e33c346f47215d5 Mon Sep 17 00:00:00 2001 From: bredo Date: Thu, 18 Jul 2024 13:19:21 +1200 Subject: [PATCH 07/10] cleanup: remove entrypoint.sh --- entrypoint.sh | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100644 index f86a597..0000000 --- a/entrypoint.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -exec sh /scripts/setup-steamcmd.sh -exec sh /scripts/update-resonite.sh -exec sh /scripts/launch-resonite.sh From 81cf436c51d4b81948e72f1fa3abbe9b361160a4 Mon Sep 17 00:00:00 2001 From: bredo Date: Thu, 18 Jul 2024 13:25:22 +1200 Subject: [PATCH 08/10] enhancement: resonite headless shuts down gracefully now --- Dockerfile | 6 +++--- scripts/launch-resonite.sh | 2 ++ scripts/setup-steamcmd.sh | 6 ------ scripts/update-resonite.sh | 9 +++++++++ 4 files changed, 14 insertions(+), 9 deletions(-) delete mode 100755 scripts/setup-steamcmd.sh diff --git a/Dockerfile b/Dockerfile index 1d54edd..a9a63d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,10 +7,9 @@ RUN apt update \ && apt install curl lib32gcc-s1 libfreetype6 -y \ && useradd -m -d /home/container -s /bin/bash container -COPY ./entrypoint.sh /entrypoint.sh COPY ./scripts /scripts -RUN chmod +x /entrypoint.sh +RUN chmod +x /scripts/* RUN mkdir /Logs \ && chown -R container:container /Logs @@ -28,4 +27,5 @@ WORKDIR /home/container STOPSIGNAL SIGINT -ENTRYPOINT ["/entrypoint.sh"] +ENTRYPOINT ["/scripts/update-resonite.sh"] +CMD ["/scripts/launch-resonite.sh"] diff --git a/scripts/launch-resonite.sh b/scripts/launch-resonite.sh index cf5b6ee..2c2c0ba 100644 --- a/scripts/launch-resonite.sh +++ b/scripts/launch-resonite.sh @@ -1,5 +1,7 @@ #!/bin/sh +echo FUCK! + rm -r /home/container/Headless/Data rm -r /home/container/Headless/Cache find /Logs -type f -name *.log -atime +${LOG_RETENTION:-30} -delete diff --git a/scripts/setup-steamcmd.sh b/scripts/setup-steamcmd.sh deleted file mode 100755 index 3de4f8a..0000000 --- a/scripts/setup-steamcmd.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -echo Installing steamcmd -mkdir -p /home/container/steamcmd -curl -sSL -o /tmp/steamcmd.tar.gz https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz -tar -xf /tmp/steamcmd.tar.gz --directory /home/container/steamcmd diff --git a/scripts/update-resonite.sh b/scripts/update-resonite.sh index 4013a63..5011bda 100644 --- a/scripts/update-resonite.sh +++ b/scripts/update-resonite.sh @@ -1,5 +1,12 @@ #!/bin/sh +if [ ! -d "/home/container/steamcmd" ]; then + echo Installing steamcmd + mkdir -p /home/container/steamcmd + curl -sSL -o /tmp/steamcmd.tar.gz https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz + tar -xf /tmp/steamcmd.tar.gz --directory /home/container/steamcmd +fi + HEADLESS_DIRECTORY="/home/container/Headless/net8.0" /home/container/steamcmd/steamcmd.sh +login ${STEAM_USER} ${STEAM_PASS} +force_install_dir /home/container +app_update 2519830 -beta ${STEAM_BRANCH} -betapassword ${BETA_CODE} +quit @@ -23,3 +30,5 @@ if [ "${ENABLE_MODS}" = "true" ]; then curl -SslL https://github.com/resonite-modding-group/ResoniteModLoader/releases/latest/download/ResoniteModLoader.dll -o ${HEADLESS_DIRECTORY}/Libraries/ResoniteModLoader.dll fi + +exec $* From dd911654aa0e52f9571f5e3cf62f3a1a6ba757a4 Mon Sep 17 00:00:00 2001 From: bredo Date: Thu, 18 Jul 2024 13:26:47 +1200 Subject: [PATCH 09/10] github: revert changes to workflow --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index bf71b20..4c6392f 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -4,7 +4,7 @@ on: schedule: - cron: '24 1 * * 1' push: - branches: [ "nice-shutdown" ] + branches: [ "main" ] paths: - 'scripts/**' - 'Dockerfile' From 6fcba69b668d59b1eaa3b87c619c0a9b6c2dae7d Mon Sep 17 00:00:00 2001 From: bredo Date: Thu, 18 Jul 2024 13:27:09 +1200 Subject: [PATCH 10/10] launch-resonite: remove debug message --- scripts/launch-resonite.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/launch-resonite.sh b/scripts/launch-resonite.sh index 2c2c0ba..cf5b6ee 100644 --- a/scripts/launch-resonite.sh +++ b/scripts/launch-resonite.sh @@ -1,7 +1,5 @@ #!/bin/sh -echo FUCK! - rm -r /home/container/Headless/Data rm -r /home/container/Headless/Cache find /Logs -type f -name *.log -atime +${LOG_RETENTION:-30} -delete