-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add puid and pgid container env vars
- Loading branch information
Showing
2 changed files
with
23 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
# OUID and OGID are the original user and group ids set during the image | ||
# build and are replaced here at runtime if PGID and PUID are set | ||
if [ -n "$PGID" ] && [ "$PGID" -ne 0 ]; then | ||
sed -i "s/nonroot:x:$OUID:$OGID:/nonroot:x:$OUID:$PGID:/" /etc/passwd | ||
sed -i "s/nonroot:x:$OGID:/nonroot:x:$PGID:/" /etc/group | ||
fi | ||
|
||
if [ -n "$PUID" ] && [ "$PUID" -ne 0 ]; then | ||
sed -i "s/nonroot:x:$OUID:/nonroot:x:$PUID:/" /etc/passwd | ||
fi | ||
|
||
chown nonroot: /app /app/* | ||
|
||
# Use su-exec to execute the command as nonroot user | ||
exec su-exec nonroot "$@" |