feat: Add frontend and backend initialization scripts, implement Keycloak and PostgreSQL setup
- Implemented SvelteKit frontend with authentication callback handling. - Created demo routes and paraglide localization functionality. - Added health check and entrypoint scripts for backend services. - Established PostgreSQL and Keycloak initialization scripts with health checks. - Introduced models for database schema using SQLAlchemy. - Configured Vite and SvelteKit for development and testing environments. - Added health check script to verify service statuses and resource usage. - Created Docker entrypoint scripts for seamless service startup.
This commit is contained in:
62
scripts/backend-entrypoint.sh
Executable file
62
scripts/backend-entrypoint.sh
Executable file
@@ -0,0 +1,62 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Script de inicialización para el Backend FastAPI
|
||||
# Espera a las dependencias y ejecuta migraciones antes de iniciar
|
||||
|
||||
echo "=========================================="
|
||||
echo "Backend FastAPI - Inicialización"
|
||||
echo "=========================================="
|
||||
|
||||
# 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 python -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
|
||||
}
|
||||
|
||||
# Esperar a PostgreSQL
|
||||
wait_for_tcp "${CORE_DB_HOST:-postgres-a76}" "${CORE_DB_PORT:-5432}" "PostgreSQL"
|
||||
|
||||
# Esperar a Keycloak (HTTP por defecto usa puerto 8080)
|
||||
wait_for_tcp "keycloak" "8080" "Keycloak"
|
||||
|
||||
# Ejecutar inicialización de base de datos si existe el script
|
||||
if [ -f "/app/init_db.py" ]; then
|
||||
echo "Ejecutando inicialización de base de datos..."
|
||||
python init_db.py || echo "⚠ WARNING: Error en init_db.py"
|
||||
echo "✓ Inicialización de base de datos completada"
|
||||
fi
|
||||
|
||||
# Ejecutar migraciones (si usas Alembic, descomentar las siguientes líneas)
|
||||
# if [ -d "/app/alembic" ]; then
|
||||
# echo "Ejecutando migraciones de Alembic..."
|
||||
# alembic upgrade head
|
||||
# echo "✓ Migraciones completadas"
|
||||
# fi
|
||||
|
||||
echo "=========================================="
|
||||
echo "Iniciando aplicación FastAPI..."
|
||||
echo "=========================================="
|
||||
|
||||
# Ejecutar el comando que se pasó al contenedor
|
||||
exec "$@"
|
||||
Reference in New Issue
Block a user