140 lines
2.7 KiB
Markdown
140 lines
2.7 KiB
Markdown
# Workflow de Desenvolvimento
|
|
|
|
## Setup de Desenvolvimento Local
|
|
|
|
### Pré-requisitos
|
|
|
|
```bash
|
|
# Node.js 18+ e npm
|
|
node --version # >= 18
|
|
npm --version # >= 9
|
|
|
|
# Docker (para build de imagens e teste local)
|
|
docker --version # >= 24
|
|
|
|
# kubectl (para interagir com cluster K8s)
|
|
kubectl version --client # >= 1.28
|
|
|
|
# (Opcional) k9s para gerenciamento visual do cluster
|
|
k9s version
|
|
```
|
|
|
|
### Setup Inicial
|
|
|
|
```bash
|
|
# Clone repository
|
|
git clone https://github.com/automatizase/dashboard-promova.git
|
|
cd dashboard-promova
|
|
|
|
# Install dependencies
|
|
npm install
|
|
|
|
# Copy environment template
|
|
cp .env.local.example .env.local
|
|
|
|
# Edit .env.local com credenciais
|
|
# nano .env.local
|
|
|
|
# Start development (local, sem Docker)
|
|
npm run dev
|
|
```
|
|
|
|
### Comandos de Desenvolvimento
|
|
|
|
**Desenvolvimento Local (sem Docker):**
|
|
```bash
|
|
# Start dev server
|
|
npm run dev
|
|
|
|
# Run tests
|
|
npm run test
|
|
|
|
# Run E2E tests
|
|
npm run test:e2e
|
|
|
|
# Lint
|
|
npm run lint
|
|
|
|
# Build production
|
|
npm run build
|
|
|
|
# Start production
|
|
npm run start
|
|
```
|
|
|
|
**Desenvolvimento com Docker (simula produção):**
|
|
```bash
|
|
# Build Docker image
|
|
docker build -t portal:dev .
|
|
|
|
# Run container local
|
|
docker run -p 3000:3000 \
|
|
--env-file .env.local \
|
|
portal:dev
|
|
|
|
# Acessar: http://localhost:3000
|
|
|
|
# Stop container
|
|
docker ps # Ver CONTAINER ID
|
|
docker stop <CONTAINER_ID>
|
|
```
|
|
|
|
**Build e Push para Registry (CI/CD):**
|
|
```bash
|
|
# Build com tag de versão
|
|
docker build -t registry.automatizase.com/portal:1.0.0 .
|
|
|
|
# Login no registry privado
|
|
docker login registry.automatizase.com
|
|
|
|
# Push para registry
|
|
docker push registry.automatizase.com/portal:1.0.0
|
|
|
|
# Tag como latest
|
|
docker tag registry.automatizase.com/portal:1.0.0 registry.automatizase.com/portal:latest
|
|
docker push registry.automatizase.com/portal:latest
|
|
```
|
|
|
|
**Deploy para Kubernetes (via kubectl manual, ou ArgoCD automatizado):**
|
|
```bash
|
|
# Aplicar todos manifests K8s
|
|
kubectl apply -f k8s/
|
|
|
|
# Verificar pods
|
|
kubectl get pods -n automatizase-portal
|
|
|
|
# Ver logs
|
|
kubectl logs -f deployment/portal-deployment -n automatizase-portal
|
|
|
|
# Port-forward para testar local
|
|
kubectl port-forward svc/portal-service 3000:80 -n automatizase-portal
|
|
|
|
# Rollback (se algo der errado)
|
|
kubectl rollout undo deployment/portal-deployment -n automatizase-portal
|
|
|
|
# Verificar status do Ingress
|
|
kubectl get ingress -n automatizase-portal
|
|
```
|
|
|
|
## Configuração de Ambiente
|
|
|
|
### Variáveis de Ambiente Necessárias
|
|
|
|
```bash
|
|
# Frontend (.env.local)
|
|
NEXT_PUBLIC_SITE_URL=http://localhost:3000
|
|
NEXT_PUBLIC_SUPABASE_URL=https://xxxxx.supabase.co
|
|
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGci...
|
|
|
|
# Backend
|
|
SUPABASE_SERVICE_ROLE_KEY=eyJhbGci...
|
|
|
|
EVOLUTION_API_URL=https://evolution.automatizase.com
|
|
EVOLUTION_API_KEY=your-key
|
|
EVOLUTION_INSTANCE_NAMES=instance1,instance2,instance3
|
|
|
|
N8N_OAUTH_URL=https://n8n.automatizase.com/webhook/google-oauth
|
|
```
|
|
|
|
---
|