From 7b60748e3e3f58f27ae79052fec0b06ae7b31638 Mon Sep 17 00:00:00 2001 From: Julian Nadeau Date: Tue, 28 Jan 2025 08:04:32 -0500 Subject: [PATCH] Fix PUID and PGID handling (#711) --- Dockerfile | 2 +- README.md | 7 ++++++- startup.sh | 15 +++++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index a67acbd3d..314d9a17b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ WORKDIR /var/www/html # Update packages and install dependencies RUN apk upgrade --no-cache && \ - apk add --no-cache sqlite-dev libpng libpng-dev libjpeg-turbo libjpeg-turbo-dev freetype freetype-dev curl autoconf libgomp icu-dev icu-data-full nginx dcron tzdata imagemagick imagemagick-dev libzip-dev sqlite libwebp-dev && \ + apk add --no-cache shadow sqlite-dev libpng libpng-dev libjpeg-turbo libjpeg-turbo-dev freetype freetype-dev curl autoconf libgomp icu-dev icu-data-full nginx dcron tzdata imagemagick imagemagick-dev libzip-dev sqlite libwebp-dev && \ docker-php-ext-install pdo pdo_sqlite calendar && \ docker-php-ext-enable pdo pdo_sqlite && \ docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp && \ diff --git a/README.md b/README.md index 80d1b8629..4a1f29c39 100644 --- a/README.md +++ b/README.md @@ -114,10 +114,12 @@ See instructions to run Wallos below. ```bash docker run -d --name wallos -v /path/to/config/wallos/db:/var/www/html/db \ -v /path/to/config/wallos/logos:/var/www/html/images/uploads/logos \ --e TZ=Europe/Berlin -p 8282:80 --restart unless-stopped \ +-e TZ=Europe/Berlin -e PUID=82 -e PGID=82 -p 8282:80 --restart unless-stopped \ bellamy/wallos:latest ``` +Note: PUID and PGUID are optional, defaults to 82. Will let you run as an arbitrary user. + ### Docker Compose ``` @@ -129,6 +131,9 @@ services: - "8282:80/tcp" environment: TZ: 'America/Toronto' + # PUID and PGUID are optional, defaults to 82. Will let you run as an arbitrary user. + # PUID: 82 + # PGID: 82 # Volumes store your data between container upgrades volumes: - './db:/var/www/html/db' diff --git a/startup.sh b/startup.sh index 7400b1799..388c35388 100644 --- a/startup.sh +++ b/startup.sh @@ -2,12 +2,15 @@ echo "Startup script is running..." > /var/log/startup.log -# If the PUID or PGID environment variables are set, create a new user and group -if [ ! -z "$PUID" ] && [ ! -z "$PGID" ]; then - addgroup -g $PGID appgroup - adduser -D -u $PUID -G appgroup appuser - chown -R appuser:appgroup /var/www/html -fi +# Default the PUID and PGID environment variables to 82, otherwise +# set to the user defined ones. +PUID=${PUID:-82} +PGID=${PGID:-82} + +# Change the www-data user id and group id to be the user-specified ones +groupmod -o -g "$PGID" www-data +usermod -o -u "$PUID" www-data +chown -R www-data:www-data /var/www/html # Start both PHP-FPM and Nginx php-fpm & nginx -g 'daemon off;' & touch ~/startup.txt