2026-05-12 01:57:55 -05:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
# Ensure database and logs directories exist with proper permissions
|
|
|
|
|
# We run as root first (before USER directive), fix permissions, then exec to nodejs
|
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
2026-05-17 14:44:34 -05:00
|
|
|
log_error() {
|
|
|
|
|
echo "[$(date -Iseconds)] ERROR $1" >&2
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-12 01:57:55 -05:00
|
|
|
# Create directories if they don't exist
|
|
|
|
|
mkdir -p /app/db
|
|
|
|
|
mkdir -p /app/logs
|
|
|
|
|
|
|
|
|
|
# Make directories world-writable to allow the nodejs user to create files
|
|
|
|
|
chmod 777 /app/db
|
|
|
|
|
chmod 777 /app/logs
|
|
|
|
|
|
2026-05-17 14:44:34 -05:00
|
|
|
# Issue #4: Check if nodejs user exists - if not, this is a Docker build error
|
|
|
|
|
if ! id nodejs >/dev/null 2>&1; then
|
|
|
|
|
log_error "nodejs user does not exist - this is a Docker build error"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2026-05-12 01:57:55 -05:00
|
|
|
# Run the Express server as nodejs user
|
2026-05-17 14:44:34 -05:00
|
|
|
# Issue #4: Exit with error code 1 if su-exec fails instead of falling back to root
|
2026-05-12 01:57:55 -05:00
|
|
|
exec su-exec nodejs node server/index.js
|