Skip to content

Commit

Permalink
Merge pull request #4 from nossas/feature/legacy-architecture
Browse files Browse the repository at this point in the history
[ Feature ] Arquitetura de containers do servidor "legacy"
  • Loading branch information
igr-santos authored Dec 18, 2024
2 parents 2cd7e37 + 8b47df9 commit c98dd46
Show file tree
Hide file tree
Showing 6 changed files with 549 additions and 0 deletions.
5 changes: 5 additions & 0 deletions legacy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Na instância onde essa arquitetura será implantada cria uma rede docker:

```bash
docker network create web
```
78 changes: 78 additions & 0 deletions legacy/clients/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
services:
accounts:
image: ${DOCKER_IMAGE:-nossas/bonde-clients:clients-v1.0.0}
command: pnpm --filter accounts-client start
restart: "${DOCKER_RESTART_POLICY:-unless-stopped}"
pull_policy: always
healthcheck:
test: "${DOCKER_WEB_HEALTHCHECK_TEST:-wget -qO- localhost:3000}"
interval: "60s"
timeout: "3s"
start_period: "5s"
retries: 3
labels:
- traefik.enable=true
- traefik.http.services.accounts.loadbalancer.server.port=3000
- traefik.http.routers.accounts.tls=true
- traefik.http.routers.accounts.tls.certresolver=myresolver
- traefik.http.routers.accounts.rule=Host(`accounts.${DEFAULT_DOMAIN_RULE}`)

app:
image: ${DOCKER_IMAGE:-nossas/bonde-clients:clients-v1.0.0}
command: pnpm --filter admin-client start
restart: "${DOCKER_RESTART_POLICY:-unless-stopped}"
pull_policy: always
healthcheck:
test: "${DOCKER_WEB_HEALTHCHECK_TEST:-wget -qO- localhost:5000}"
interval: "60s"
timeout: "3s"
start_period: "5s"
retries: 3
labels:
- traefik.enable=true
- traefik.http.services.app.loadbalancer.server.port=5000
- traefik.http.routers.app.tls=true
- traefik.http.routers.app.tls.certresolver=myresolver
- traefik.http.routers.app.rule=Host(`app.${DEFAULT_DOMAIN_RULE}`)

admin-canary:
image: ${DOCKER_IMAGE:-nossas/bonde-clients:clients-v1.0.0}
command: pnpm --filter canary-client start
restart: "${DOCKER_RESTART_POLICY:-unless-stopped}"
pull_policy: always
healthcheck:
test: "${DOCKER_WEB_HEALTHCHECK_TEST:-wget -qO- localhost:3000}"
interval: "60s"
timeout: "3s"
start_period: "5s"
retries: 3
labels:
- traefik.enable=true
- traefik.http.services.admin-canary.loadbalancer.server.port=3000
- traefik.http.routers.admin-canary.tls=true
- traefik.http.routers.admin-canary.tls.certresolver=myresolver
- traefik.http.routers.admin-canary.rule=Host(`admin-canary.${DEFAULT_DOMAIN_RULE}`)

redes:
image: ${DOCKER_REDES_IMAGE:-nossas/bonde-clients:v7.7.2}
command: pnpm --filter redes-client start
restart: "${DOCKER_RESTART_POLICY:-unless-stopped}"
pull_policy: always
healthcheck:
test: "${DOCKER_WEB_HEALTHCHECK_TEST:-wget -qO- localhost:3000}"
interval: "60s"
timeout: "3s"
start_period: "5s"
retries: 3
labels:
- traefik.enable=true
- traefik.http.services.redes.loadbalancer.server.port=3000
- traefik.http.routers.redes.tls=true
- traefik.http.routers.redes.tls.certresolver=myresolver
- traefik.http.routers.redes.rule=Host(`redes.${DEFAULT_DOMAIN_RULE}`)

# Todos os serviços devem pertencer a mesma rede para serem descobertos pelo Traefik
networks:
default:
# Padronizar o nome da rede com o nome do domínio
name: web
175 changes: 175 additions & 0 deletions legacy/common/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
services:
traefik:
image: "traefik:v3.1"
command:
# - "--accesslog.filepath=/logs/access.log"
- "--accesslog=true"
- "--accesslog.format=json"
# - "--log.filepath=/logs/traefik.log"
- "--log=true"
- "--log.format=json"
- "--log.level=${TRAEFIK_LOG_LEVEL:-ERROR}"
- "--metrics.influxdb2=true"
- "--metrics.influxdb2.address=${TRAEFIK_INFLUX_HOST:-http://localhost:8086}"
- "--metrics.influxdb2.token=${TRAEFIK_INFLUX_SECRET:-secret}"
- "--metrics.influxdb2.org=NOSSAS"
- "--metrics.influxdb2.bucket=metrics"
- "--metrics.influxdb2.additionallabels.host=${TRAEFIK_INFLUX_HOSTNAME:-example.com}"
- "--global.checknewversion=${TRAEFIK_CHECK_NEW_VERSION:-false}"
- "--global.sendanonymoususage=${TRAEFIK_SEND_ANONYMOUS_USAGE:-false}"
- "--ping"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.watch=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.defaultRule=Host(`{{ index .Labels \"com.docker.compose.service\"}}.${TRAEFIK_DEFAULT_DOMAIN_RULE:-bonde.devel}`)"
- "--entrypoints.web.address=:80"
- "--entrypoints.web.http.redirections.entryPoint.to=websecure"
- "--entrypoints.web.http.redirections.entryPoint.scheme=https"
- "--entrypoints.web.http.redirections.entrypoint.permanent=true"
- "--entrypoints.websecure.address=:443"
# - "--entrypoints.websecure.http.middlewares=securityHeader@etcd"
- "--certificatesresolvers.myresolver.acme.tlschallenge=true"
- "--certificatesresolvers.myresolver.acme.email=${TRAEFIK_DEFAULT_EMAIL_ACME:[email protected]}"
- "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
- "--certificatesresolvers.myresolver.acme.dnschallenge.provider=route53"
restart: always
healthcheck:
test: ['CMD', 'traefik', 'healthcheck', '--ping']
interval: 10s
timeout: 10s
retries: 5
ports:
- "80:80"
- "443:443"
# - "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "letsencrypt:/letsencrypt"
environment:
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-xxxxxxx}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:-xxxxxx}
- AWS_REGION=${AWS_REGION:-us-east-1}
labels:
- traefik.enable=true
# global redirection: https (www.) to https
- traefik.http.routers.wwwsecure-catchall.rule=HostRegexp(`{host:(www\\.).+}`)
- traefik.http.routers.wwwsecure-catchall.entrypoints=websecure
- traefik.http.routers.wwwsecure-catchall.tls=true
- traefik.http.routers.wwwsecure-catchall.middlewares=wwwtohttps
# middleware: http(s)://(www.) to https://
- traefik.http.middlewares.wwwtohttps.redirectregex.regex=^https?://(?:www\\.)?(.+)
- traefik.http.middlewares.wwwtohttps.redirectregex.replacement=https://$${1}
- traefik.http.middlewares.wwwtohttps.redirectregex.permanent=true
# export traefik dashboard
- traefik.http.services.traefik.loadbalancer.server.port=8080
- traefik.http.routers.traefik.tls=true
- traefik.http.routers.traefik.tls.certresolver=myresolver

api-graphql:
image: hasura/graphql-engine:v2.44.0
environment:
- HASURA_GRAPHQL_DATABASE_URL=${BONDE_DATABASE_URL:-postgres://user:pass@postgres:5432/bonde}
- HASURA_GRAPHQL_VOTEPELOCLIMA_DATABASE_URL=${VOTEPELOCLIMA_DATABASE_URL:-postgres://user:pass@postgres:5432/votepeloclima}
- HASURA_GRAPHQL_ENABLE_CONSOLE=${HASURA_GRAPHQL_ENABLE_CONSOLE:-'false'}
- HASURA_GRAPHQL_ADMIN_SECRET=${HASURA_GRAPHQL_ADMIN_SECRET:-segredo123}
- HASURA_GRAPHQL_JWT_SECRET=${HASURA_GRAPHQL_JWT_SECRET}
- HASURA_GRAPHQL_UNAUTHORIZED_ROLE=anonymous
- HASURA_GRAPHQL_ENABLED_LOG_TYPES=startup,query-log,http-log,webhook-log,websocket-log
- HASURA_GRAPHQL_LOG_LEVEL=${HASURA_GRAPHQL_LOG_LEVEL:-debug}
- HASURA_GRAPHQL_CORS_DOMAIN=${HASURA_GRAPHQL_CORS_DOMAIN:-*}
- HASURA_GRAPHQL_INFER_FUNCTION_PERMISSIONS=false
# Remote schemas
- API_ACCOUNTS_URL=${HASURA_REMOTE_SCHEMA_API_ACCOUNTS_URL:-http://api-accounts.bonde.devel}
- API_ACTIVISTS_URL=${HASURA_REMOTE_SCHEMA_API_ACTIVISTS_URL:-http://activists.bonde.devel}
- API_DOMAINS_URL=${HASURA_REMOTE_SCHEMA_API_DOMAINS_URL:-http://api-domains.bonde.devel}
- API_NOTIFICATIONS_URL=${HASURA_REMOTE_SCHEMA_API_NOTIFICATIONS_URL:-http://notifications.bonde.devel}
- API_PAYMENTS_URL=${HASURA_REMOTE_SCHEMA_API_PAYMENTS_URL:-http://api-payments.bonde.devel}
- API_REDES_URL=${HASURA_REMOTE_SCHEMA_API_REDES_URL:-http://api-redes.bonde.devel}
- N8N_WEBHOOK_URL=${HASURA_N8N_WEBHOOK_URL:-http://n8n.bonde.devel/webhook}
- PORT=8080
restart: always
pull_policy: always
logging:
driver: "json-file"
options:
max-size: "5120m"
labels:
- traefik.enable=true
- traefik.http.services.api-graphql.loadbalancer.server.port=8080
- traefik.http.routers.api-graphql.tls=true
- traefik.http.routers.api-graphql.tls.certresolver=myresolver
- traefik.http.routers.api-graphql.rule=Host(`api-graphql.${DEFAULT_DOMAIN_RULE}`)

api-rest:
image: ghcr.io/nossas/bonde-server:latest
command: bundle exec puma -C config/puma.rb
healthcheck:
test: ["wget", "-qO-", "localhost:3000"]
interval: "60s"
timeout: "3s"
start_period: "5s"
retries: 3
environment:
- DATABASE_URL=${BONDE_DATABASE_URL:-postgres://user:pass@postgres:5432/bonde}
- AWS_ID=${AWS_ACCESS_KEY_ID:-xxxxxxx}
- AWS_SECRET=${AWS_SECRET_ACCESS_KEY:-xxxxxx}
- AWS_ROUTE53_REGION=${AWS_REGION:-us-east-1}
- AWS_BUCKET=${API_REST_AWS_BUCKET:-hub-central}
- AWS_ENDPOINT=${AWS_ENDPOINT:-https://s3.amazonaws.com}
- AWS_ROUTE53_SYNC=${AWS_ROUTE53_SYNC:-force}
- AWS_ROUTE_IP=${AWS_ROUTE_IP:-127.0.0.1}
- API_HOST=${API_REST_HOST:-api-rest.bonde.devel}
- CLIENT_HOST=${API_REST_CLIENT_HOST:-bonde.devel}
- JWT_SECRET=${API_REST_JWT_SECRET:-segredo123}
- LOG_LEVEL=${API_REST_LOG_LEVEL:-info}
- RAILS_ENV=${API_REST_ENV:-production}
- RAILS_SERVE_STATIC_FILES=${API_REST__SERVE_STATIC_FILES:-enabled}
- SECRET_KEY_BASE=${API_REST_SECRET_KEY_BASE:-seeeeeeeeeee}
- SMTP_HOST=${SMTP_HOST:-smtp}
- SMTP_PASSWORD=${SMTP_PASSWORD:-SG.fdsafdsafdsafdsa}
- SMTP_PORT=${SMTP_PORT:-587}
- SMTP_USERNAME=${SMTP_USERNAME:-apikey}
- PORT=3000
- WEB_CONCURRENCY=2
- WEB_MEMORY=1024
labels:
- traefik.enable=true
- traefik.http.services.api-rest.loadbalancer.server.port=3000
- traefik.http.routers.api-rest.tls=true
- traefik.http.routers.api-rest.tls.certresolver=myresolver
- traefik.http.routers.api-rest.rule=Host(`api-rest.${DEFAULT_DOMAIN_RULE}`)

n8n:
image: n8nio/n8n:1.66.0
environment:
- DB_POSTGRESDB_DATABASE=${N8N_DB_POSTGRESDB_DATABASE:-n8n}
- DB_POSTGRESDB_HOST=${N8N_DB_POSTGRESDB_HOST:-postgres}
- DB_POSTGRESDB_PASSWORD=${N8N_DB_POSTGRESDB_PASSWORD:-postgres}
- DB_POSTGRESDB_PORT=${N8N_DB_POSTGRESDB_PORT:-5432}
- DB_POSTGRESDB_USER=${N8N_DB_POSTGRESDB_USER:-postgres}
- DB_TYPE=${N8N_DB_TYPE:-postgresdb}
- WEBHOOK_URL=${N8N_WEBHOOK_URL:-http://n8n.bonde.devel}
- N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
- DB_LOGGING_ENABLED=true
- DB_LOGGING_OPTIONS=all
volumes:
- n8n:/home/node/.n8n
labels:
- traefik.enable=true
- traefik.http.services.n8n.loadbalancer.server.port=5678
- traefik.http.routers.n8n.tls=true
- traefik.http.routers.n8n.tls.certresolver=myresolver
- traefik.http.routers.n8n.rule=Host(`n8n.${DEFAULT_DOMAIN_RULE}`)

volumes:
letsencrypt:
driver: local
n8n:
driver: local

# Todos os serviços devem pertencer a mesma rede para serem descobertos pelo Traefik
networks:
default:
# Padronizar o nome da rede com o nome do domínio
name: web
24 changes: 24 additions & 0 deletions legacy/data/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
services:
metabase:
image: metabase/metabase
environment:
JAVA_TIMEZONE: America/Sao_Paulo
MB_DB_TYPE: postgres
MB_DB_DBNAME: ${MB_DB_DBNAME:-metabase}
MB_DB_PORT: ${MB_DB_PORT:-5432}
MB_DB_USER: ${MB_DB_USER:-postgres}
MB_DB_PASS: ${MB_DB_PASS:-postgres}
MB_DB_HOST: ${MB_DB_HOST:-postgres}
JAVA_TOOL_OPTIONS: -Xmx2g
labels:
- traefik.enable=true
- traefik.http.services.metabase.loadbalancer.server.port=3000
- traefik.http.routers.metabase.tls=true
- traefik.http.routers.metabase.tls.certresolver=myresolver
- traefik.http.routers.metabase.rule=Host(`metabase.${DEFAULT_DOMAIN_RULE}`)

# Todos os serviços devem pertencer a mesma rede para serem descobertos pelo Traefik
networks:
default:
# Padronizar o nome da rede com o nome do domínio
name: web
88 changes: 88 additions & 0 deletions legacy/mapa-acolhimento/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
services:
mautic:
image: mautic/mautic:v4
environment:
- MAUTIC_DB_HOST=${MAUTIC_DB_HOST:-mautic-nossasdb}
- MAUTIC_DB_NAME=${MAUTIC_DB_NAME:-mautic}
- MAUTIC_DB_PASSWORD=${MAUTIC_DB_PASSWORD:-mysecret}
- MAUTIC_DB_USER=${MAUTIC_DB_USER:-root}
- MAUTIC_RUN_CRON_JOBS=${MAUTIC_RUN_CRON_JOBS:-true}
- MYSQL_PORT_3306_TCP=${MYSQL_PORT_3306_TCP:-3306}
volumes:
- mautic_data:/var/www/html
healthcheck:
test: "${DOCKER_WEB_HEALTHCHECK_TEST:-wget -qO- localhost}"
interval: "60s"
timeout: "3s"
start_period: "5s"
retries: 3
labels:
- traefik.enable=true
- traefik.http.services.mautic.loadbalancer.server.port=80
- traefik.http.routers.mautic.priority=10000
- traefik.http.routers.mautic.tls=true
- traefik.http.routers.mautic.tls.certresolver=myresolver
- traefik.http.routers.mautic.rule=Host(`${MAUTIC_URL}`)

formularios:
image: ${FORMULARIO_DOCKER_IMAGE:-nossas/mapa-org-formularios:v1.3.6}
restart: "${DOCKER_RESTART_POLICY:-unless-stopped}"
pull_policy: always
environment:
- DEBUG=${FORMULARIO_DEBUG:-True}
- ALLOWED_HOSTS=${FORMULARIO_ALLOWED_HOSTS}
- VOLUNTEER_HOST=${FORMULARIO_VOLUNTEER_HOST}
- DATABASE_URL=${FORMULARIO_DATABASE_URL}
- BONDE_DATABASE_URL=${BONDE_DATABASE_URL}
- MOODLE_API_URL=${FORMULARIO_MOODLE_API_URL}
- MOODLE_API_KEY=${FORMULARIO_MOODLE_API_KEY}
- GEOCODING_API_KEY=${FORMULARIO_GEOCODING_API_KEY}
- GOOGLE_MAPS_API_KEY=${FORMULARIO_GOOGLE_MAPS_API_KEY}
- MOODLE_DATABASE_URL=${FORMULARIO_MOODLE_DATABASE_URL}
- LOOPS_API_KEY=${FORMULARIO_LOOPS_API_KEY}
- ZENDESK_SUBDOMAIN=${FORMULARIO_ZENDESK_SUBDOMAIN}
- ZENDESK_API_TOKEN=${FORMULARIO_ZENDESK_API_TOKEN}
- ZENDESK_API_USER=${FORMULARIO_ZENDESK_API_USER}
- NEW_RELIC_LICENSE_KEY=${FORMULARIO_NEW_RELIC_LICENSE_KEY}
- NEW_RELIC_ENVIRONMENT=${FORMULARIO_NEW_RELIC_ENVIRONMENT}
labels:
- traefik.enable=true
- traefik.http.services.formularios.loadbalancer.server.port=8000
- traefik.http.routers.formularios.tls=true
- traefik.http.routers.formularios.tls.certresolver=myresolver
- traefik.http.routers.formularios.rule=Host(`${FORMULARIO_VOLUNTEER_HOST}`)

moodle:
image: bitnami/moodle:4.1
volumes:
- moodle_data:/bitnami/moodle
- moodledata_data:/bitnami/moodledata
environment:
- MOODLE_DATABASE_TYPE=${MOODLE_DATABASE_TYPE:-pgsql}
- MOODLE_DATABASE_HOST=${MOODLE_DATABASE_HOST}
- MOODLE_DATABASE_USER=${MOODLE_DATABASE_USER}
- MOODLE_DATABASE_PASSWORD=${MOODLE_DATABASE_PASSWORD}
- MOODLE_DATABASE_NAME=${MOODLE_DATABASE_NAME}
- MOODLE_DATABASE_PORT_NUMBER=${MOODLE_DATABASE_PORT_NUMBER:-5432}
- MOODLE_HOST=${MOODLE_HOST}
- MOODLE_SSLPROXY=${MOODLE_SSLPROXY:-true}
labels:
- traefik.enable=true
- traefik.http.services.moodle.loadbalancer.server.port=8080
- traefik.http.routers.moodle.tls=true
- traefik.http.routers.moodle.tls.certresolver=myresolver
# - traefik.http.routers.moodle.rule=Host(`${MOODLE_HOST}`)

volumes:
mautic_data:
driver: local
moodle_data:
driver: local
moodledata_data:
driver: local

# Todos os serviços devem pertencer a mesma rede para serem descobertos pelo Traefik
networks:
default:
# Padronizar o nome da rede com o nome do domínio
name: web
Loading

0 comments on commit c98dd46

Please sign in to comment.