-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add UID and GID to set the user & group ID's during runtime (#10)
This PR add the option to set UID/GID during runtime, making sure the application is running as a non-root user. Besides this, it also helps with making sure UID/GID match between containers.
- Loading branch information
1 parent
81ba20f
commit 06f654f
Showing
3 changed files
with
36 additions
and
4 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,22 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
mkdir -p /var/logs | ||
mkdir -p "$INGEST_DIR" | ||
|
||
# Create group if it doesn't exist | ||
if ! getent group "$GID" >/dev/null; then | ||
groupadd -g "$GID" abc | ||
fi | ||
|
||
# Create user if it doesn't exist | ||
if ! id -u "$UID" >/dev/null 2>&1; then | ||
useradd -u "$UID" -g "$GID" -d /app -s /sbin/nologin abc | ||
fi | ||
|
||
# Adjust ownership of application directories | ||
chown -R $UID:$GID /app "$INGEST_DIR" /var/logs | ||
|
||
# Switch to the created user and execute the main command | ||
exec gosu $UID "$@" | ||
|
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