-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
224 lines (215 loc) · 7.85 KB
/
Copy pathdocker-compose.yml
File metadata and controls
224 lines (215 loc) · 7.85 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
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
# Production-style Docker Compose stack mirroring the Kubernetes development
# environment defined under manifests/{mongodb,valkey,deployment/dd-default-development}.
#
# Mapping summary (K8s -> Compose):
# StatefulSet mongodb (replSet rs0, keyFile auth) -> mongodb + mongodb-keyfile-init + mongodb-rs-init
# StatefulSet valkey-service -> valkey-service
# Deployment dd-default-development-blue -> app
# HTTPProxy default.net / www.default.net (Contour) -> proxy (nginx reverse proxy)
# Service type LoadBalancer / NodePort -> published host ports via the proxy
# Secret mongodb-secret / mongodb-keyfile -> .env values + generated keyfile volume
# PVC mongodb-storage / volumeClaimTemplates -> named volumes
name: dd-default-development
services:
# --- MongoDB -------------------------------------------------------------
# Mirrors manifests/mongodb/statefulset.yaml: replSet rs0, keyFile cluster
# auth, --auth, bind to all interfaces. Single-node replica set for local dev.
#
# Bootstrap follows src/db/mongo/MongoBootstrap.js rather than the image's
# MONGO_INITDB_ROOT_USERNAME auto-init (whose temp server + keyFile combination
# is unreliable). The generated entrypoint (docker/mongodb/entrypoint.sh)
# generates the keyfile, starts mongod, and bootstraps the replica set + root
# user over the loopback localhost exception. The healthcheck gates readiness
# on an authenticated writable primary.
mongodb:
image: ${MONGO_IMAGE:-mongo:latest}
container_name: dd-mongodb
entrypoint: ["bash", "/docker-init/entrypoint.sh"]
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME:?set MONGO_INITDB_ROOT_USERNAME in docker/compose.env}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD:?set MONGO_INITDB_ROOT_PASSWORD in docker/compose.env}
DB_REPLICA_SET: ${DB_REPLICA_SET:-rs0}
volumes:
- ./docker/mongodb:/docker-init:ro
- mongodb-keyfile:/opt/keyfile
- mongodb-data:/data/db
networks:
- dd-internal
expose:
- "27017"
ports:
- "${MONGO_HOST_PORT:-27017}:27017"
healthcheck:
test:
- CMD-SHELL
- >
mongosh --quiet -u "$$MONGO_INITDB_ROOT_USERNAME" -p "$$MONGO_INITDB_ROOT_PASSWORD"
--authenticationDatabase admin --eval "db.hello().isWritablePrimary" | grep -q true
interval: 10s
timeout: 5s
retries: 20
start_period: 60s
restart: unless-stopped
# --- Valkey --------------------------------------------------------------
# Mirrors manifests/valkey/statefulset.yaml.
valkey-service:
image: ${VALKEY_IMAGE:-valkey/valkey:latest}
container_name: dd-valkey
command: ["valkey-server", "--port", "6379", "--bind", "0.0.0.0", "--protected-mode", "no"]
volumes:
- valkey-data:/data
networks:
- dd-internal
expose:
- "6379"
# NodePort equivalent (manifests/valkey/valkey-nodeport.yaml nodePort 32079).
ports:
- "${VALKEY_NODEPORT:-32079}:6379"
healthcheck:
test: ["CMD", "valkey-cli", "-p", "6379", "ping"]
interval: 10s
timeout: 5s
retries: 10
start_period: 10s
restart: unless-stopped
# --- Application ---------------------------------------------------------
# Mirrors manifests/deployment/dd-default-development/deployment.yaml
# (dd-default-development-blue). Connection targets use Docker service
# discovery instead of hardcoded localhost.
app:
image: ${APP_IMAGE:-underpost/underpost-engine}:${APP_TAG:-v3.2.22}
container_name: dd-app
# The start command is supplied by the generated override docker/compose.app.yml
# (see `underpost docker-compose --generate --deploy-id <id>`), keeping this
# file deployment-agnostic.
environment:
NODE_ENV: ${NODE_ENV:-development}
DB_PROVIDER: ${DB_PROVIDER:-mongoose}
DB_HOST: ${DB_HOST:-mongodb://mongodb:27017}
DB_NAME: ${DB_NAME:-default}
DB_REPLICA_SET: ${DB_REPLICA_SET:-rs0}
DB_AUTH_SOURCE: ${DB_AUTH_SOURCE:-admin}
DB_USER: ${MONGO_INITDB_ROOT_USERNAME:?}
DB_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD:?}
VALKEY_HOST: ${VALKEY_HOST:-valkey-service}
VALKEY_PORT: ${VALKEY_PORT:-6379}
networks:
- dd-internal
expose:
- "4001"
- "4002"
- "4003"
- "4004"
# Direct access to the LoadBalancer-equivalent ports (manifest 4001-4004).
ports:
- "${APP_PORT_4001:-4001}:4001"
- "${APP_PORT_4002:-4002}:4002"
- "${APP_PORT_4003:-4003}:4003"
- "${APP_PORT_4004:-4004}:4004"
healthcheck:
test: ["CMD-SHELL", "timeout 2 bash -c '</dev/tcp/127.0.0.1/4001' || exit 1"]
interval: 15s
timeout: 5s
retries: 5
start_period: 60s
depends_on:
mongodb:
condition: service_healthy
valkey-service:
condition: service_healthy
restart: unless-stopped
# --- Reverse proxy / NodePort-equivalent load balancer -------------------
# Mirrors manifests/deployment/dd-default-development/proxy.yaml (Contour
# HTTPProxy) using nginx with websocket upgrade support.
proxy:
image: ${PROXY_IMAGE:-nginx:stable-alpine}
container_name: dd-proxy
volumes:
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
networks:
- dd-internal
ports:
- "${PROXY_HTTP_PORT:-80}:80"
healthcheck:
test: ["CMD", "wget", "-q", "-O", "-", "http://127.0.0.1/healthz"]
interval: 15s
timeout: 5s
retries: 5
start_period: 10s
depends_on:
app:
condition: service_started
restart: unless-stopped
# --- Monitoring: Prometheus ----------------------------------------------
# Mirrors manifests/prometheus/deployment.yaml. Scrapes the app's /metrics
# endpoint (prom-client) over the internal network. Config is generated by
# `underpost docker-compose --generate` into docker/prometheus/prometheus.yml.
prometheus:
image: ${PROMETHEUS_IMAGE:-prom/prometheus:latest}
container_name: dd-prometheus
command:
- --config.file=/etc/prometheus/prometheus.yml
- --storage.tsdb.path=/prometheus
volumes:
- ./docker/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus-data:/prometheus
networks:
- dd-internal
expose:
- "9090"
ports:
- "${PROMETHEUS_PORT:-9090}:9090"
healthcheck:
test: ["CMD", "wget", "-q", "-O", "-", "http://127.0.0.1:9090/-/healthy"]
interval: 15s
timeout: 5s
retries: 5
start_period: 15s
depends_on:
app:
condition: service_started
restart: unless-stopped
# --- Monitoring: Grafana -------------------------------------------------
# Mirrors manifests/grafana/deployment.yaml. Prometheus datasource is
# pre-provisioned (generated) so dashboards work out of the box.
grafana:
image: ${GRAFANA_IMAGE:-grafana/grafana:latest}
container_name: dd-grafana
environment:
GF_SECURITY_ADMIN_USER: ${GRAFANA_ADMIN_USER:-admin}
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_ADMIN_PASSWORD:-admin}
GF_USERS_ALLOW_SIGN_UP: "false"
volumes:
- ./docker/grafana/provisioning:/etc/grafana/provisioning:ro
- grafana-data:/var/lib/grafana
networks:
- dd-internal
expose:
- "3000"
ports:
- "${GRAFANA_PORT:-3000}:3000"
healthcheck:
test: ["CMD", "wget", "-q", "-O", "-", "http://127.0.0.1:3000/api/health"]
interval: 15s
timeout: 5s
retries: 5
start_period: 15s
depends_on:
prometheus:
condition: service_started
restart: unless-stopped
networks:
dd-internal:
name: dd-internal
driver: bridge
volumes:
mongodb-data:
name: dd-mongodb-data
mongodb-keyfile:
name: dd-mongodb-keyfile
valkey-data:
name: dd-valkey-data
prometheus-data:
name: dd-prometheus-data
grafana-data:
name: dd-grafana-data