-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
144 lines (135 loc) · 3.89 KB
/
docker-compose.yml
File metadata and controls
144 lines (135 loc) · 3.89 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
---
volumes:
sqlite-data:
services:
redis:
image: redis:7-alpine
ports:
- "6379:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
migrate:
build:
context: .
dockerfile: tests/Dockerfile
command: python manage.py migrate --noinput
environment:
DJANGO_SETTINGS_MODULE: tests.config.settings.local
volumes:
- sqlite-data:/data
depends_on:
redis:
condition: service_healthy
django:
container_name: django-app
build:
context: .
dockerfile: tests/Dockerfile
entrypoint: python manage.py runserver 0.0.0.0:8000
environment:
DJANGO_SETTINGS_MODULE: tests.config.settings.local
OTEL_SERVICE_NAME: django-app
DJANGO_O11Y_LOGGING_FILE_PATH: /tmp/django-o11y/django.log
volumes:
- ${DJANGO_O11Y_STACK_LOG_MOUNT:-/tmp/django-o11y}:/tmp/django-o11y
- sqlite-data:/data
ports:
- "8000:8000"
extra_hosts:
- "host.docker.internal:host-gateway"
develop:
watch:
- action: sync
path: ./src
target: /app/src
- action: sync
path: ./tests
target: /app/tests
- action: rebuild
path: pyproject.toml
- action: rebuild
path: uv.lock
depends_on:
migrate:
condition: service_completed_successfully
celery:
build:
context: .
dockerfile: tests/Dockerfile
entrypoint: celery -A tests.celery_app worker
environment:
DJANGO_SETTINGS_MODULE: tests.config.settings.local
OTEL_SERVICE_NAME: celery-worker
DJANGO_O11Y_LOGGING_FILE_PATH: /tmp/django-o11y/celery.log
volumes:
- ${DJANGO_O11Y_STACK_LOG_MOUNT:-/tmp/django-o11y}:/tmp/django-o11y
- sqlite-data:/data
ports:
- "8009:8009"
extra_hosts:
- "host.docker.internal:host-gateway"
develop:
watch:
- action: sync+restart
path: ./src
target: /app/src
- action: sync+restart
path: ./tests
target: /app/tests
- action: rebuild
path: pyproject.toml
- action: rebuild
path: uv.lock
depends_on:
migrate:
condition: service_completed_successfully
task-generator:
image: curlimages/curl:latest
entrypoint: >
sh -c "
echo 'Waiting for django...';
until curl -sf 'http://django:8000/trigger/?x=3&y=4'; do sleep 2; done;
echo 'Django ready, generating tasks every 5s';
while true; do
curl -sf 'http://django:8000/trigger/?x=3&y=4';
sleep 5;
done
"
depends_on:
- django
ws-generator:
image: python:3.12-slim
entrypoint:
- sh
- -c
- |
pip install -q websockets
python - <<'EOF'
import asyncio, json, websockets
WS_URL = "ws://django:8000/ws/echo/"
CONNECTION_TTL = 15
async def run():
print("ws-generator: waiting for django WebSocket...")
while True:
try:
async with websockets.connect(WS_URL) as ws:
print("ws-generator: connected")
n = 0
deadline = asyncio.get_event_loop().time() + CONNECTION_TTL
while asyncio.get_event_loop().time() < deadline:
await ws.send(json.dumps({"msg": "hello", "n": n}))
reply = await ws.recv()
print("ws-generator: echo", reply)
n += 1
await asyncio.sleep(5)
print("ws-generator: reconnecting")
except Exception as exc:
print("ws-generator: error", exc)
await asyncio.sleep(3)
asyncio.run(run())
EOF
depends_on:
- django