Skip to content

Commit 7b60748

Browse files
authored
Fix PUID and PGID handling (#711)
1 parent 2ca5786 commit 7b60748

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ WORKDIR /var/www/html
66

77
# Update packages and install dependencies
88
RUN apk upgrade --no-cache && \
9-
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 && \
9+
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 && \
1010
docker-php-ext-install pdo pdo_sqlite calendar && \
1111
docker-php-ext-enable pdo pdo_sqlite && \
1212
docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp && \

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,12 @@ See instructions to run Wallos below.
114114
```bash
115115
docker run -d --name wallos -v /path/to/config/wallos/db:/var/www/html/db \
116116
-v /path/to/config/wallos/logos:/var/www/html/images/uploads/logos \
117-
-e TZ=Europe/Berlin -p 8282:80 --restart unless-stopped \
117+
-e TZ=Europe/Berlin -e PUID=82 -e PGID=82 -p 8282:80 --restart unless-stopped \
118118
bellamy/wallos:latest
119119
```
120120

121+
Note: PUID and PGUID are optional, defaults to 82. Will let you run as an arbitrary user.
122+
121123
### Docker Compose
122124

123125
```
@@ -129,6 +131,9 @@ services:
129131
- "8282:80/tcp"
130132
environment:
131133
TZ: 'America/Toronto'
134+
# PUID and PGUID are optional, defaults to 82. Will let you run as an arbitrary user.
135+
# PUID: 82
136+
# PGID: 82
132137
# Volumes store your data between container upgrades
133138
volumes:
134139
- './db:/var/www/html/db'

startup.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
echo "Startup script is running..." > /var/log/startup.log
44

5-
# If the PUID or PGID environment variables are set, create a new user and group
6-
if [ ! -z "$PUID" ] && [ ! -z "$PGID" ]; then
7-
addgroup -g $PGID appgroup
8-
adduser -D -u $PUID -G appgroup appuser
9-
chown -R appuser:appgroup /var/www/html
10-
fi
5+
# Default the PUID and PGID environment variables to 82, otherwise
6+
# set to the user defined ones.
7+
PUID=${PUID:-82}
8+
PGID=${PGID:-82}
9+
10+
# Change the www-data user id and group id to be the user-specified ones
11+
groupmod -o -g "$PGID" www-data
12+
usermod -o -u "$PUID" www-data
13+
chown -R www-data:www-data /var/www/html
1114

1215
# Start both PHP-FPM and Nginx
1316
php-fpm & nginx -g 'daemon off;' & touch ~/startup.txt

0 commit comments

Comments
 (0)