-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
29 lines (24 loc) · 720 Bytes
/
docker-entrypoint.sh
File metadata and controls
29 lines (24 loc) · 720 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
27
28
29
#!/bin/sh
set -e
# Ensure subdirectories exist
mkdir -p storage/avatars storage/yjs storage/uploads .next/cache
# Fix permissions if running as root
if [ "$(id -u)" = '0' ]; then
# Set default PUID/PGID if not provided
PUID=${PUID:-1001}
PGID=${PGID:-1001}
# Update appuser UID/GID if necessary to match requested ID
if [ "$(id -u appuser)" != "$PUID" ]; then
usermod -o -u "$PUID" appuser
fi
if [ "$(id -g appuser)" != "$PGID" ]; then
groupmod -o -g "$PGID" appuser
fi
# Fix ownership
chown -R appuser:appuser storage .next/cache
# Run the application as appuser
exec su-exec appuser "$@"
else
# Already running as non-root user
exec "$@"
fi