-
Notifications
You must be signed in to change notification settings - Fork 2
/
docker-compose.yml
183 lines (173 loc) · 4.64 KB
/
docker-compose.yml
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
176
177
178
179
180
181
182
183
# The aim of this docker compose file is to provide a good known
# way to build your docker-compose file for Anomaly projects
#
# Before you use this template have a look at the README, note that
# you will require PROJ_NAME and PROJ_FQDN setup in your environment
# for these template to work
#
# This file provides you a template for your development environment
# https://docs.docker.com/compose/compose-file/compose-versioning/
version: "3.8"
volumes:
postgres-data:
redis-data:
minio-data:
services:
# Postgres:
# - In development we read secrets from .env.development
# refer to the production config to see how to use secrets
# via Kubernetes
db:
image: postgres:14-bullseye
container_name: ${PROJ_NAME}-postgres
# Expose for development purposes
ports:
- "5432:5432"
restart: unless-stopped
env_file:
- .env.development
volumes:
- postgres-data:/var/lib/postgresql/data/
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 30s
timeout: 30s
retries: 5
start_period: 30s
# RabbitMQ:
# TaskIQ recommend using rabbitmq for the broker
rabbitmq:
image: rabbitmq:3.12-management
container_name: ${PROJ_NAME}-rabbitmq
restart: unless-stopped
env_file:
- .env.development
ports:
- 15672:15672
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "ping"]
interval: 30s
timeout: 30s
retries: 5
start_period: 30s
# Redis:
# TaskIQ recommend using redis as the task result backend
redis:
image: redis:7-bullseye
container_name: ${PROJ_NAME}-redis
volumes:
- redis-data:/data
restart: unless-stopped
healthcheck:
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
interval: 30s
timeout: 30s
retries: 5
start_period: 30s
# Applicaiton API:
# - In development we read secrets from .env.development
# - Provides a FastAPI based API that runs using uvicorn in development
api:
container_name: ${PROJ_NAME}-api
build:
context: .
dockerfile: Dockerfile
command:
[
"uvicorn",
"${PROJ_NAME}.api:app",
"--host=0.0.0.0",
"--port=80",
"--reload",
]
env_file:
- .env.development
# restart: unless-stopped
ports:
- 8000:80
volumes:
- ./src/${PROJ_NAME}:/opt/${PROJ_NAME}
- ./src/tests:/opt/tests # Mount it so we can keep modifying tests
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
rabbitmq:
condition: service_healthy
# TaskIQ worker
worker:
container_name: ${PROJ_NAME}-worker
build:
context: .
dockerfile: Dockerfile
command: ["taskiq", "worker", "--reload", "${PROJ_NAME}.broker:broker"]
env_file:
- .env.development
restart: unless-stopped
volumes:
- ./src/${PROJ_NAME}:/opt/${PROJ_NAME}
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
rabbitmq:
condition: service_healthy
# TaskIQ scheduler
scheduler:
container_name: ${PROJ_NAME}-scheduler
build:
context: .
dockerfile: Dockerfile
command:
[
"taskiq",
"worker",
"--reload",
"--fs-discover",
"${PROJ_NAME}.broker:broker",
]
env_file:
- .env.development
restart: unless-stopped
volumes:
- ./src/${PROJ_NAME}:/opt/${PROJ_NAME}
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
rabbitmq:
condition: service_healthy
# MinIO server used during development, replaced by object store in prod
minio:
image: minio/minio
container_name: ${PROJ_NAME}-minio
restart: unless-stopped
volumes:
- minio-data:/data
- .cert:/root/.minio/certs
ports:
- 9000:9000
- 9001:9001
env_file:
- .env.development
command: server /data --console-address ":9001"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
createbuckets:
image: minio/mc
container_name: ${PROJ_NAME}-createbuckets
depends_on:
- minio
env_file:
- .env.development
entrypoint: >
/bin/sh -c " /usr/bin/mc config host add $$S3_BUCKET_NAME http://minio:9000 $$MINIO_ROOT_USER $$MINIO_ROOT_PASSWORD; /usr/bin/mc mb -p $$S3_BUCKET_NAME/$$S3_BUCKET_NAME; /usr/bin/mc policy set download $$S3_BUCKET_NAME/$$S3_BUCKET_NAME; exit 0; "
networks:
default:
name: ${PROJ_NAME}-network