Files
plantillas-proyectos/frontend/docker-entrypoint.sh
AlexeerCT 9d63b000bc 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.
2026-04-24 12:53:11 -05:00

41 lines
1.1 KiB
Bash

#!/bin/sh
set -e
# Arranque del contenedor: opcionalmente espera al health del backend, luego ejecuta CMD (pnpm dev / start, …)
wait_for_backend() {
local url=$1
local max_attempts=30
local attempt=1
echo "Esperando a que el backend esté disponible en ${url}..."
while [ $attempt -le $max_attempts ]; do
if wget -q -O /dev/null "${url}/health" 2>/dev/null; then
echo "✓ Backend está listo"
return 0
fi
echo "Backend no está listo aún... (intento $attempt/$max_attempts)"
attempt=$((attempt + 1))
sleep 3
done
echo "⚠ WARNING: Backend no estuvo disponible, continuando de todas formas"
return 0
}
# compose usa INTERNAL_API_URL; alias opcional BACKEND_INTERNAL_URL
_api_base="${INTERNAL_API_URL:-${BACKEND_INTERNAL_URL:-http://backend:8000/api}}"
_api_base="${_api_base%/}"
wait_for_backend "${_api_base}/health"
# En desarrollo (volumen montado) reinstala deps si cambia package.json
if [ "$NODE_ENV" = "development" ]; then
echo "Instalando dependencias (development)..."
CI=true pnpm install
fi
echo "Iniciando: $*"
exec "$@"