-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docker): add support for pgid and puid env variables (#1759)
- Loading branch information
1 parent
56b57ad
commit aeb681a
Showing
3 changed files
with
42 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,25 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
# Creating folders in volume | ||
mkdir -p /appdata/db | ||
mkdir -p /appdata/redis | ||
export PUID=${PUID:-0} | ||
export PGID=${PGID:-0} | ||
|
||
chown -R nextjs:nodejs /appdata | ||
echo "Starting with UID='$PUID', GID='$PGID'" | ||
|
||
su-exec 1001:1001 "$@" | ||
if [ "${PUID}" != "0" ] || [ "${PGID}" != "0" ]; then | ||
# The below command will change the owner of all files in the /app directory (except node_modules) to the new UID and GID | ||
echo "Changing owner to $PUID:$PGID, this will take about 10 seconds..." | ||
find . -name 'node_modules' -prune -o -mindepth 1 -maxdepth 1 -exec chown -R $PUID:$PGID {} + | ||
chown -R $PUID:$PGID /var/cache/nginx | ||
chown -R $PUID:$PGID /var/log/nginx | ||
chown -R $PUID:$PGID /var/lib/nginx | ||
chown -R $PUID:$PGID /run/nginx/nginx.pid | ||
chown -R $PUID:$PGID /etc/nginx | ||
echo "Changing owner to $PUID:$PGID, done." | ||
fi | ||
|
||
if [ "${PUID}" != "0" ]; then | ||
su-exec $PUID:$PGID "$@" | ||
else | ||
exec "$@" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters