-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
26 lines (20 loc) · 774 Bytes
/
docker-entrypoint.sh
File metadata and controls
26 lines (20 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh
set -e
# Support PUID/PGID
if [ "$(id -u)" = "0" ]; then
PUID=${PUID:-1001}
PGID=${PGID:-1001}
if [ "$PUID" != "1001" ] || [ "$PGID" != "1001" ]; then
echo "Setting UID to $PUID and GID to $PGID"
# Modify group nodejs gid
sed -i "s/^nodejs:x:[0-9]\+:/nodejs:x:$PGID:/" /etc/group
# Modify user nextjs uid and gid
sed -i "s/^nextjs:x:[0-9]\+:[0-9]\+:/nextjs:x:$PUID:$PGID:/" /etc/passwd
fi
# Fix permissions for the data directory
# We check ownership of /app/data and if it's not owned by nextjs, we chown it.
# This is necessary because when mounting volumes, the directory might be owned by root.
chown -R nextjs:nodejs /app/data
exec su-exec nextjs "$@"
fi
exec "$@"