feat: add isolated staging environment, manual promotion script, and prepended staging domain pattern
continuous-integration/webhook Falha no deploy de scoreodonto.com (VPS 4)

This commit is contained in:
VPS 4 Builder
2026-05-18 00:37:49 +02:00
parent b649d926fd
commit b7bb455f56
9 changed files with 912 additions and 750 deletions
+8 -11
View File
@@ -36,19 +36,16 @@ node update-version.js
log "⚙️ Instalando dependências e preparando o Backend..."
cd /home/deploy/stack/scoreodonto.com/backend
npm install
# Prisma removido — backend usa pg nativo, schema.prisma é legado
# 2.1 Compilar os Plugins
log "⚙️ Compilando os Plugins da plataforma..."
cd /home/deploy/stack/scoreodonto.com/plugins
if [ -f "/home/deploy/stack/scoreodonto.com/backend/node_modules/.bin/tsc" ]; then
/home/deploy/stack/scoreodonto.com/backend/node_modules/.bin/tsc -p tsconfig.json || true
fi
# 3. Compilar o Frontend
log "⚙️ Instalando dependências e compilando o Frontend (Vite)..."
cd /home/deploy/stack/scoreodonto.com/frontend
npm install
npm run build
# 4. Reconstruir containers localmente na VPS 4 (servidor de produção)
log "🔄 Reconstruindo containers na VPS 4 (produção real)..."
cd /home/deploy/stack/scoreodonto.com
docker compose up -d --build
# 4. Reiniciar os serviços de Staging localmente na VPS 4
log "🔄 Reiniciando contêineres de STAGING na VPS 4..."
docker compose -f /home/deploy/stack/scoreodonto.com/docker-compose-staging.yml up -d --build
# 6. Salvar incremento de versão no Git
log "💾 Comitando o incremento de versão de volta para o repositório central..."
+53
View File
@@ -0,0 +1,53 @@
#!/bin/bash
# ─── deploy-to-prod.sh (ScoreOdonto) ──────────────────────────────────────────
# Script de Promoção Manual: Staging (VPS 4) ➔ Produção (VPS 1)
# ─────────────────────────────────────────────────────────────────────────────
set -e
LOCK_FILE="/tmp/deploy-prod-scoreodonto-release.lock"
if [ -f "$LOCK_FILE" ]; then
echo "🚨 Promoção para produção já está em andamento! Aguarde..."
exit 1
fi
touch "$LOCK_FILE"
trap 'rm -f "$LOCK_FILE"' EXIT
LOG_FILE="/home/deploy/stack/webhook-listener/deploy.log"
log() {
echo "[$(date -u +'%Y-%m-%dT%H:%M:%SZ')] [SCOREODONTO-PROD] $1" | tee -a "$LOG_FILE"
}
log "🚀 Iniciando PROMOÇÃO MANUAL de Staging (VPS 4) para PRODUÇÃO (VPS 1)..."
# 1. Sincronizar Backend para a VPS 1
log "🚚 Despachando Backend para a VPS 1 (Produção)..."
rsync -avz --delete \
--exclude '.env' \
--exclude 'node_modules/.cache' \
/home/deploy/stack/scoreodonto.com/backend/ \
deploy@10.99.0.1:/home/deploy/stack/scoreodonto.com/backend/
# 2. Sincronizar Frontend (build compilada em Staging) para a VPS 1
log "🚚 Despachando Frontend (build) para a VPS 1 (Produção)..."
rsync -avz --delete \
/home/deploy/stack/scoreodonto.com/frontend/dist/ \
deploy@10.99.0.1:/home/deploy/stack/scoreodonto.com/frontend/dist/
# 3. Sincronizar Plugins para a VPS 1
log "🚚 Despachando Plugins..."
rsync -avz --delete \
/home/deploy/stack/scoreodonto.com/plugins/ \
deploy@10.99.0.1:/home/deploy/stack/scoreodonto.com/plugins/
# 4. Sincronizar Docker Compose de Produção e Configurações de Nginx
log "🚚 Despachando Infraestrutura (Docker/Config) para a VPS 1..."
rsync -avz \
/home/deploy/stack/scoreodonto.com/docker-compose.yml \
/home/deploy/stack/scoreodonto.com/nginx \
deploy@10.99.0.1:/home/deploy/stack/scoreodonto.com/
# 5. SSH na VPS 1 para Reiniciar Serviços de Produção
log "🔄 Reiniciando containers de PRODUÇÃO na VPS 1..."
ssh -o BatchMode=yes deploy@10.99.0.1 "cd /home/deploy/stack/scoreodonto.com && DOCKER_HOST=unix:///run/user/1000/docker.sock docker compose up -d"
log "✅ PROMOÇÃO PARA PRODUÇÃO CONCLUÍDA COM SUCESSO!"
+59
View File
@@ -0,0 +1,59 @@
services:
nginx:
image: nginx:alpine
container_name: scoreodonto-nginx-staging
restart: always
ports:
- "8082:80"
volumes:
- "./nginx/default-staging.conf:/etc/nginx/conf.d/default.conf:ro"
networks:
- staging-net
depends_on:
- scoreodonto-backend-staging
- scoreodonto-frontend-staging
scoreodonto-backend-staging:
build:
context: "./backend"
dockerfile: Dockerfile
container_name: scoreodonto-backend-staging
restart: always
env_file:
- "./backend/.env"
environment:
- BAILEYS_ENGINE=infinite
- PORT=8018
- NODE_ENV=staging
- DATABASE_URL=postgresql://scoreodonto_user:clube67_scoreodonto_pass_9903@10.99.0.3:5432/scoreodonto?schema=public
- DRAGONFLY_URL=redis://:clube67_dragonfly_pass_9903@10.99.0.3:6379/1
- NATS_URL=nats://10.99.0.3:4222
- TEMPORAL_ADDRESS=10.99.0.3:7233
- BAILEYS_SESSIONS_PATH=/app/sessions
- APP_URL=https://staging.scoreodonto.com
- GOOGLE_REDIRECT_URI=https://staging.scoreodonto.com/api/oauth2callback
volumes:
- "/home/deploy/scoreodonto-sessions-staging:/app/sessions"
- "/home/deploy/scoreodonto-media-staging:/app/media"
- "./plugins:/app/plugins"
networks:
- staging-net
scoreodonto-frontend-staging:
build:
context: "."
dockerfile: frontend/Dockerfile
container_name: scoreodonto-frontend-staging
restart: always
env_file:
- "./frontend/.env.production.local"
environment:
- PORT=3013
- NODE_ENV=staging
- NEXT_PUBLIC_API_URL=https://staging.scoreodonto.com/api
networks:
- staging-net
networks:
staging-net:
driver: bridge
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -22,8 +22,8 @@
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<script type="module" crossorigin src="/assets/index-CS4bnJiX.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-VV5qCksm.css">
<script type="module" crossorigin src="/assets/index-DBXVhurK.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CwbNbjIf.css">
</head>
<body>
+52
View File
@@ -0,0 +1,52 @@
server {
listen 80;
server_name _;
# Limite de upload para mídias do WhatsApp
client_max_body_size 100M;
# Resolver DNS interno do Docker para resolução dinâmica
resolver 127.0.0.11 valid=30s;
# Proxy para o Backend (Express API)
location /api/ {
set $backend_upstream http://scoreodonto-backend-staging:8018;
rewrite ^/api/api/(.*)$ /api/$1 break;
proxy_pass $backend_upstream;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Proxy para o Socket.io (Realtime Events)
location /socket.io/ {
set $backend_upstream http://scoreodonto-backend-staging:8018;
proxy_pass $backend_upstream;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Proxy para o Frontend (Vite React SPA)
location / {
set $frontend_upstream http://scoreodonto-frontend-staging:3013;
proxy_pass $frontend_upstream;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}