Espera Oracle na compose e roda bootstrap automatico no start

This commit is contained in:
Frederico Castro
2025-12-12 20:27:59 -03:00
parent 77029695cb
commit a768fadbe2
2 changed files with 26 additions and 12 deletions

View File

@@ -16,9 +16,13 @@ services:
- LOG_LEVEL=INFO
volumes:
- ./backend/src:/app/src
- ./backend/scripts:/app/scripts
- /etc/localtime:/etc/localtime:ro
networks:
- shared_network
depends_on:
oracle18c:
condition: service_healthy
restart: unless-stopped
frontend:
@@ -47,7 +51,7 @@ services:
environment:
- ORACLE_PASSWORD=local123
- ORACLE_CHARACTERSET=AL32UTF8
- APP_USER=locasl123
- APP_USER=local123
- APP_USER_PASSWORD=local123
- TZ=America/Sao_Paulo
ports:

View File

@@ -1,20 +1,27 @@
#!/bin/bash
echo "=== Ranking CAPES - Iniciando sistema ==="
echo "=== Ranking CAPES - Iniciando com ngrok ==="
cd /home/fred/projetos/ranking
echo "[1/5] Parando containers antigos..."
docker compose down 2>/dev/null
echo "[2/5] Limpando portas ocupadas..."
sudo fuser -k 8000/tcp 2>/dev/null
sudo fuser -k 5173/tcp 2>/dev/null
echo "[3/5] Matando ngrok antigo..."
pkill -f "ngrok http 5173" 2>/dev/null
echo "[4/5] Criando rede e subindo containers..."
docker network create shared_network 2>/dev/null
echo "[1/3] Liberando portas ocupadas..."
sudo lsof -i :8000 -t 2>/dev/null | xargs -r sudo kill -9
sudo lsof -i :5173 -t 2>/dev/null | xargs -r sudo kill -9
echo "[2/3] Subindo containers Docker..."
cd /home/fred/projetos/ranking
docker compose up -d backend frontend
echo "Aguardando backend subir (e Oracle ficar healthy)..."
sleep 10
docker compose up -d backend frontend >/dev/null
sleep 3
sleep 2
if ! docker ps | grep -q ranking_backend; then
echo "ERRO: Backend não subiu!"
@@ -26,7 +33,10 @@ if ! docker ps | grep -q ranking_frontend; then
exit 1
fi
echo "[3/3] Iniciando ngrok..."
echo "[4b/5] Rodando bootstrap (ranking + componente B) dentro do backend..."
docker exec ranking_backend bash -lc "ORACLE_LOCAL_DSN=oracle18c:1521/XEPDB1 /app/scripts/bootstrap_ranking.sh"
echo "[5/5] Iniciando ngrok..."
ngrok http 5173 --log=stdout > /tmp/ngrok-ranking.log 2>&1 &
sleep 4