- Removed custom entrypoint scripts for backend, frontend, and PostgreSQL services from docker-compose files. - Added a new entrypoint script in the backend and frontend Dockerfiles to handle initialization without relying on host-mounted scripts. - Updated Dockerfiles to ensure proper permissions for the new entrypoint scripts. - Enhanced database initialization logic by moving schema and extension creation to the Alembic migration script.
37 lines
1.0 KiB
Bash
37 lines
1.0 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
# Arranque del contenedor: espera a dependencias, luego ejecuta CMD (uvicorn, gunicorn, celery, …)
|
|
|
|
# Función para esperar a un puerto TCP usando Python
|
|
wait_for_tcp() {
|
|
local host=$1
|
|
local port=$2
|
|
local service=$3
|
|
local max_attempts=30
|
|
local attempt=1
|
|
|
|
echo "Esperando a que $service esté disponible en ${host}:${port}..."
|
|
|
|
while [ $attempt -le $max_attempts ]; do
|
|
if python3 -c "import socket; s = socket.socket(); s.settimeout(3); s.connect(('$host', $port)); s.close()" 2>/dev/null; then
|
|
echo "✓ $service está listo y accesible"
|
|
return 0
|
|
fi
|
|
|
|
echo "$service no está listo aún... (intento $attempt/$max_attempts)"
|
|
attempt=$((attempt + 1))
|
|
sleep 2
|
|
done
|
|
|
|
echo "⚠ WARNING: $service no estuvo disponible después de $max_attempts intentos"
|
|
echo " Continuando de todas formas..."
|
|
return 0
|
|
}
|
|
|
|
wait_for_tcp "${CORE_DB_HOST:-postgres-a76}" "${CORE_DB_PORT:-5432}" "PostgreSQL"
|
|
wait_for_tcp "keycloak" "8080" "Keycloak"
|
|
|
|
echo "Iniciando proceso: $*"
|
|
exec "$@"
|