Skip to content

Commit

Permalink
Fix PUID and PGID handling (#711)
Browse files Browse the repository at this point in the history
  • Loading branch information
jules2689 authored Jan 28, 2025
1 parent 2ca5786 commit 7b60748
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

```
Expand All @@ -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'
Expand Down
15 changes: 9 additions & 6 deletions startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7b60748

Please sign in to comment.