Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
152 lines (143 loc) · 4.55 KB
/
Copy pathdocker-compose.yml
File metadata and controls
152 lines (143 loc) · 4.55 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
services:
backend:
build:
context: ./backend
dockerfile: dev.dockerfile
# Init container: creates the bucket.
post_start:
- command: ["python", "manage.py", "ensure_bucket"]
# Run Django under debugpy so VS Code can attach ("Django: attach (Docker)").
command: python -m debugpy --listen 0.0.0.0:5678 manage.py runserver 0.0.0.0:8000
ports:
- "5678:5678" # debugpy; published to the host for VS Code attach
environment:
DB_NAME: uitslagenportaal
DB_USER: uitslagenportaal_user
DB_PASSWORD: password
DB_HOST: db
DB_PORT: "5432"
SECRET_KEY: super-secret
CORS_ALLOWED_ORIGINS: http://localhost:8080
DJANGO_SETTINGS_MODULE: "mainsite.settings"
# The backend uploads over the compose network, but the URLs it hands to
# the browser have to use the published port instead.
S3_ENDPOINT_URL: http://object-storage:9000
S3_PUBLIC_DOMAIN: localhost:9000/uitslagenportaal
S3_URL_PROTOCOL: "http:"
S3_BUCKET_NAME: uitslagenportaal
S3_ACCESS_KEY: uitslagenportaal
S3_SECRET_KEY: password
S3_ADDRESSING_STYLE: path
# Host inotify instance limit is 128; skip inotify and poll instead.
WATCHFILES_FORCE_POLLING: "true"
volumes:
- ./backend:/app
- ./backend/.data:/app/.data
# Hides the host's .venv so its churn cannot trigger the autoreloader; the image installs into system Python.
- /app/.venv
depends_on:
db:
condition: service_healthy
object-storage:
condition: service_healthy
# For running one-off scripts/management commands, e.g.:
# docker compose run --rm backend-scripts python manage.py <command>
backend-scripts:
extends:
service: backend
command: sleep infinity
depends_on: !reset [] # backend-scripts has no service dependencies
ports: !reset [] # do not inherit 5678 from backend; only backend publishes debugpy
post_start: !reset []
celery:
extends:
service: backend
# Celery has no autoreloader of its own, so watchfiles restarts the worker whenever a .py file changes.
# Uses polling under windows. Only Python files in app directories are watched. The SIGINT timeout lets a running
# task finish.
command: >
watchfiles --filter python --sigint-timeout 30
"celery -A mainsite worker --beat --loglevel=INFO"
environment:
WATCHFILES_POLL_DELAY_MS: "1000"
depends_on: !reset []
ports: !reset []
post_start: !reset []
celery-pv-scraper:
extends:
service: celery
profiles:
- with-scraper
command: >
watchfiles --filter python --sigint-timeout 30
"celery -A mainsite worker -Q scraper --loglevel=INFO"
frontend:
build:
context: ./frontend
dockerfile: dev.dockerfile
environment:
# Empty base URL -> requests go to the same origin the page was loaded
# from, which the proxy then routes to the backend.
VITE_API_BASE_URL: ""
# Lets Vite's HMR websocket reconnect through the proxy's published
# port instead of the (unpublished) internal dev-server port.
VITE_HMR_CLIENT_PORT: "8080"
volumes:
- ./frontend:/app
- /app/node_modules
depends_on:
- backend
proxy:
image: nginx:alpine
volumes:
- ./.docker/proxy/nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- "8080:80"
depends_on:
- backend
- frontend
db:
image: postgres:16
environment:
POSTGRES_DB: uitslagenportaal
POSTGRES_USER: uitslagenportaal_user
POSTGRES_PASSWORD: password
volumes:
- db_data:/var/lib/postgresql/data
- ./.docker/postgres-init:/docker-entrypoint-initdb.d:ro
ports:
- "5433:5432"
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U uitslagenportaal_user -d uitslagenportaal" ]
interval: 5s
timeout: 5s
retries: 5
redis:
image: redis:8
ports:
- "6379:6379"
volumes:
- redis_data:/data
# S3-compatible object storage for local dev.
object-storage:
image: rustfs/rustfs:1.0.3
environment:
RUSTFS_ACCESS_KEY: uitslagenportaal
RUSTFS_SECRET_KEY: password
RUSTFS_ADDRESS: "0.0.0.0:9000"
RUSTFS_CONSOLE_ADDRESS: "0.0.0.0:9001"
RUSTFS_CONSOLE_ENABLE: "true"
volumes:
- rustfs_data:/data
ports:
- "9000:9000" # S3 API
- "9001:9001" # Web console
healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost:9000/health" ]
interval: 5s
timeout: 5s
retries: 5
volumes:
db_data:
redis_data:
rustfs_data: