Files
drone-detector/server/docker-entrypoint.sh
2025-09-20 21:06:16 +02:00

31 lines
839 B
Bash

#!/bin/sh
# This script runs as root to set up permissions, then switches to nodejs user
# Ensure uploads directory exists and has correct permissions
mkdir -p /app/uploads/logos
chown -R nodejs:nodejs /app/uploads
chmod -R 755 /app/uploads
# Wait for database to be ready
echo "Waiting for database to be ready..."
while ! nc -z postgres 5432; do
echo "Database not ready, waiting..."
sleep 1
done
echo "Database is ready!"
# Run database migrations as nodejs user
echo "Running database migrations..."
su-exec nodejs npm run db:migrate
# Check if migrations were successful
if [ $? -eq 0 ]; then
echo "Database migrations completed successfully"
else
echo "Database migrations failed"
exit 1
fi
# Switch to nodejs user and execute the command with dumb-init for signal handling
exec su-exec nodejs dumb-init -- "$@"