xpeditis2.0/apps/backend/docker-entrypoint.sh
David d65cb721b5
Some checks are pending
CD Production (Hetzner k3s) / Promote Images (preprod → prod) (push) Waiting to run
CD Production (Hetzner k3s) / Deploy to k3s (xpeditis-prod) (push) Blocked by required conditions
CD Production (Hetzner k3s) / Smoke Tests (push) Blocked by required conditions
CD Production (Hetzner k3s) / Deployment Summary (push) Blocked by required conditions
CD Production (Hetzner k3s) / Notify Success (push) Blocked by required conditions
CD Production (Hetzner k3s) / Notify Failure (push) Blocked by required conditions
chore: sync full codebase from cicd branch
Aligns main with the complete application codebase (cicd branch).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 12:56:44 +02:00

27 lines
951 B
Bash

#!/bin/sh
echo "Starting Xpeditis Backend..."
echo "Waiting for PostgreSQL..."
max_attempts=30
attempt=0
while [ $attempt -lt $max_attempts ]; do
if node -e "const { Client } = require('pg'); const client = new Client({ host: process.env.DATABASE_HOST, port: process.env.DATABASE_PORT, user: process.env.DATABASE_USER, password: process.env.DATABASE_PASSWORD, database: process.env.DATABASE_NAME }); client.connect().then(() => { client.end(); process.exit(0); }).catch(() => process.exit(1));" 2>/dev/null; then
echo "PostgreSQL is ready"
break
fi
attempt=$((attempt + 1))
echo "Attempt $attempt/$max_attempts - Retrying..."
sleep 2
done
if [ $attempt -eq $max_attempts ]; then
echo "Failed to connect to PostgreSQL"
exit 1
fi
echo "Running database migrations..."
node /app/run-migrations.js
if [ $? -ne 0 ]; then
echo "Migrations failed"
exit 1
fi
echo "Starting NestJS application..."
exec "$@"