Commit ed84e30
Story 1.3: Data Tier Deployment (PostgreSQL + Redis) (#37)
* Story 1.3: Data Tier Deployment - PO validation and corrections
Created and validated Story 1.3 for deploying PostgreSQL 18 with pgvector
and Redis 8.2 on dedicated data tier (VPS 2).
Story includes:
- Complete acceptance criteria for data tier deployment
- 9 detailed tasks with granular subtasks
- Integration verification criteria (IV1-IV3)
- Comprehensive Dev Notes with architecture references
- Testing standards and verification procedures
PO Validation corrections applied (v1.0 → v1.2):
CRITICAL fixes:
- Added Task 5: Docker Swarm Secrets and Configs preparation
- 7 secrets creation (postgres_password, 5 db passwords, redis_password)
- 4 configs creation with versioning pattern (_v1)
- Added "Deployment Workflow" section with scp transfer instructions
- Clarified all commands execute from VPS 1 manager node
SHOULD-FIX improvements:
- Task 2.5.1: Specific postgresql.conf adaptation steps for 4GB RAM
- Task 6.5: Rollback procedure for failed deployments
- Important Notes #7: pgvector for Chatwoot documentation clarification
- Important Notes #8: Resource monitoring guidance
Enhancements:
- Health check timing guidance (30-60 seconds)
- Cross-references between sections
- Updated task numbering after Task 5 insertion
Story status: APPROVED - Ready for implementation
Implementation Readiness Score: 10/10
Confidence Level: HIGH
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Atualizar Evolution API para v2.3.6 (evoapicloud/evolution-api)
Atualização da imagem do container Evolution API no PRD e toda
documentação relacionada à Story 1.7.
Mudanças:
- Evolution API: atendai/evolution-api:v2.2.3 → evoapicloud/evolution-api:v2.3.6
- Atualizado em 7 arquivos de documentação (PRD + shards + architecture docs)
- Total de 9 ocorrências atualizadas
Arquivos alterados:
- docs/prd.md
- docs/prd/technical-constraints-and-integration-requirements.md
- docs/architecture.md (3 ocorrências)
- docs/architecture/service-architecture-deep-dive.md
- docs/architecture/target-architecture-to-be-docker-swarm-cluster.md
- docs/architecture/high-level-architecture-current-state-as-is.md
- docs/services.md
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Story 1.3: Data Tier Deployment - Development Complete
Implementa configuração completa para deployment de PostgreSQL 18 + Redis 8.2
no VPS 2 (data tier) usando Docker Swarm.
Arquivos Criados:
- stacks/stack-worker-data.yml: Stack Swarm com PostgreSQL e Redis
- scripts/deploy-data-tier.sh: Script automático de deployment
- tests/deployment/verify-data-tier-swarm.sh: 18 testes de verificação
Arquivos Modificados:
- config/postgresql/init-databases.sh: Suporte a Docker Swarm secrets
- config/postgresql/postgresql.conf: Adaptado para perfil Minimal (4GB RAM)
* shared_buffers: 8GB → 1GB
* effective_cache_size: 24GB → 2.5GB
* max_connections: 200 → 100
* work_mem: 20MB → 64MB
Configurações:
- PostgreSQL 18 com pgvector (image: pgvector/pgvector:pg18)
- Redis 8.2 com persistência RDB + AOF (image: redis:8.2-alpine)
- 5 databases isolados: n8n, chatwoot, metabase, directus, evolution
- pgvector habilitado em: n8n_db, chatwoot_db, directus_db
- 7 Docker Swarm secrets (senhas)
- 4 Docker Swarm configs (arquivos de configuração)
- Sem portas expostas (rede interna apenas)
- Health checks configurados
- Resource limits baseados em perfil Minimal
Segurança:
- Todas as senhas via Docker Swarm secrets (criptografadas)
- PostgreSQL: scram-sha-256 password encryption
- Redis: protected-mode com autenticação por senha
- Script de deployment gera senhas aleatórias seguras
Próximos Passos:
- Tasks 5-8 requerem execução no VPS 1 (scripts prontos)
- Deployment: bash scripts/deploy-data-tier.sh
- Verificação: bash tests/deployment/verify-data-tier-swarm.sh
Status: Ready for Review
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Fix: PostgreSQL 18+ volume mount path
PostgreSQL 18+ requer volume em /var/lib/postgresql ao invés de
/var/lib/postgresql/data conforme documentação oficial.
Ref: docker-library/postgres#1259
* Fix: PostgreSQL config syntax - use integer MB values
PostgreSQL não aceita valores decimais com unidades (ex: 2.5GB).
Corrigido: effective_cache_size = 2.5GB → 2560MB
Erro: 'syntax error near token GB' na linha 35
* Fix: Corrigir script de verificação para Docker Swarm
O script estava tentando docker ps no VPS 1, mas containers estão no VPS 2.
Correções:
- Test 4: SSH para data node para obter container PostgreSQL
- Test 5-10: Executar comandos PostgreSQL via SSH no data node
- Test 15-17: SSH para data node para Redis
- Test 16: Obter senha do secret e testar autenticação Redis
- Corrigir aspas em comandos SQL dentro de SSH (usar aspas simples)
Agora o script executa corretamente em ambiente Swarm distribuído.
* Fix: Criar scripts de verificação corretos (sem SSH entre nodes)
PROBLEMA: Script anterior tentava SSH de VPS1 para VPS2 - gambiarra ridícula.
SOLUÇÃO CORRETA:
- verify-data-tier-manager.sh: Roda no VPS 1 (manager)
* Verifica via comandos Swarm (service ls, service ps, inspect)
* 8 testes: service exists, placement, state, ports
- verify-data-tier-local.sh: Roda no VPS 2 (data node)
* Verifica containers localmente (docker exec direto)
* 12 testes: connectivity, databases, pgvector, config, Redis auth, persistence
Removido:
- verify-data-tier-swarm.sh (script quebrado com SSH)
Uso correto:
1. VPS 1: ./tests/deployment/verify-data-tier-manager.sh
2. VPS 2: ./tests/deployment/verify-data-tier-local.sh
* Fix: Remover set -e dos scripts de verificação
set -e fazia script parar após primeiro teste quando incrementava variável.
Removido para permitir execução completa dos testes.
* Story 1.3: Final story update - deployment complete
Atualizou story file com resultados finais do deployment:
- Status: Ready for Review → Complete
- Testes: 20/20 passed (8 manager + 12 local)
- Scripts de verificação que funcionaram: verify-data-tier-manager.sh + verify-data-tier-local.sh
- Correções aplicadas: volume path PG18, syntax config, remoção SSH, fix set -e
Mudanças documentadas:
1. PostgreSQL 18 volume: /var/lib/postgresql/data → /var/lib/postgresql
2. Config syntax: effective_cache_size 2.5GB → 2560MB
3. Abordagem verificação: 2 scripts separados (sem SSH entre nodes)
4. Script bug: Removido set -e que causava exit no primeiro teste
Deployment verificado e completo em VPS 1 e VPS 2.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Mark Story 1.3 as Done: Data Tier Deployment (PostgreSQL + Redis)
Finalizing story branch with all implementation and documentation updates.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent d9e1c57 commit ed84e30
File tree
14 files changed
+1471
-26
lines changed- config/postgresql
- docs
- architecture
- prd
- stories
- scripts
- stacks
- tests/deployment
14 files changed
+1471
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
27 | 63 | | |
28 | 64 | | |
29 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
| 32 | + | |
| 33 | + | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
156 | | - | |
| 155 | + | |
| 156 | + | |
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
160 | 166 | | |
161 | 167 | | |
162 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
| 185 | + | |
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| |||
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
452 | | - | |
| 452 | + | |
453 | 453 | | |
454 | 454 | | |
455 | 455 | | |
| |||
1668 | 1668 | | |
1669 | 1669 | | |
1670 | 1670 | | |
1671 | | - | |
| 1671 | + | |
1672 | 1672 | | |
1673 | 1673 | | |
1674 | 1674 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
202 | | - | |
| 202 | + | |
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
342 | | - | |
| 342 | + | |
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
232 | | - | |
| 232 | + | |
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
| |||
0 commit comments