-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
144 lines (137 loc) · 4.56 KB
/
Copy pathdocker-compose.yml
File metadata and controls
144 lines (137 loc) · 4.56 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
# Development stack — source bind-mounted, Vite HMR on :5173, API on :8000.
# Run: make up
# Admin password (written on first startup): make admin
services:
db:
image: postgres:16-alpine
environment:
POSTGRES_DB: trueppm
POSTGRES_USER: trueppm
POSTGRES_PASSWORD: trueppm
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U trueppm"]
interval: 5s
timeout: 5s
retries: 5
# Valkey is the BSD-licensed Linux Foundation fork of Redis (March 2024
# license change). Wire-compatible with Redis 7 — REDIS_URL stays as-is.
valkey:
image: valkey/valkey:8-alpine
volumes:
- valkey_data:/data
healthcheck:
test: ["CMD", "valkey-cli", "ping"]
interval: 5s
timeout: 5s
retries: 5
api:
build:
context: .
dockerfile: packages/api/Dockerfile
args:
# Local dev uses the precompiled psycopg wheel (no from-source C
# compile) so `make up` rebuilds stay fast. The published/CI image omits
# this arg and keeps the hardened `[c]` default. See #1955.
PSYCOPG_EXTRA: binary
image: trueppm-api:local
command: >
sh -c "
until python manage.py migrate --noinput; do
echo 'DB not ready yet (DNS or connection), retrying in 2s...';
sleep 2;
done &&
python manage.py collectstatic --noinput &&
python manage.py create_admin &&
uvicorn trueppm_api.asgi:application --host 0.0.0.0 --port 8000 --reload"
environment:
DATABASE_URL: postgres://trueppm:trueppm@db:5432/trueppm
REDIS_URL: redis://valkey:6379
DJANGO_SETTINGS_MODULE: trueppm_api.settings.dev
TRUEPPM_ALLOW_DEV_SETTINGS: "1"
SECRET_KEY: dev-secret-key-change-in-prod
TRUEPPM_ADMIN_PASSWORD_FILE: /tmp/trueppm_admin_password
STATIC_ROOT: /app/staticfiles
# Prepend the bind-mounted source so uvicorn --reload picks up changes
# to Python files without requiring a container rebuild.
PYTHONPATH: /app/src
volumes:
- ./packages/api/src:/app/src
ports:
- "8000:8000"
depends_on:
db:
condition: service_healthy
valkey:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "python -c \"import urllib.request; urllib.request.urlopen('http://localhost:8000/api/v1/health/')\""]
interval: 5s
timeout: 5s
retries: 10
start_period: 20s
web:
build:
context: packages/web
dockerfile: Dockerfile
target: dev
command: sh -c "rm -rf /app/node_modules/.vite && npm run dev -- --host 0.0.0.0"
environment:
API_URL: http://api:8000
volumes:
- ./packages/web:/app
- web_node_modules:/app/node_modules
ports:
- "5173:5173"
depends_on:
- api
celery:
image: trueppm-api:local
# --concurrency=2 keeps dev memory under ~150 MB (default=10 caused OOM kills)
command: ["celery", "-A", "trueppm_api.celery", "worker", "--loglevel=info", "--concurrency=2"]
restart: unless-stopped
environment:
DATABASE_URL: postgres://trueppm:trueppm@db:5432/trueppm
REDIS_URL: redis://valkey:6379
DJANGO_SETTINGS_MODULE: trueppm_api.settings.dev
TRUEPPM_ALLOW_DEV_SETTINGS: "1"
SECRET_KEY: dev-secret-key-change-in-prod
PYTHONPATH: /app/src
volumes:
- ./packages/api/src:/app/src
depends_on:
db:
condition: service_healthy
valkey:
condition: service_healthy
celery-beat:
image: trueppm-api:local
# Runs CELERY_BEAT_SCHEDULE periodic tasks (drain_schedule_queue every 30 s, etc.)
# `--schedule=/tmp/...` writes the persistent schedule DB to a writable path;
# the container's working directory is owned by root so the default
# `celerybeat-schedule` write fails with PermissionError (#314 follow-up).
command: ["celery", "-A", "trueppm_api.celery", "beat", "--loglevel=info", "--schedule=/tmp/celerybeat-schedule"]
restart: unless-stopped
environment:
DATABASE_URL: postgres://trueppm:trueppm@db:5432/trueppm
REDIS_URL: redis://valkey:6379
DJANGO_SETTINGS_MODULE: trueppm_api.settings.dev
TRUEPPM_ALLOW_DEV_SETTINGS: "1"
SECRET_KEY: dev-secret-key-change-in-prod
PYTHONPATH: /app/src
volumes:
- ./packages/api/src:/app/src
depends_on:
db:
condition: service_healthy
valkey:
condition: service_healthy
celery:
condition: service_started
volumes:
postgres_data:
valkey_data:
web_node_modules: