-
Notifications
You must be signed in to change notification settings - Fork 4
/
docker-compose.yml
332 lines (316 loc) · 9.23 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
---
version: "3.9"
services:
# Image used to run tests
test:
image: "${REGISTRY:-docker.io/}${IMAGE_OWNER}/${IMAGE_NAME}:test${VAR}${IMAGE_VER:-latest}"
build:
dockerfile: ${DOCKER_FILE:-deploy/debian.Dockerfile}
target: test-image
args:
BUILDKIT_INLINE_CACHE: "1"
REGISTRY: ${REGISTRY:-docker.io/}
context: .
# secrets:
# - oban_license_key
# - oban_key_fingerprint
# - access_token
environment:
- DATABASE_DB
- DATABASE_HOST=${DATABASE_HOST:-postgres}
- SECRET_KEY_BASE=${SECRET_KEY_BASE:-0cSFk8v5IsZIIGCjY+X66l5xULUl/2mczI4Eqf7slpyns5nBkhegDn6YH9th+5D2}
volumes:
- "./.cache:/var/cache"
- "./junit-reports:/app/_build/test/junit-reports"
- "./sarif-reports:/sarif-reports"
depends_on:
postgres:
condition: service_healthy
# Final deploy image
prod:
image: "${REGISTRY:-docker.io/}${IMAGE_OWNER}/${IMAGE_NAME}:${VAR}${IMAGE_VER:-latest}"
build:
dockerfile: ${DOCKER_FILE:-deploy/debian.Dockerfile}
target: prod
args:
BUILDKIT_INLINE_CACHE: "1"
MIX_ENV: prod
REGISTRY: ${REGISTRY:-docker.io/}
# secrets:
# - oban_license_key
# - oban_key_fingerprint
# - access_token
context: .
environment:
- DATABASE_URL=${DATABASE_URL:-ecto://postgres:postgres@postgres:5432/postgres}
- PORT=4000
- SECRET_KEY_BASE=${SECRET_KEY_BASE:-0cSFk8v5IsZIIGCjY+X66l5xULUl/2mczI4Eqf7slpyns5nBkhegDn6YH9th+5D2}
ports:
- '4000:4000'
# healthcheck:
# test: ["CMD", "curl", "--fail", "http://127.0.0.1:${PORT}/healthz"]
# start_period: 2s
# interval: 1s
# timeout: 1s
# retries: 20
healthcheck:
test: ["CMD", "bin/prod", "eval", "PhoenixContainerExample.Health.liveness()"]
start_period: 2s
interval: 1s
timeout: 1s
retries: 20
depends_on:
postgres:
condition: service_healthy
# Development image
dev:
image: "${REGISTRY:-docker.io/}${IMAGE_OWNER}/${IMAGE_NAME}:dev"
build:
dockerfile: ${DOCKER_FILE:-deploy/debian.Dockerfile}
target: dev
args:
BUILDKIT_INLINE_CACHE: "1"
REGISTRY: ${REGISTRY:-docker.io/}
PUBLIC_REGISTRY: ${REGISTRY:-docker.io/}
context: .
# secrets:
# - oban_license_key
# - oban_key_fingerprint
# - access_token
# VSCode devcontainer needs something running
# command: /bin/sh -c "while sleep 1000; do :; done"
environment:
- DATABASE_DB
- DATABASE_HOST=${DATABASE_HOST:-postgres}
- DATABASE_URL
- SECRET_KEY_BASE=${SECRET_KEY_BASE:-0cSFk8v5IsZIIGCjY+X66l5xULUl/2mczI4Eqf7slpyns5nBkhegDn6YH9th+5D2}
ports:
- '4000:4000'
stdin_open: true
tty: true
cap_add:
- CAP_SYS_ADMIN
volumes:
- ".:/app:delegated"
# - 'nfsmount:/app'
depends_on:
postgres:
condition: service_healthy
# AWS CodeBuild custom build image
codebuild:
image: "${REGISTRY:-docker.io/}foo-app-ecs-build:latest"
# Custom build image for AWS CodeBuild
# build:
# context: .
# dockerfile: deploy/codebuild.Dockerfile
# args:
# BUILDKIT_INLINE_CACHE: "1"
# REGISTRY: ${REGISTRY:-docker.io/}
environment:
- REPO_URL
- TASKDEF=ecs/taskdef-otel.json
# - EARTHLY_BUILDKIT_CACHE_SIZE_MB=30000
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- AWS_DEFAULT_REGION
- DOCKERHUB_USERNAME
- DOCKERHUB_TOKEN
read_only: false
privileged: true
volumes:
- ".:/app:delegated"
# https://docs.datadoghq.com/getting_started/agent/
# https://github.com/DataDog/datadog-agent/blob/main/pkg/config/config_template.yaml
datadog:
image: "${PUBLIC_REGISTRY:-docker.io/}datadog/agent:latest"
# image: public.ecr.aws/datadog/agent:7
# image: gcr.io/datadoghq/agent:7
# volumes:
# # Main Datadog config
# - ./datadog.yml:/etc/datadog-agent/datadog.yaml
# # Log config for service for app
# - ./datadog-conf.yml:/etc/datadog-agent/conf.d/app.d/conf.yml
ports:
- "4317:4317" # OTLP over gRPC
- "4318:4318" # OTLP over HTTP
- "8125:8125/udp" # Datadog DogStatsD metrics receiver
- "8126:8126" # Datadog trace receiver
- "5002:5002" # web ui
- "10518:10518" # Datadog log receiver
healthcheck:
test: ["CMD", "/probe.sh"]
start_period: 1s
interval: 2s
timeout: 5s
retries: 20
environment:
- DD_API_KEY
- DD_SITE
- DD_HOSTNAME="${DD_HOSTNAME:-none}"
- DD_TAGS=${DD_TAGS:-environment:ci}"
- DD_ENV="${DD_ENV:-ci}"
- DD_INSIDE_CI="true"
- DD_CHECKS_TAG_CARDINALITY=high
- DD_CLOUD_PROVIDER_METADATA=aws
- DD_GUI_PORT=5002
- DD_LOG_LEVEL
- DD_LOGS_ENABLED=true
- DD_APM_ENABLED=true
- DD_APM_NON_LOCAL_TRAFFIC=true
- DD_DOGSTATSD_TAG_CARDINALITY=high
- DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true
restart: always
grype:
image: "${PUBLIC_REGISTRY:-docker.io/}anchore/grype"
volumes:
- "./.cache:/var/cache"
- "/var/run/docker.sock:/var/run/docker.sock"
kafka:
image: 'bitnami/kafka:2'
ports:
- '9092'
volumes:
- 'kafka_data:/bitnami'
environment:
- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
- ALLOW_PLAINTEXT_LISTENER=yes
healthcheck:
test: ["CMD", "nc", "-vz", "localhost", "9092"]
start_period: 1s
interval: 2s
timeout: 2s
retries: 20
# healthcheck:
# test: ["CMD-SHELL", "kafka-topics.sh --bootstrap-server 127.0.0.1:9092 --topic <TOPIC_NAME> --describe"]
# interval: 2s
# timeout: 2s
# retries: 15
depends_on:
- zookeeper
mssql:
image: mcr.microsoft.com/mssql/server:2019-latest
environment:
ACCEPT_EULA: "Y"
SA_PASSWORD: some!Password
ports:
- '1433'
mysql:
# https://hub.docker.com/_/mysql
image: "${PUBLIC_REGISTRY:-docker.io/}mysql:8"
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
- MYSQL_DATABASE=test
- MYSQL_ROOT_PASSWORD=
# command: --default-authentication-plugin=mysql_native_password
ports:
- '3306'
volumes:
- mysql_data:/var/lib/mysql
# - "./db/mysql/initdb.d:/docker-entrypoint-initdb.d"
restart: always
healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "127.0.0.1"]
# test: ["CMD", "mysql" ,"-h", "mysql", "-P", "3306", "-u", "root", "-e", "SELECT 1", "cache"]
start_period: 1s
interval: 1s
timeout: 1s
retries: 10
newman:
# image: "${PUBLIC_REGISTRY:-docker.io/}postman/newman"
image: "${REGISTRY:-docker.io/}${IMAGE_OWNER}/newman"
build:
dockerfile: deploy/newman.Dockerfile
args:
BUILDKIT_INLINE_CACHE: "1"
REGISTRY: ${REGISTRY:-docker.io/}
context: .
volumes:
# Mount Postman files into default location
- "./postman:/etc/newman"
- "./junit-reports:/junit-reports"
# https://github.com/docker-library/docs/blob/master/postgres/README.md
# https://geshan.com.np/blog/2021/12/docker-postgres/
postgres:
image: "${PUBLIC_REGISTRY:-docker.io/}postgres:14.6-alpine"
# build:
# context: .
# dockerfile: deploy/postgres.Dockerfile
# args:
# REGISTRY: ${REGISTRY:-docker.io/}
ports:
- '5432'
user: postgres
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
volumes:
- postgres_data:/var/lib/postgresql/data
# - ./db/postgres/init.sql:/docker-entrypoint-initdb.d/create_tables.sql
restart: always
healthcheck:
# test: ["CMD", "pg_isready -U postgres -d app_test"]
# test: ["psql", "-w", "-U", "postgres", "-d", "app_test", "-c", "SELECT 1"]
test: ["CMD", "pg_isready"]
start_period: 2s
interval: 1s
timeout: 1s
retries: 10
redis:
image: "${PUBLIC_REGISTRY:-docker.io/}redis:4"
ports:
- '6379'
restart: always
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 1s
timeout: 3s
retries: 10
rabbitmq:
image: rabbitmq:3-management
restart: always
ports:
- '5672:5672'
- '8080:15672'
healthcheck:
test: ["CMD", "rabbitmqctl", "status"]
timeout: 5s
interval: 5s
retries: 5
trivy:
# image: "${PUBLIC_REGISTRY:-docker.io/}aquasec/trivy"
image: ghcr.io/aquasecurity/trivy
volumes:
- "./.cache:/var/cache"
- "/var/run/docker.sock:/var/run/docker.sock"
zookeeper:
image: 'bitnami/zookeeper:3'
ports:
- '2181:2181'
volumes:
- 'zookeeper_data:/bitnami'
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
healthcheck:
test: ["CMD", "nc", "-vz", "localhost", "2181"]
interval: 2s
timeout: 2s
retries: 10
volumes:
kafka_data:
driver: local
mysql_data:
driver: local
postgres_data:
driver: local
zookeeper_data:
driver: local
# Secrets for builds
# secrets:
# oban_license_key:
# file: ./.dev_secrets/oban_license_key.txt
# oban_key_fingerprint:
# file: ./.dev_secrets/oban_fingerprint.txt
# # GitHub Personal Access Token
# access_token:
# file: ./.access_token