From 6aefa6c26cf69a61a644e498ac54df36ae4c3b33 Mon Sep 17 00:00:00 2001 From: Spencer Hughes <16389711+spencerhughes@users.noreply.github.com> Date: Wed, 1 Dec 2021 18:51:59 -0500 Subject: [PATCH 1/4] Adds the ability to change the uid and gid of the container user at runtime --- Dockerfile | 4 ++-- entrypoint.sh | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8789272..eb58e01 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,6 +21,8 @@ ENV RENDER_POI "true" ENV RENDER_SIGNS_FILTER "-- RENDER --" ENV RENDER_SIGNS_HIDE_FILTER "false" ENV RENDER_SIGNS_JOINER "
" +ENV PUID 1000 +ENV PGID 1000 # ---------------------------- # # INSTALL & CONFIGURE DEFAULTS # @@ -72,6 +74,4 @@ COPY download_url.py /home/minecraft/download_url.py RUN chown minecraft:minecraft -R /home/minecraft/ -USER minecraft - CMD ["bash", "/home/minecraft/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh index 1ac800d..177421f 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,11 @@ #!/bin/bash +if [ $(id -u) = 0 ]; then + usermod -u ${PUID} minecraft > /dev/null 2>&1 + groupmod -g ${PGID} minecraft > /dev/null 2>&1 + chown -R minecraft:minecraft /home/minecraft/render + su -c "bash $0" minecraft +else + set -o errexit # Require MINECRAFT_VERSION environment variable to be set (no default assumed) @@ -43,3 +50,5 @@ if [ "$RENDER_POI" == "true" ]; then # shellcheck disable=SC2086 overviewer.py --config "$CONFIG_LOCATION" --genpoi $ADDITIONAL_ARGS_POI fi + +fi \ No newline at end of file From 188d419772b85bcb9b13a7a00ce529acb7c368e2 Mon Sep 17 00:00:00 2001 From: Spencer Hughes <16389711+spencerhughes@users.noreply.github.com> Date: Wed, 1 Dec 2021 19:19:45 -0500 Subject: [PATCH 2/4] Changes variable names to match those used in itzg's Minecraft container --- Dockerfile | 4 ++-- entrypoint.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index eb58e01..4556f98 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,8 +21,8 @@ ENV RENDER_POI "true" ENV RENDER_SIGNS_FILTER "-- RENDER --" ENV RENDER_SIGNS_HIDE_FILTER "false" ENV RENDER_SIGNS_JOINER "
" -ENV PUID 1000 -ENV PGID 1000 +ENV UID 1000 +ENV GID 1000 # ---------------------------- # # INSTALL & CONFIGURE DEFAULTS # diff --git a/entrypoint.sh b/entrypoint.sh index 177421f..e50db25 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/bash if [ $(id -u) = 0 ]; then - usermod -u ${PUID} minecraft > /dev/null 2>&1 - groupmod -g ${PGID} minecraft > /dev/null 2>&1 + usermod -u ${UID} minecraft > /dev/null 2>&1 + groupmod -g ${GID} minecraft > /dev/null 2>&1 chown -R minecraft:minecraft /home/minecraft/render su -c "bash $0" minecraft else From 049bbf4a14da332b86663172b36e47b5b9dd5ce9 Mon Sep 17 00:00:00 2001 From: Spencer Hughes <16389711+spencerhughes@users.noreply.github.com> Date: Wed, 1 Dec 2021 19:23:31 -0500 Subject: [PATCH 3/4] Adds documentation for UID and GID variables --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index f263838..d0d9a5d 100644 --- a/README.md +++ b/README.md @@ -57,3 +57,9 @@ _Note:_ The `latest` Docker tag is rebuilt daily. If there are changes to the [u - `RENDER_SIGNS_JOINER` Default Value: `
`. Set to the string that should be used to join the lines on the sign while rendering. Value of `"
"` will make each in-game line it's own line on the render. A value of `" "` will make all the in-game lines a single line on the render. + +- `UID` + Default Value: 1000. Set to the UID of the user the container process should run as. + +- `GID` + Default Value: 1000. Set to the GID of the user the container process should run as. From 334e11d3fd63ec191ab6c32baffa2a887b31a192 Mon Sep 17 00:00:00 2001 From: Spencer Hughes <16389711+spencerhughes@users.noreply.github.com> Date: Sun, 5 Dec 2021 13:47:18 -0500 Subject: [PATCH 4/4] Adds more reporting to the logs --- entrypoint.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index e50db25..869c880 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,8 +1,13 @@ #!/bin/bash if [ $(id -u) = 0 ]; then + echo "UID: ${UID}" usermod -u ${UID} minecraft > /dev/null 2>&1 + echo "GID: ${GID}" groupmod -g ${GID} minecraft > /dev/null 2>&1 + echo "Updating permissions..." chown -R minecraft:minecraft /home/minecraft/render + echo "Done." + echo "Starting Overviewer." su -c "bash $0" minecraft else