Refactor Docker entrypoints and remove unused scripts
- 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.
This commit is contained in:
36
backend/docker-entrypoint.sh
Normal file
36
backend/docker-entrypoint.sh
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/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 "$@"
|
||||
Reference in New Issue
Block a user