Some checks failed
DEPLOY_MULTI_BRACH/pipeline/head There was a failure building this commit
- entrypoint.sh: sustituye runserver por gunicorn (workers=2, timeout=120) - entrypoint.sh: espera a PostgreSQL antes de migrar cuando DB_HOST está definido - docker-compose.yml: unifica nombre de servicio db, añade healthcheck robusto, corrige env_file path a ../.env Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
42 lines
1.1 KiB
Bash
42 lines
1.1 KiB
Bash
#!/bin/bash
|
|
|
|
# Salir inmediatamente si un comando falla
|
|
set -e
|
|
|
|
# --- Esperar a PostgreSQL si estamos en modo BD remota ---
|
|
if [ -n "$DB_HOST" ]; then
|
|
echo "--> Esperando a PostgreSQL en $DB_HOST:${DB_PORT:-5432}..."
|
|
until python -c "
|
|
import sys, psycopg2, os
|
|
try:
|
|
psycopg2.connect(
|
|
host=os.environ['DB_HOST'],
|
|
port=os.environ.get('DB_PORT', 5432),
|
|
user=os.environ['DB_USER'],
|
|
password=os.environ['DB_PASSWORD'],
|
|
dbname=os.environ['DB_NAME']
|
|
)
|
|
sys.exit(0)
|
|
except Exception:
|
|
sys.exit(1)
|
|
" 2>/dev/null; do
|
|
echo " PostgreSQL no disponible, reintentando en 2s..."
|
|
sleep 2
|
|
done
|
|
echo "--> PostgreSQL listo."
|
|
fi
|
|
|
|
echo "--> Ejecutando migraciones..."
|
|
python manage.py migrate --noinput
|
|
|
|
echo "--> Cargando semillas (si existen)..."
|
|
python manage.py loaddata semillas 2>/dev/null || echo " Sin semillas, continuando."
|
|
|
|
echo "--> Arrancando servidor con Gunicorn..."
|
|
exec gunicorn api_config.wsgi:application \
|
|
--bind 0.0.0.0:8000 \
|
|
--workers 2 \
|
|
--timeout 120 \
|
|
--access-logfile - \
|
|
--error-logfile -
|