diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index c3c9093..4c6f5a5 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -172,6 +172,66 @@ Teste final esperado no navegador: > Se houver erro de CORS, ajuste `FRONTEND_PUBLIC_URL` no `.env` da API para a URL exata usada no navegador (incluindo porta), e recrie o container da API. +## 5.2) Passo a passo (copiar e colar) para subir o front no servidor + +> Objetivo: abrir o front no navegador usando IP público, consumindo a API em `http://SEU_IP:8080`. + +No servidor (SSH), como usuário `deploy`: + +```bash +cd ~/apps/line-gestao-frontend + +# 1) Atualiza código do front +git fetch --all --prune +git pull --ff-only origin + +# 2) Configura URL da API para build de produção (Vite) +cat > .env.production << 'EOF' +VITE_API_URL=http://SEU_IP:8080 +EOF + +# 3) Build do front +npm ci +npm run build + +# 4) Publica build estático do front em container Nginx (porta 4173) +docker rm -f linegestao-frontend 2>/dev/null || true +docker run -d \ + --name linegestao-frontend \ + --restart unless-stopped \ + -p 4173:80 \ + -v "$PWD/dist:/usr/share/nginx/html:ro" \ + nginx:alpine +``` + +Agora teste: + +```bash +# no servidor +curl -I http://localhost:4173 + +# no seu computador +# http://SEU_IP:4173 +``` + +Se a porta 4173 não abrir externamente, libere no firewall: + +```bash +sudo ufw allow 4173/tcp +``` + +### Checklist final no navegador + +1. Abrir `http://SEU_IP:4173`. +2. Fazer login com o usuário admin seed da API. +3. Navegar no fluxo principal (cadastro/listagem/edição) e confirmar persistência. +4. Se aparecer erro de CORS, setar `FRONTEND_PUBLIC_URL=http://SEU_IP:4173` no `.env` da API e recriar o backend: + +```bash +cd ~/apps/line-gestao-api +docker compose -f docker-compose.prod.yml up -d --build +``` + --- ## 6) HTTPS (domínio público)