-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
137 lines (129 loc) · 4.14 KB
/
Copy pathdocker-compose.yml
File metadata and controls
137 lines (129 loc) · 4.14 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: fanilab-backend
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: fanilab
POSTGRES_PASSWORD: fanilab
POSTGRES_DB: fanilab_backend
ports:
- '5432:5432'
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U fanilab -d fanilab_backend']
interval: 5s
timeout: 5s
retries: 10
redis:
image: redis:7-alpine
ports:
- '6379:6379'
volumes:
- redis-data:/data
healthcheck:
test: ['CMD', 'redis-cli', 'ping']
interval: 5s
timeout: 5s
retries: 10
# One-shot local/dev convenience: applies pending Prisma migrations before
# `api`/`worker` start, so `make docker-up` produces a working stack on a
# clean volume instead of every request failing with "table does not
# exist". This does NOT change the production release process
# (docs/DEPLOYMENT.md § Release Process still runs `prisma:migrate:deploy`
# as its own explicit, reviewed step) — `api`/`worker` still never migrate
# on boot themselves, this container just runs once and exits.
migrate:
build:
context: .
target: deps
env_file: .env
environment:
DATABASE_URL: postgresql://fanilab:fanilab@postgres:5432/fanilab_backend?schema=public
command: ['pnpm', 'prisma:migrate:deploy']
depends_on:
postgres:
condition: service_healthy
api:
build:
context: .
target: api
env_file: .env
environment:
DATABASE_URL: postgresql://fanilab:fanilab@postgres:5432/fanilab_backend?schema=public
REDIS_URL: redis://redis:6379
EVIDENCE_STORAGE_DIR: /var/lib/fanilab/evidence
volumes:
- evidence-data:/var/lib/fanilab/evidence
ports:
- '3000:3000'
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
migrate:
condition: service_completed_successfully
worker:
build:
context: .
target: worker
env_file: .env
environment:
DATABASE_URL: postgresql://fanilab:fanilab@postgres:5432/fanilab_backend?schema=public
REDIS_URL: redis://redis:6379
EVIDENCE_STORAGE_DIR: /var/lib/fanilab/evidence
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
migrate:
condition: service_completed_successfully
# `docker compose --profile observability up` — a local Prometheus +
# Grafana starter, not part of the default topology `docker compose up`
# brings up on its own (DEPLOYMENT.md's topology is api/worker/postgres/
# redis; a real deployment scrapes `/metrics` with whatever monitoring
# stack it already runs, per OBSERVABILITY.md). This is here so the
# metrics this backend emits can actually be looked at without standing
# up external infra first.
prometheus:
image: prom/prometheus:v3.1.0
profiles: ['observability']
volumes:
- ./docker/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus-data:/prometheus
ports:
- '9090:9090'
depends_on:
api:
condition: service_healthy
grafana:
image: grafana/grafana:11.4.0
profiles: ['observability']
environment:
# Local-dev-only default — change this before exposing Grafana
# anywhere beyond your own machine.
GF_SECURITY_ADMIN_PASSWORD: admin
volumes:
- ./docker/grafana/provisioning:/etc/grafana/provisioning:ro
- ./docker/grafana/dashboards:/etc/grafana/dashboards:ro
- grafana-data:/var/lib/grafana
ports:
- '3001:3000'
depends_on:
api:
condition: service_healthy
prometheus:
condition: service_started
volumes:
postgres-data:
redis-data:
# Dispute evidence files — the only copy of this data outside of the
# evidence rows' storageUrl/content-hash in Postgres. Without a named
# volume this lived in the api container's writable layer and was
# destroyed on every `docker compose down`/rebuild; back this volume up
# the same way you back up postgres-data. See docs/DEPLOYMENT.md.
evidence-data:
prometheus-data:
grafana-data: