-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
69 lines (65 loc) · 2.25 KB
/
Copy pathdocker-compose.yml
File metadata and controls
69 lines (65 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
63
64
65
66
67
68
69
# Três serviços, uma imagem para scheduler+dashboard:
# - db : Postgres em volume nomeado (sobrevive a rebuilds da imagem)
# - scheduler : roda o ciclo bootstrap -> scrape -> processar -> snapshot -> push
# - dashboard : gunicorn servindo o Dash app na :8050 (read-only sobre data/)
#
# Variáveis de ambiente em .env (copie de .env.example).
services:
db:
# Casar com o postgresql-client default do python:3.8-slim (Debian bookworm -> v15).
image: postgres:15-alpine
restart: unless-stopped
environment:
POSTGRES_DB: agenda
POSTGRES_USER: agenda
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?defina POSTGRES_PASSWORD em .env}
volumes:
- agenda_postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U agenda -d agenda"]
interval: 10s
timeout: 5s
retries: 5
scheduler:
build: .
restart: unless-stopped
depends_on:
db:
condition: service_healthy
environment:
AGENDA_DB_URL: postgresql://agenda:${POSTGRES_PASSWORD}@db:5432/agenda
AGENDA_SCRAPE_INTERVAL_HOURS: ${AGENDA_SCRAPE_INTERVAL_HOURS:-24}
AGENDA_SNAPSHOT_RETENTION_DAYS: ${AGENDA_SNAPSHOT_RETENTION_DAYS:-30}
POSTGRES_USER: agenda
POSTGRES_DB: agenda
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
GIT_REMOTE: ${GIT_REMOTE:-}
GIT_TOKEN: ${GIT_TOKEN:-}
GIT_BRANCH: ${GIT_BRANCH:-master}
GIT_USER_EMAIL: ${GIT_USER_EMAIL:-agenda-bot@local}
GIT_USER_NAME: ${GIT_USER_NAME:-agenda-bot}
volumes:
# Código + .git vêm do host (permite editar sem rebuild e commit/push do dump CSV).
- .:/app
command: python agenda-presidencial/code/scheduler.py
dashboard:
build: .
restart: unless-stopped
ports:
- "${DASHBOARD_PORT:-8050}:8050"
volumes:
# Read-only: dashboard só lê CSVs, defense in depth.
- .:/app:ro
# Forma de lista para evitar tokenização errada do shell pelo compose.
# ${GUNICORN_WORKERS:-2} é expandido pelo compose antes de chegar ao docker.
command:
- gunicorn
- --workers
- "${GUNICORN_WORKERS:-2}"
- --bind
- 0.0.0.0:8050
- --chdir
- agenda-presidencial/code
- dashboard:server
volumes:
agenda_postgres_data: