puid and pgid support
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Paolo Asperti 2024-12-15 09:39:25 +01:00
parent 4e9ca79504
commit 7a8422f208
Signed by: paspo
GPG Key ID: 06D46905D19D5182
3 changed files with 14 additions and 3 deletions

View File

@ -10,6 +10,8 @@ VOLUME [ "/data/www", "/ssh" ]
ENV \
USERNAME=theuser \
PHP=none
PHP=none \
PUID=1000 \
PGID=1000
ENTRYPOINT [ "/sbin/tini", "/app/entrypoint.sh" ]

View File

@ -20,4 +20,8 @@ services:
- ./ssh:/ssh # add authorized_keys file here
environment:
PHP: php84 # none (default), php82, php83, php84
PUID: 1000
PGID: 1000
```
The `/data/www` directory and its contents will be chowned to `$PUID:$PGID` and chmodded to `0755` for directories and `0644` for files at container start.

View File

@ -3,12 +3,17 @@
WEBROOT=/data/www
PHP=${PHP:-none}
USERNAME=${USERNAME:-theuser}
PUID=${PUID:-1000}
GROUPNAME=${GROUPNAME:-thegroup}
PGID=${PGID:-1000}
RANDOMPWD=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 13)
adduser -DH -h "${WEBROOT}" -G "nginx" -u "1000" "${USERNAME}"
addgroup -g "${PGID}" "${GROUPNAME}"
addgroup nginx "${GROUPNAME}"
adduser -DH -h "${WEBROOT}" -G "${GROUPNAME}" -u "${PUID}" "${USERNAME}"
printf '%s\n%s' "${RANDOMPWD}" "${RANDOMPWD}" | passwd "${USERNAME}"
echo "password for the user \"${USERNAME}\" is: ${RANDOMPWD}"
chown "${USERNAME}:nginx" "${WEBROOT}" -R
chown "${PUID}:${GROUPNAME}" "${WEBROOT}" -R
find "${WEBROOT}" -type d -exec chmod 0755 {} \;
find "${WEBROOT}" -type f -exec chmod 0644 {} \;