Skip to content

Commit

Permalink
Docker: Fix alpine
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi311 committed Sep 13, 2024
1 parent fa01345 commit b3b0cca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM python:3.11-alpine

ENV PUID=1000
ENV PGID=1000
ENV GOSU_VERSION 1.17
ENV GOSU_VERSION=1.17

RUN apk add --no-cache tini dos2unix

Expand Down
14 changes: 9 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@ set -e

# Check if user is root
if [ "$(id -u)" = '0' ]; then
echo "User is root, checking if we need to create a user and group based on environment variables"
# Create group and user based on environment variables
if [ ! "$(getent group "$PGID")" ]; then
# If groupadd exists, use it
if command -v groupadd > /dev/null; then
groupadd -g "$PGID" jellyplex_group
groupadd -g "$PGID" jellyplex_watched
elif command -v addgroup > /dev/null; then
addgroup -g "$PGID" jellyplex_group
addgroup -g "$PGID" jellyplex_watched
fi
fi

# If user id does not exist, create the user
if [ ! "$(getent passwd "$PUID")" ]; then
# If useradd exists, use it
if command -v useradd > /dev/null; then
useradd --no-create-home -u "$PUID" -g "$PGID" jellyplex_user
useradd --no-create-home -u "$PUID" -g "$PGID" jellyplex_watched
elif command -v adduser > /dev/null; then
adduser -D -H -u "$PUID" -G jellyplex_group jellyplex_user
# Use alpine busybox adduser syntax
adduser -D -H -u "$PUID" -G jellyplex_watched jellyplex_watched
fi
fi
else
Expand All @@ -40,6 +42,8 @@ if [ -n "$MARK_DIR" ]; then
mkdir -p "$MARK_DIR"
fi

echo "Starting JellyPlex-Watched with UID: $PUID and GID: $PGID"

# If root run as the created user
if [ "$(id -u)" = '0' ]; then
chown -R "$PUID:$PGID" "$LOG_DIR"
Expand Down

0 comments on commit b3b0cca

Please sign in to comment.