Create user during dockerfile
All checks were successful
ci/woodpecker/push/build/2 Pipeline was successful
ci/woodpecker/push/build/1 Pipeline was successful
ci/woodpecker/push/build/3 Pipeline was successful
ci/woodpecker/manual/build/1 Pipeline was successful
ci/woodpecker/manual/build/2 Pipeline was successful
ci/woodpecker/manual/build/3 Pipeline was successful

This commit is contained in:
Ryan Voots 2024-08-01 08:58:59 -04:00
parent 9968836d28
commit 4caf0c0f99
2 changed files with 18 additions and 14 deletions

View file

@ -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; \

View file

@ -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