build: add Docker entrypoint scripts for automated setup

- Add backend entrypoint with automated Prisma migrations and client regeneration
- Add frontend entrypoint with dependency management
- Update Dockerfiles to use entrypoint scripts
- Ensures database schema stays in sync with Prisma Client after migrations
This commit is contained in:
Radosław Gierwiało
2025-11-14 13:35:10 +01:00
parent 8c637469fd
commit 5bea2ad133
4 changed files with 66 additions and 2 deletions

View File

@@ -0,0 +1,33 @@
#!/bin/sh
set -e
echo "🔧 Checking dependencies..."
# Install dependencies if node_modules doesn't exist or package.json changed
if [ ! -d "node_modules" ] || [ "package.json" -nt "node_modules" ]; then
echo "📦 Installing npm dependencies..."
npm install
else
echo "✅ Dependencies already installed"
fi
# Generate Prisma Client if not exists or schema changed
if [ ! -d "node_modules/.prisma/client" ] || [ "prisma/schema.prisma" -nt "node_modules/.prisma/client" ]; then
echo "🔨 Generating Prisma Client..."
npx prisma generate
else
echo "✅ Prisma Client already generated"
fi
# Run pending database migrations
echo "🔄 Applying database migrations..."
npx prisma migrate deploy
# Regenerate Prisma Client after migrations to ensure sync
echo "🔨 Regenerating Prisma Client after migrations..."
npx prisma generate
echo "✅ Ready to start!"
# Execute the main command (passed as arguments to this script)
exec "$@"