feat: add FreeSWITCH service (SignalWire packages, not compiled from source)

- infrastructure/freeswitch/Dockerfile: debian:trixie-slim + SignalWire
  packaged freeswitch-meta-vanilla, avoiding a C/C++ build on a 1.9GB RAM VM
- FREESWITCH_PAT used only via Docker BuildKit secret, apt credentials file
  created and deleted within the same RUN — verified absent from the final
  image with docker history
- minimal module set (agente.md secao 15): sofia, event_socket, commands,
  dptools, callcenter, avmd, curl, local_stream, etc. mod_xml_curl installed
  but disabled — it refuses to load without a configured gateway-url, which
  will exist once b2bcall-fs-config is built
- entrypoint.sh rotates the Event Socket password away from the 'ClueCon'
  default at container runtime (never baked into the image); fails loudly if
  ESL_PASSWORD is unset
- port 8021 not published to the host; only reachable from other containers
  on the compose network
- found and fixed: freeswitch-conf-vanilla is a Recommends (not a Depends)
  of freeswitch-meta-vanilla, so --no-install-recommends silently produced
  an empty /etc/freeswitch and a crash loop
- verified end-to-end: fs_cli status via ESL with the custom password,
  default password rejected, expected modules loaded, healthcheck green,
  ~44MB RAM usage
- docs/FREESWITCH.md, docs/NETWORK_ARCHITECTURE.md (network_mode decision
  deferred until a real SIP trunk exists)
This commit is contained in:
2026-08-28 06:30:25 -03:00
parent 68b403a7ff
commit b3b0aaacb3
7 changed files with 317 additions and 6 deletions

29
TODO.md
View File

@@ -8,9 +8,25 @@
- [x] Redis 7 (docker-compose, porta 127.0.0.1:6379)
- [x] Secrets gerados em `.env` (POSTGRES_PASSWORD, REDIS_PASSWORD, JWT_SECRET, JWT_REFRESH_SECRET, ENCRYPTION_KEY, ESL_PASSWORD)
- [x] `FREESWITCH_PAT` configurado em `.env` (não commitado)
- [ ] FreeSWITCH (build/imagem própria, ver risco de RAM abaixo)
- [x] FreeSWITCH (imagem própria via pacotes SignalWire, não compilada da fonte —
ver docs/FREESWITCH.md; rodando, saudável, ~44MB RAM, senha ESL customizada,
nenhuma porta exposta ao host)
- [ ] nginx (reverse proxy)
## PHASE 05 — FreeSWITCH (agente.md secao 232)
- [x] Imagem própria (`infrastructure/freeswitch/`), pacotes SignalWire (PAT via
BuildKit secret, nunca na imagem final — verificado com `docker history`)
- [x] Módulos mínimos carregados: sofia, event_socket, commands, dptools,
callcenter, avmd, curl, local_stream, etc. (mod_xml_curl instalado mas
desativado até existir b2bcall-fs-config)
- [x] Senha do Event Socket trocada da padrão via entrypoint runtime (nunca
fica na imagem); porta 8021 não publicada no host
- [x] docs/FREESWITCH.md, docs/NETWORK_ARCHITECTURE.md (decisão de
network_mode adiada pra quando existir tronco SIP real)
- [ ] Diretório/dialplan ainda são os estáticos da config vanilla (ramais de
teste 1000-1019, senhas fracas) — substituir por mod_xml_curl na fase
Extensions/Trunks/Dialplan
## PHASE 02 — SaaS Core
- [x] Monorepo Node.js/TypeScript (pnpm workspaces, tsconfig base)
- [x] Node 22 LTS + pnpm instalados no host
@@ -42,14 +58,15 @@
— testado ponta a ponta com curl (login, refresh rotation, logout, RBAC, 401/403/429)
- [ ] Password reset por e-mail — depende de SMTP configurado
## PHASE 05+ — ver `agente.md` seções 15 em diante (FreeSWITCH, Telefonia, Call Center,
Predictive Dialer, Recordings, AI, Billing, Frontend, Reports, Security, Tests)
## PHASE 06+ — ver `agente.md` seções 21 em diante (Event Socket, XML Curl, Telefonia,
Call Center, Predictive Dialer, Recordings, AI, Billing, Frontend, Reports, Security, Tests)
---
## Riscos conhecidos
- **RAM da VM (1.9GB total)**: insuficiente para rodar toda a stack (Postgres + Redis +
FreeSWITCH + múltiplos workers Node + Next.js) simultaneamente sem swap/OOM. Avaliar
upgrade de RAM antes de subir FreeSWITCH + frontend + workers juntos.
- **RAM da VM (1.9GB total)**: medido com Postgres+Redis+FreeSWITCH rodando juntos —
~91MB no total (Postgres 37MB, Redis 10MB, FreeSWITCH 44MB), bem tranquilo. O risco
real ainda não testado é o build/runtime do Next.js (frontend) e vários workers Node
simultâneos — reavaliar quando chegarmos lá.
- **Disco (26GB livre)**: build do FreeSWITCH + imagens Docker + gravações vão consumir
espaço rápido. Monitorar com `df -h`.