-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
175 lines (166 loc) · 4.52 KB
/
docker-compose.yml
File metadata and controls
175 lines (166 loc) · 4.52 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
services:
nginx:
image: nginx:latest
container_name: taskflow_nginx
ports:
- "80:80" # Expose standard web port
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- api
networks:
- taskflow_net
restart: always
api:
build:
context: .
dockerfile: api/Dockerfile
image: ghcr.io/dhruvkshah75/taskflow-api:latest
container_name: taskflow_api
working_dir: /app
# Production: run migrations first, then start server
command: sh -c "alembic upgrade head && python -m scripts.janitor_script && uvicorn api.main:app --host 0.0.0.0 --port 8000 --workers 4"
env_file: .env.production
expose:
- "8000" # Only internal containers (Nginx) can see this removed: ports: - "8000:8000"(So users can't bypass Nginx)
depends_on:
pgbouncer:
condition: service_healthy
redis-low:
condition: service_healthy
redis-high:
condition: service_started
restart: always
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8000/status || exit 1"]
interval: 30s
timeout: 10s
retries: 5
start_period: 40s
networks:
- taskflow_net
# Production: read-only root filesystem for security
read_only: false
security_opt:
- no-new-privileges:true
volumes:
- ./worker/tasks:/app/worker/tasks # Maps local folder to container
worker:
build:
context: .
dockerfile: worker/Dockerfile
image: ghcr.io/dhruvkshah75/taskflow-worker:latest
working_dir: /app
env_file: .env.production
depends_on:
pgbouncer:
condition: service_healthy
redis-low:
condition: service_healthy
restart: always
networks:
- taskflow_net
deploy:
replicas: 4
security_opt:
- no-new-privileges:true
volumes:
- ./worker/tasks:/app/worker/tasks
queue_manager:
build:
context: .
dockerfile: core/Dockerfile
image: ghcr.io/dhruvkshah75/taskflow-queue-manager:latest
container_name: taskflow_queue_manager
working_dir: /app
env_file: .env.production
depends_on:
api:
condition: service_healthy
pgbouncer:
condition: service_healthy
redis-low:
condition: service_healthy
redis-high:
condition: service_started
restart: always
networks:
- taskflow_net
security_opt:
- no-new-privileges:true
volumes:
- ./worker/tasks:/app/worker/tasks
postgres:
image: postgres:15
container_name: taskflow_postgres
environment:
- POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
# Production: NO external port exposure
# Only internal container network access
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-taskflow_db}"]
interval: 10s
timeout: 5s
retries: 5
networks:
- taskflow_net
restart: always
pgbouncer:
image: edoburu/pgbouncer:latest
container_name: taskflow-pgbouncer
environment:
- DB_USER=${POSTGRES_USER}
- DB_PASSWORD=${POSTGRES_PASSWORD}
- DB_HOST=postgres
- DB_PORT=5432
- POOL_MODE=transaction
- MAX_CLIENT_CONN=1000
- DEFAULT_POOL_SIZE=20
- AUTH_TYPE=scram-sha-256
- LISTEN_PORT=6432
healthcheck:
test: ["CMD", "nc", "-z", "127.0.0.1", "6432"]
interval: 10s
timeout: 5s
retries: 5
depends_on:
postgres:
condition: service_healthy
networks:
- taskflow_net
restart: always
redis-low:
image: redis:7
container_name: taskflow-redis-low
# Production: Enable password authentication
command: ["redis-server", "--save", "60", "1", "--requirepass", "${REDIS_PASSWORD:-changeme}"]
volumes:
- redisdata_low:/data
healthcheck:
test: ["CMD", "redis-cli", "--no-auth-warning", "-a", "${REDIS_PASSWORD:-changeme}", "ping"]
interval: 10s
timeout: 5s
retries: 3
networks:
- taskflow_net
restart: always
redis-high:
image: redis:7
container_name: taskflow-redis-high
command: ["redis-server", "--save", "60", "1", "--requirepass", "${REDIS_PASSWORD:-changeme}"]
volumes:
- redisdata_high:/data
networks:
- taskflow_net
restart: always
volumes:
pgdata:
redisdata_low:
redisdata_high:
networks:
taskflow_net:
driver: bridge