From 4caf0c0f99d20e829cc92e6256e044e279be103f Mon Sep 17 00:00:00 2001 From: Ryan Voots Date: Thu, 1 Aug 2024 08:58:59 -0400 Subject: [PATCH] Create user during dockerfile --- Dockerfile | 4 ++++ docker-entrypoint.sh | 28 ++++++++++++++-------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index f45dd5a..669b44e 100755 --- a/Dockerfile +++ b/Dockerfile @@ -62,6 +62,10 @@ WORKDIR /data COPY /docker-entrypoint.sh /opt/minecraft RUN chmod +x /opt/minecraft/docker-entrypoint.sh +RUN addgroup --gid 9001 dockergroup +RUN adduser --shell /bin/sh --uid 9001 --gid 9001 dockeruser + + # Install gosu #RUN set -eux; \ # apk update; \ diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 847fec9..02db9c7 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -4,20 +4,20 @@ set -euxo pipefail DOCKER_USER='dockeruser' DOCKER_GROUP='dockergroup' -if ! id "$DOCKER_USER" >/dev/null 2>&1; then - echo "First start of the docker container, start initialization process." - - USER_ID=${PUID:-9001} - GROUP_ID=${PGID:-9001} - echo "Starting with $USER_ID:$GROUP_ID (UID:GID)" - - addgroup --gid $GROUP_ID $DOCKER_GROUP - adduser --shell /bin/sh --uid $USER_ID --gid $GROUP_ID $DOCKER_USER - - chown -vR $USER_ID:$GROUP_ID /opt/minecraft - chmod -vR ug+rwx /opt/minecraft - chown -vR $USER_ID:$GROUP_ID /data -fi +#if ! id "$DOCKER_USER" >/dev/null 2>&1; then +# echo "First start of the docker container, start initialization process." +# +# USER_ID=${PUID:-9001} +# GROUP_ID=${PGID:-9001} +# echo "Starting with $USER_ID:$GROUP_ID (UID:GID)" +# +# addgroup --gid $GROUP_ID $DOCKER_GROUP +# adduser --shell /bin/sh --uid $USER_ID --gid $GROUP_ID $DOCKER_USER +# +# chown -vR $USER_ID:$GROUP_ID /opt/minecraft +# chmod -vR ug+rwx /opt/minecraft +# chown -vR $USER_ID:$GROUP_ID /data +#fi export HOME=/home/$DOCKER_USER exec sudo -u $DOCKER_USER java -jar -Xms$MEMORYSIZE -Xmx$MEMORYSIZE $JAVAFLAGS /opt/minecraft/paperspigot.jar --nojline nogui