feat: add asterisk pjsip integration
- infrastructure/docker/asterisk.Dockerfile: Asterisk 22.10.1 LTS compilado do fonte oficial (Debian trixie nao distribui mais o pacote asterisk), com PJSIP, AMI, ARI, res_odbc/res_config_odbc, cdr_adaptive_odbc, cel_odbc, app_queue - infrastructure/asterisk/config: templates renderizados no entrypoint (secrets via envsubst, nunca versionados) + sorcery.conf/extconfig.conf para PJSIP realtime, dialplan de teste (extensao 600) - infrastructure/postgres/init/002-asterisk-realtime.sql: tabelas ps_endpoints/ps_auths/ps_aors/ps_contacts/ps_endpoint_id_ips/ ps_registrations/cdr/cel no schema 'asterisk' - infrastructure/nftables: protege AMI/ARI/SIP contra acesso pela LAN (interface ens18), trazido da Fase 9 do TODO para ja, sem afetar SSH nem a rede interna do Docker - docker-compose.yml: servico asterisk em network_mode: host (RTP); Postgres publicado em 127.0.0.1:5432 (nao 0.0.0.0) para o Asterisk alcanca-lo, ja que host network nao enxerga a rede Docker interna Testado: AMI login, ARI com auth (401 sem auth), pjsip realtime consultando Postgres sem erro, dialplan originate -> CDR e CEL gravados corretamente, healthcheck do compose passando.
This commit is contained in:
@@ -7,6 +7,9 @@ networks:
|
||||
volumes:
|
||||
postgres-data:
|
||||
redis-data:
|
||||
asterisk-lib:
|
||||
asterisk-log:
|
||||
asterisk-spool:
|
||||
|
||||
services:
|
||||
postgres:
|
||||
@@ -22,7 +25,12 @@ services:
|
||||
- ./infrastructure/postgres/init:/docker-entrypoint-initdb.d:ro
|
||||
networks:
|
||||
- b2bcall-net
|
||||
# Sem "ports": Postgres não deve ficar acessível fora da rede Docker interna.
|
||||
ports:
|
||||
# Publicado SOMENTE em loopback do host: o container do Asterisk usa
|
||||
# network_mode: host (necessário para RTP) e por isso não enxerga a
|
||||
# rede Docker interna por nome — precisa alcançar o Postgres via
|
||||
# 127.0.0.1. Isso nunca fica acessível pela LAN/Internet (não é 0.0.0.0).
|
||||
- "127.0.0.1:${POSTGRES_PORT:-5432}:5432"
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-b2bcall} -d ${POSTGRES_DB:-b2bcall}"]
|
||||
interval: 10s
|
||||
@@ -71,3 +79,45 @@ services:
|
||||
resources:
|
||||
limits:
|
||||
memory: 160M
|
||||
|
||||
asterisk:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: infrastructure/docker/asterisk.Dockerfile
|
||||
image: b2bcall-asterisk:22.10.1
|
||||
container_name: b2bcall-asterisk
|
||||
restart: unless-stopped
|
||||
network_mode: host
|
||||
# RTP exige uma faixa larga de portas UDP — inviável de mapear uma a uma
|
||||
# em bridge network, por isso host mode (ver docs/ARCHITECTURE.md 3.1).
|
||||
# AMI (5038), ARI (8088) e SIP (5060) ficam protegidos pelo nftables
|
||||
# (infrastructure/nftables/b2bcall.nft), que bloqueia acesso pela LAN.
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
# O Asterisk (host network) alcança o Postgres via loopback do host,
|
||||
# não pelo nome do container (ver publicação de porta do serviço postgres).
|
||||
ASTERISK_DB_HOST: ${ASTERISK_DB_HOST:-127.0.0.1}
|
||||
volumes:
|
||||
- ./infrastructure/asterisk/config:/etc/asterisk-templates:ro
|
||||
- asterisk-lib:/var/lib/asterisk
|
||||
- asterisk-log:/var/log/asterisk
|
||||
- asterisk-spool:/var/spool/asterisk
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "asterisk -rx 'core show uptime' | grep -q 'System uptime'"]
|
||||
interval: 15s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_period: 20s
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
memory: 400M
|
||||
|
||||
Reference in New Issue
Block a user