Files
beauty-bookings/start.sh

40 lines
1.7 KiB
Bash

#!/bin/sh
# Create .storage directories if they don't exist (as root)
mkdir -p /app/.storage/users
mkdir -p /app/.storage/bookings
mkdir -p /app/.storage/treatments
mkdir -p /app/.storage/availability
mkdir -p /app/.storage/cancellation-tokens
# Ensure permissive group-write permissions and correct ownership
umask 002
chown -R nextjs:nodejs /app/.storage 2>/dev/null || true
chmod -R 775 /app/.storage 2>/dev/null || true
# Ensure runtime dependencies exist (for prebuilt images)
echo "[startup] Checking runtime dependencies..."
if [ ! -d "/app/node_modules/hono" ] || ! node -e "require('bcrypt')" 2>/dev/null; then
if [ "$ALLOW_RUNTIME_INSTALL" = "true" ]; then
echo "[startup] Installing/rebuilding runtime dependencies..."
pnpm install --frozen-lockfile --prod --ignore-scripts=false || pnpm install --prod
echo "[startup] Rebuilding bcrypt native bindings..."
pnpm rebuild bcrypt --build-from-source
echo "[startup] Verifying bcrypt installation..."
node -e "require('bcrypt')" || { echo "[startup] ERROR: bcrypt verification failed!"; exit 1; }
echo "[startup] bcrypt successfully installed and verified."
else
echo "[startup] ERROR: Runtime dependencies missing and ALLOW_RUNTIME_INSTALL not set!"
echo "[startup] This should only happen in prebuilt scenarios. Check your setup."
exit 1
fi
fi
# Final verification before starting app
echo "[startup] Final bcrypt verification before starting app..."
node -e "require('bcrypt')" || { echo "[startup] FATAL: bcrypt not available!"; exit 1; }
echo "[startup] All checks passed. Starting application..."
# Start the application as nextjs user
exec su-exec nextjs node server-dist/index.js