Files
tech-gadget-manager/docker-entrypoint.sh
2026-01-15 23:37:33 +07:00

29 lines
826 B
Bash

#!/bin/sh
set -e
# Fix permissions for the database directory
# This script runs as root, so we can change ownership of the mounted volume
echo "Fixing permissions for /app/db..."
mkdir -p /app/db
chown -R nextjs:nodejs /app/db
if [ -f "/app/db/prod.db" ]; then
chown nextjs:nodejs /app/db/prod.db
fi
if [ -f "/app/db/prod.db-journal" ]; then
chown nextjs:nodejs /app/db/prod.db-journal
fi
if [ -f "/app/db/prod.db-shm" ]; then
chown nextjs:nodejs /app/db/prod.db-shm
fi
if [ -f "/app/db/prod.db-wal" ]; then
chown nextjs:nodejs /app/db/prod.db-wal
fi
# Switch to nextjs user to run migration and app
echo "Running database migrations..."
su-exec nextjs prisma migrate deploy
echo "Starting Next.js application..."
# exec replaces the shell process, su-exec switches user
exec su-exec nextjs node server.js