File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -e
3+
4+ # If running as root, check if we need to change UID/GID
5+ if [ " $( id -u) " = " 0" ]; then
6+ # Check if USER_UID or USER_GID environment variables are set
7+ if [ -n " ${USER_UID} " ] || [ -n " ${USER_GID} " ]; then
8+ USER_UID=${USER_UID:- 1000}
9+ USER_GID=${USER_GID:- 1000}
10+
11+ # Modify user if UID/GID different from default
12+ if [ " ${USER_UID} " != " 1000" ] || [ " ${USER_GID} " != " 1000" ]; then
13+ echo " Adjusting user to UID=${USER_UID} , GID=${USER_GID} "
14+
15+ # Modify group if needed
16+ if [ " ${USER_GID} " != " 1000" ]; then
17+ groupmod -g ${USER_GID} appuser
18+ fi
19+
20+ # Modify user if needed
21+ if [ " ${USER_UID} " != " 1000" ]; then
22+ usermod -u ${USER_UID} appuser
23+ fi
24+ fi
25+
26+ # Fix ownership of app directory and data
27+ chown -R appuser:appuser /app
28+
29+ # Execute command as appuser
30+ exec gosu appuser " $@ "
31+ fi
32+ fi
33+
34+ # Execute command directly if not running as root or no UID/GID specified
35+ exec " $@ "
You can’t perform that action at this time.
0 commit comments