-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
214 lines (202 loc) · 6.65 KB
/
Copy pathdocker-compose.yml
File metadata and controls
214 lines (202 loc) · 6.65 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
version: "3.9"
# A named network isn't strictly required -- Compose creates one
# automatically -- but naming it explicitly makes it easy to reference
# later (e.g. attaching a debugging container to inspect traffic).
networks:
pricelens-net:
driver: bridge
volumes:
pg_data:
redis_data:
rabbitmq_data:
services:
# ---------------------------------------------------------------------
# Infrastructure
# ---------------------------------------------------------------------
postgres:
image: postgres:16
container_name: pricelens-postgres
environment:
POSTGRES_USER: pricelens
POSTGRES_PASSWORD: pricelens_dev_password
POSTGRES_DB: pricelens_auth
volumes:
- pg_data:/var/lib/postgresql/data
# Auto-creates the tracking-service database on first boot only --
# Postgres's official image runs every .sql/.sh file in this folder
# exactly once, when the data directory is empty.
- ./infra/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
ports:
- "5432:5432"
networks:
- pricelens-net
healthcheck:
test: ["CMD-SHELL", "pg_isready -U pricelens"]
interval: 5s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
container_name: pricelens-redis
command: redis-server --appendonly yes
volumes:
- redis_data:/data
ports:
- "6379:6379"
networks:
- pricelens-net
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 5s
retries: 5
rabbitmq:
image: rabbitmq:3.13-management
container_name: pricelens-rabbitmq
environment:
RABBITMQ_DEFAULT_USER: pricelens
RABBITMQ_DEFAULT_PASS: pricelens_dev_password
volumes:
- rabbitmq_data:/var/lib/rabbitmq
ports:
- "5672:5672"
- "15672:15672"
networks:
- pricelens-net
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "-q", "ping"]
interval: 10s
timeout: 10s
retries: 5
# ---------------------------------------------------------------------
# Backend services
# ---------------------------------------------------------------------
auth-service:
build: ./services/auth-service
container_name: pricelens-auth-service
environment:
DATABASE_URL: postgresql://pricelens:pricelens_dev_password@postgres:5432/pricelens_auth
JWT_SECRET_KEY: ${JWT_SECRET_KEY}
JWT_ALGORITHM: HS256
ACCESS_TOKEN_EXPIRE_MINUTES: 30
CORS_ALLOWED_ORIGINS: '["http://localhost:5173","http://localhost:8080"]'
ports:
- "8001:8001"
networks:
- pricelens-net
depends_on:
postgres:
condition: service_healthy
search-service:
build: ./services/search-service
container_name: pricelens-search-service
environment:
REDIS_URL: redis://redis:6379/0
SEARCH_CACHE_TTL_SECONDS: 600
CELERY_BROKER_URL: amqp://pricelens:pricelens_dev_password@rabbitmq:5672//
CELERY_RESULT_BACKEND: redis://redis:6379/1
CORS_ALLOWED_ORIGINS: '["http://localhost:5173","http://localhost:8080"]'
ports:
- "8002:8002"
networks:
- pricelens-net
depends_on:
redis:
condition: service_healthy
rabbitmq:
condition: service_healthy
tracking-service:
build: ./services/tracking-service
container_name: pricelens-tracking-service
environment:
DATABASE_URL: postgresql://pricelens:pricelens_dev_password@postgres:5432/pricelens_tracking
JWT_SECRET_KEY: ${JWT_SECRET_KEY}
JWT_ALGORITHM: HS256
CORS_ALLOWED_ORIGINS: '["http://localhost:5173","http://localhost:8080"]'
ports:
- "8003:8003"
networks:
- pricelens-net
depends_on:
postgres:
condition: service_healthy
analytics-service:
build: ./services/analytics-service
container_name: pricelens-analytics-service
environment:
# Service name, not localhost -- this is the Compose networking
# change called out above. tracking-service is reachable by this
# hostname only inside the pricelens-net network Compose creates.
TRACKING_SERVICE_URL: http://tracking-service:8003
TRACKING_SERVICE_TIMEOUT_SECONDS: 5
CORS_ALLOWED_ORIGINS: '["http://localhost:5173","http://localhost:8080"]'
ports:
- "8004:8003"
networks:
- pricelens-net
depends_on:
- tracking-service
# ---------------------------------------------------------------------
# Scraper: same image, two different roles via different `command:`
# ---------------------------------------------------------------------
scraper-service:
build: ./services/scraper-service
container_name: pricelens-scraper-service
environment:
SELENIUM_HEADLESS: "true"
SELENIUM_PAGE_LOAD_TIMEOUT: 20
SELENIUM_IMPLICIT_WAIT: 5
CELERY_BROKER_URL: amqp://pricelens:pricelens_dev_password@rabbitmq:5672//
CELERY_RESULT_BACKEND: redis://redis:6379/1
ports:
- "8006:8006"
networks:
- pricelens-net
depends_on:
rabbitmq:
condition: service_healthy
scraper-worker:
build: ./services/scraper-service
container_name: pricelens-scraper-worker
# Overrides the Dockerfile's default CMD (the FastAPI server) to run
# a Celery worker instead -- this is the "same image, different role"
# pattern flagged in Phase 12's scraper-service Dockerfile comments.
command: celery -A celery_app worker --loglevel=info --concurrency=2
environment:
SELENIUM_HEADLESS: "true"
SELENIUM_PAGE_LOAD_TIMEOUT: 20
SELENIUM_IMPLICIT_WAIT: 5
CELERY_BROKER_URL: amqp://pricelens:pricelens_dev_password@rabbitmq:5672//
CELERY_RESULT_BACKEND: redis://redis:6379/1
ports:
- "9100:9100"
networks:
- pricelens-net
depends_on:
rabbitmq:
condition: service_healthy
# Headless Chrome inside Docker needs more than the tiny default
# /dev/shm size (64MB) or it crashes with "session not created" --
# this is a well-known Selenium-in-Docker gotcha, not a project bug.
shm_size: "1gb"
# ---------------------------------------------------------------------
# Frontend
# ---------------------------------------------------------------------
frontend:
build:
context: ./frontend
args:
VITE_AUTH_SERVICE_URL: http://localhost:8001
VITE_SEARCH_SERVICE_URL: http://localhost:8002
VITE_TRACKING_SERVICE_URL: http://localhost:8003
VITE_ANALYTICS_SERVICE_URL: http://localhost:8004
container_name: pricelens-frontend
ports:
- "8080:80"
networks:
- pricelens-net
depends_on:
- auth-service
- search-service
- tracking-service
- analytics-service