5.2 KiB
5.2 KiB
Arquitetura de Deploy
Estratégia de Deploy
Containerização:
- Build Tool: Docker multi-stage build
- Base Image: node:18-alpine (otimizado para produção)
- Output: Container image com NextJS standalone build
- Registry: Registry privado (registry.automatizase.com) ou Docker Hub
Orquestração Kubernetes:
- Platform: Kubernetes cluster (self-hosted ou cloud)
- Namespace:
automatizase-portal - Replicas: 2+ pods (alta disponibilidade via HPA)
- Service: ClusterIP (internal)
- Ingress: Nginx Ingress Controller (HTTPS via Cert-Manager)
GitOps Deployment:
- Tool: ArgoCD
- Source: Git repository (
k8s/folder) - Sync: Automatizado (self-heal + prune)
- Rollback: Via ArgoCD UI ou kubectl
Pipeline CI/CD
CI (Continuous Integration) - GitHub Actions:
# .github/workflows/ci.yaml
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Type check
run: npx tsc --noEmit
- name: Run unit tests
run: npm run test
- name: Build application
run: npm run build
env:
# Env vars necessárias para build (apenas públicas)
NEXT_PUBLIC_SITE_URL: https://portal.automatizase.com
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
CD (Continuous Delivery) - Docker Build & Push:
# .github/workflows/docker-build.yaml
name: Docker Build and Push
on:
push:
branches: [main]
tags:
- 'v*' # Trigger on version tags (v1.0.0)
env:
REGISTRY: registry.automatizase.com
IMAGE_NAME: portal
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix={{branch}}-
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
NEXT_PUBLIC_SITE_URL=https://portal.automatizase.com
- name: Output image tag
run: echo "Image pushed: ${{ steps.meta.outputs.tags }}"
CD (GitOps) - ArgoCD:
ArgoCD monitora automaticamente o repositório Git (k8s/ folder) e sincroniza mudanças para o cluster. Quando novo commit é pushado em main:
- GitHub Actions executa CI (testes, lint, build)
- Se CI passa, GitHub Actions builda e pusha Docker image para registry
- Developer atualiza
k8s/deployment.yamlcom nova tag de imagem:image: registry.automatizase.com/portal:v1.0.1 # Atualizar aqui - Commit e push para
main - ArgoCD detecta mudança no Git, atualiza deployment no cluster automaticamente
- Kubernetes faz rolling update (zero downtime)
Fluxo Completo:
Developer push → CI tests → Build Docker → Push to registry →
Update k8s/deployment.yaml tag → Push to Git → ArgoCD sync → K8s rolling update
Ambientes
| Ambiente | Frontend URL | Backend URL | K8s Namespace | ArgoCD App | Propósito |
|---|---|---|---|---|---|
| Development | http://localhost:3000 | http://localhost:3000/api | - | - | Dev local (npm/docker) |
| Staging | https://staging.portal.automatizase.com | https://staging.portal.automatizase.com/api | automatizase-portal-staging | portal-staging | Pre-production K8s |
| Production | https://portal.automatizase.com | https://portal.automatizase.com/api | automatizase-portal | portal-prod | Live K8s |
Notas:
- Development: Roda localmente (npm dev ou Docker), sem K8s
- Staging (opcional): Cluster K8s separado ou namespace separado, mesma infra
- Production: Cluster K8s produção, Ingress com TLS, 2+ replicas, HPA ativo