-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
134 lines (122 loc) · 3.44 KB
/
Copy pathdocker-compose.yml
File metadata and controls
134 lines (122 loc) · 3.44 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
# ============================================================
# docker-compose.yml
# ============================================================
# Full stack: Redis + API server + dedicated worker process
#
# Usage
# -----
# docker-compose up --build # start everything
# docker-compose up --build api # API only
# docker-compose logs -f api # stream API logs
# docker-compose down -v # stop + remove volumes
#
# Services
# --------
# redis — Redis 7, data persisted to a named volume
# api — FastAPI server (port 8000) with Swagger UI
# worker — Standalone worker daemon (no HTTP, just task processing)
#
# Ports
# -----
# http://localhost:8000/docs → Swagger UI
# http://localhost:8000/health → Health check
# http://localhost:6379 → Redis (internal)
# ============================================================
version: "3.9"
services:
# ── Redis ──────────────────────────────────────────────────
redis:
image: redis:7-alpine
container_name: tq-redis
ports:
- "6379:6379"
volumes:
- redis_data:/data
command: >
redis-server
--save 60 1
--loglevel warning
--maxmemory 256mb
--maxmemory-policy allkeys-lru
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
restart: unless-stopped
networks:
- tq-net
# ── API server ─────────────────────────────────────────────
api:
build:
context: .
target: runtime
container_name: tq-api
ports:
- "8000:8000"
environment:
REDIS_URL: redis://redis:6379/0
APP_PORT: "8000"
WORKERS: "8"
LOG_LEVEL: info
depends_on:
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "python", "-c",
"import urllib.request; urllib.request.urlopen('http://localhost:8000/health/live')"]
interval: 10s
timeout: 5s
retries: 3
start_period: 15s
restart: unless-stopped
networks:
- tq-net
volumes:
# Mount source in dev so code changes reload without rebuild
- .:/app
command: >
uvicorn api.main:app
--host 0.0.0.0
--port 8000
--reload
--log-level info
# ── Worker daemon (standalone, no HTTP) ────────────────────
worker:
build:
context: .
target: runtime
container_name: tq-worker
environment:
REDIS_URL: redis://redis:6379/0
WORKERS: "4"
depends_on:
redis:
condition: service_healthy
restart: unless-stopped
networks:
- tq-net
volumes:
- .:/app
command: python worker_daemon.py
# ── Redis Commander (optional web UI for Redis) ─────────────
redis-ui:
image: rediscommander/redis-commander:latest
container_name: tq-redis-ui
ports:
- "8081:8081"
environment:
REDIS_HOSTS: local:redis:6379
depends_on:
- redis
restart: unless-stopped
networks:
- tq-net
profiles:
- debug # Only starts with: docker-compose --profile debug up
volumes:
redis_data:
driver: local
networks:
tq-net:
driver: bridge