fix: user management in Docker container startup

This commit is contained in:
FuzzyGrim
2025-03-13 15:37:23 +01:00
parent df4d5314ab
commit eb934b36a8
2 changed files with 4 additions and 8 deletions

View File

@@ -10,14 +10,14 @@ COPY ./nginx.conf /etc/nginx/nginx.conf
WORKDIR /yamtrack
RUN apk add --no-cache nginx \
RUN apk add --no-cache nginx shadow \
&& pip install --no-cache-dir -r /requirements.txt \
&& pip install --no-cache-dir supervisor==4.2.5 \
&& rm -rf /root/.cache /tmp/* \
&& find /usr/local -type d -name __pycache__ -exec rm -rf {} + \
&& chmod +x /entrypoint.sh \
# create user abc for later PUID/PGID mapping
&& adduser -D -H -s /bin/sh abc \
&& useradd -U -M -s /bin/sh abc \
# Create required nginx directories and set permissions
&& mkdir -p /var/log/nginx \
&& mkdir -p /var/lib/nginx/body \

View File

@@ -7,12 +7,8 @@ python manage.py migrate --noinput
PUID=${PUID:-1000}
PGID=${PGID:-1000}
if [ "$(id -u abc)" != "$PUID" ] || [ "$(id -g abc)" != "$PGID" ]; then
# Delete and recreate the user with the correct IDs
deluser abc
addgroup -g "$PGID" abc
adduser -D -H -G abc -s /bin/sh -u "$PUID" abc
fi
groupmod -o -g "$PGID" abc
usermod -o -u "$PUID" abc
chown -R abc:abc /yamtrack
chown -R abc:abc db