145 lines
4.6 KiB
Markdown
145 lines
4.6 KiB
Markdown
# Status Deploy: BI Dashboard Custom - 13/02/2026 19:11
|
|
|
|
## 🎯 Objetivo
|
|
Deploy dashboard Next.js custom para substituir Metabase, com PostgreSQL staging existente.
|
|
|
|
## ✅ Estado Actual
|
|
- **Container:** Running (2 minutos)
|
|
- **Serviço Docker:** `descomplicar_bi-descomplicar` activo
|
|
- **Build:** Completou com sucesso
|
|
- **Logs:** "✓ Ready in 62ms" (Next.js iniciado)
|
|
- **Health Check:** ❌ HTTPS ainda não responde (erro SSL/domínio)
|
|
|
|
## 🔧 Problemas Resolvidos (7 iterações)
|
|
|
|
| # | Problema | Solução Aplicada |
|
|
|---|----------|------------------|
|
|
| 1 | Falta `class-variance-authority` | ✅ Adicionado ao package.json |
|
|
| 2 | `pnpm-lock.yaml` desatualizado | ✅ Regenerado lockfile |
|
|
| 3 | Prisma: `libssl.so.1.1` não encontrado (Alpine) | ✅ Instalado OpenSSL no builder |
|
|
| 4 | Runtime sem OpenSSL correcto | ✅ Tentado copiar Prisma client |
|
|
| 5 | Alpine OpenSSL 3.x incompatível com Prisma | ✅ Mudado para Debian slim |
|
|
| 6 | Prisma Alpine copiado para Debian | ✅ Copiar node_modules Prisma |
|
|
| 7 | `prisma` CLI não encontrado (devDependency) | ✅ **Fresh install no Debian** |
|
|
|
|
## 📋 Dockerfile Final (v8 - Actual)
|
|
|
|
```dockerfile
|
|
# Build: Alpine (rápido)
|
|
# Runtime: Debian slim (fresh install, Prisma nativo)
|
|
```
|
|
|
|
**Pontos-chave:**
|
|
- Builder: Alpine com build Next.js apenas
|
|
- Runner: Debian instala deps do zero + gera Prisma nativo
|
|
- **NÃO copia** node_modules do builder (evita conflito Alpine/Debian)
|
|
|
|
## 🚨 Problema Pendente: Domínio/SSL
|
|
|
|
**Sintoma:** Container running, Next.js "Ready", mas HTTPS não responde.
|
|
|
|
**Possíveis causas:**
|
|
1. Domínio `bi-custom.descomplicar.pt` não criado no EasyPanel
|
|
2. Traefik routing não configurado
|
|
3. SSL certificate ainda não gerado
|
|
4. Port mapping incorreto (container:3000 <-> Traefik)
|
|
|
|
## 🎯 Próximos Passos
|
|
|
|
### 1. Verificar Domínio EasyPanel
|
|
```bash
|
|
TOKEN=$(cat /etc/easypanel/.api-token)
|
|
curl -s "http://localhost:3000/api/trpc/domains.listDomains" \
|
|
-H "Authorization: Bearer $TOKEN" | jq '.result.data.json[] | select(.host | contains("bi-custom"))'
|
|
```
|
|
|
|
### 2. Criar Domínio (se não existir)
|
|
```bash
|
|
DOMAIN_ID="dom_$(date +%s)_bi-descomplicar"
|
|
curl -s -X POST "http://localhost:3000/api/trpc/domains.createDomain" \
|
|
-H "Authorization: Bearer $TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"json": {
|
|
"id": "'$DOMAIN_ID'",
|
|
"projectName": "descomplicar",
|
|
"host": "bi-custom.descomplicar.pt",
|
|
"path": "/",
|
|
"https": true,
|
|
"certificateResolver": "letsencrypt",
|
|
"wildcard": false,
|
|
"middlewares": [],
|
|
"destinationType": "service",
|
|
"serviceDestination": {
|
|
"projectName": "descomplicar",
|
|
"serviceName": "bi-descomplicar",
|
|
"port": 3000,
|
|
"protocol": "http"
|
|
}
|
|
}
|
|
}'
|
|
```
|
|
|
|
### 3. Verificar Traefik
|
|
```bash
|
|
docker service logs descomplicar_traefik --tail 50 | grep bi-custom
|
|
```
|
|
|
|
### 4. Testar Direto (sem SSL)
|
|
```bash
|
|
# Via container IP interno
|
|
docker inspect $(docker ps -q --filter "name=bi-descomplicar") | jq '.[0].NetworkSettings.Networks'
|
|
curl http://<container-ip>:3000/
|
|
```
|
|
|
|
### 5. Health Check Completo
|
|
Quando domínio funcionar:
|
|
- ✅ https://bi-custom.descomplicar.pt/ (200 OK)
|
|
- ✅ Dashboard carrega
|
|
- ✅ Conexão PostgreSQL funciona
|
|
- ✅ Métricas visíveis
|
|
|
|
## 📊 Métricas Deploy
|
|
|
|
- **Tentativas:** 8 deploys
|
|
- **Tempo total:** ~35 minutos
|
|
- **Commits:** 8 fixes
|
|
- **Build time:** ~4-5 minutos/deploy
|
|
- **Container:** Running estável
|
|
|
|
## 🗂️ Ficheiros Críticos
|
|
|
|
| Ficheiro | Estado | Notas |
|
|
|----------|--------|-------|
|
|
| `Dockerfile` | ✅ Funcional | v8: Fresh install Debian |
|
|
| `package.json` | ✅ Completo | class-variance-authority adicionado |
|
|
| `pnpm-lock.yaml` | ✅ Sync | Versão 10.29.3 |
|
|
| `prisma/schema.prisma` | ✅ OK | Multi-schema (staging) |
|
|
| `next.config.ts` | ✅ OK | output: standalone |
|
|
|
|
## 📝 Lições Aprendidas
|
|
|
|
1. **Alpine vs Debian:** Prisma precisa binary nativo. Alpine (musl) != Debian (glibc).
|
|
2. **Multi-stage builds:** NÃO copiar node_modules entre Alpine e Debian.
|
|
3. **pnpm build scripts:** Prisma CLI é devDependency, precisa de install completo.
|
|
4. **EasyPanel API:** `redeployService` não existe, usar `deployService`.
|
|
5. **Fresh install melhor:** Para Prisma, install do zero no target OS > copiar binaries.
|
|
|
|
## 🔗 Repositório
|
|
|
|
- **Gitea:** git.descomplicar.pt/ealmeida/bi-descomplicar
|
|
- **Branch:** main
|
|
- **Último commit:** 525e629 "Fix: Fresh install no Debian (não copiar Prisma Alpine)"
|
|
|
|
## 👤 Sessão
|
|
|
|
- **Data:** 13/02/2026
|
|
- **Início:** ~18:20
|
|
- **Fim:** 19:11
|
|
- **Duração:** ~50 minutos
|
|
- **Status:** Container running, domínio pendente
|
|
|
|
---
|
|
|
|
**Próxima sessão:** Configurar domínio/SSL e validar dashboard funcional.
|