-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.development.yaml
More file actions
176 lines (165 loc) · 6.17 KB
/
docker-compose.development.yaml
File metadata and controls
176 lines (165 loc) · 6.17 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
# dclint disable service-image-require-explicit-tag
# explicit tags of `autoheal` are multiple years old
# Certbot setup inspired by
# https://github.com/wmnnd/nginx-certbot/blob/master/docker-compose.yaml
# and
# https://pentacent.medium.com/nginx-and-lets-encrypt-with-docker-in-less-than-5-minutes-b4b8a60d3a71
# See also
# https://certbot.eff.org/docs/install.html#running-with-docker
# Telemetry (logs and metrics) setup inspired by
# https://github.com/VictoriaMetrics/VictoriaLogs/blob/master/deployment/docker/compose-vl-single.yaml
# https://github.com/VictoriaMetrics/VictoriaLogs/blob/master/deployment/docker/victorialogs/compose-base.yaml
# https://github.com/VictoriaMetrics/VictoriaLogs/blob/master/deployment/docker/victorialogs/vector/compose-base.yaml
name: "${NAME}"
services:
# https://hub.docker.com/_/nginx
reverse_proxy:
image: "nginx:1.31-trixie-otel"
volumes:
- ./nginx/.htpasswd:/etc/apache2/.htpasswd:ro
- ./nginx/templates:/etc/nginx/templates:ro
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/html:/etc/nginx/html:ro
- ./certbot/conf:/etc/letsencrypt:ro
- ./certbot/www:/var/www/certbot:ro
- ../development:/app/production:ro
- ../development:/app/staging:ro
environment:
ENVIRONMENT: "${ENVIRONMENT:?required}"
HOST: "${HOST:?required}"
PRODUCTION_SUBDOMAIN: "${PRODUCTION_SUBDOMAIN:?required}"
STAGING_SUBDOMAIN: "${STAGING_SUBDOMAIN:?required}"
TELEMETRY_SUBDOMAIN: "${TELEMETRY_SUBDOMAIN:?required}"
PRODUCTION_HTTP_PORT: "${PRODUCTION_HTTP_PORT:?required}"
STAGING_HTTP_PORT: "${STAGING_HTTP_PORT:?required}"
MONITOR_HTTP_PORT: "${MONITOR_HTTP_PORT:?required}"
LOGS_HTTP_PORT: "${LOGS_HTTP_PORT:?required}"
METRICS_HTTP_PORT: "${METRICS_HTTP_PORT:?required}"
ports:
- "0.0.0.0:${HTTP_PORT:?required}:80"
- "0.0.0.0:${HTTPS_PORT:?required}:443"
extra_hosts:
- "host.docker.internal:host-gateway"
command: ["nginx-debug", "-g", "daemon off;"]
restart: "unless-stopped"
healthcheck:
test: ["CMD-SHELL", "service nginx status || exit 1"]
interval: "5s"
timeout: "5s"
retries: "5"
labels:
autoheal: "true"
# # Grafana instance configured with VictoriaLogs as datasource
# # https://github.com/VictoriaMetrics/VictoriaLogs/blob/master/deployment/docker/compose-vl-single.yaml
# grafana:
# image: grafana/grafana:12.3.1
# depends_on:
# - "victoriametrics"
# - "victorialogs"
# ports:
# - 3000:3000
# volumes:
# - grafanadata:/var/lib/grafana
# - ./provisioning/datasources/victoriametrics-logs-datasource/single.yaml:/etc/grafana/provisioning/datasources/single.yaml
# - ./provisioning/dashboards:/etc/grafana/provisioning/dashboards
# - ./../../dashboards/victorialogs.json:/var/lib/grafana/dashboards/victorialogs.json
# - ./../../dashboards/victorialogs-internal.json:/var/lib/grafana/dashboards/victorialogs-internal.json
# environment:
# - "GF_INSTALL_PLUGINS=victoriametrics-logs-datasource"
# restart: unless-stopped
# labels:
# autoheal: "true"
# https://hub.docker.com/r/victoriametrics/victoria-logs
logs:
image: "victoriametrics/victoria-logs:v1.50.0"
volumes:
- logs:/storage
ports:
- "0.0.0.0:${LOGS_HTTP_PORT}:9428"
command:
- "-storageDataPath=/storage"
- "-loggerFormat=json"
- "-retentionPeriod=7d"
# - -journald.streamFields=_HOSTNAME,_SYSTEMD_UNIT,_PID
# - -journald.ignoreFields=MESSAGE_ID,INVOCATION_ID,USER_INVOCATION_ID
# - -journald.ignoreFields=_BOOT_ID,_MACHINE_ID,_SYSTEMD_INVOCATION_ID,_STREAM_ID,_UID
restart: "unless-stopped"
healthcheck:
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:9428/health"]
interval: "1s"
timeout: "1s"
retries: "10"
labels:
autoheal: "true"
# https://hub.docker.com/r/victoriametrics/victoria-metrics
metrics:
image: "victoriametrics/victoria-metrics:v1.144.0"
volumes:
- metrics:/storage
ports:
- "0.0.0.0:${METRICS_HTTP_PORT}:8428"
command:
- "-storageDataPath=/storage"
- "-loggerFormat=json"
- "-retentionPeriod=1d"
restart: "unless-stopped"
healthcheck:
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:8428/health"]
interval: "1s"
timeout: "1s"
retries: "10"
labels:
autoheal: "true"
profiles:
- "manual"
# Fetch TLS certificates from Let's Encrypt
# https://hub.docker.com/r/certbot/certbot
certbot:
image: "certbot/certbot:v5.6.0"
volumes:
- ./certbot/conf:/etc/letsencrypt # --config-dir
- ./certbot/letsencrypt:/var/lib/letsencrypt # --work-dir
- ./certbot/logs:/var/log/letsencrypt # --logs-dir
- ./certbot/www:/var/www/certbot # --webroot-path
profiles:
- "manual"
# Monitor and restart unhealthy docker containers
# https://github.com/willfarrell/docker-autoheal
autoheal:
image: "willfarrell/autoheal:latest"
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock
environment:
AUTOHEAL_CONTAINER_LABEL: "autoheal"
AUTOHEAL_INTERVAL: 120 # check every 120 seconds
AUTOHEAL_START_PERIOD: 120 # wait 120 seconds before first health check
AUTOHEAL_DEFAULT_STOP_TIMEOUT: 60 # wait 60 seconds for a container to stop before killing during restarts
AUTOHEAL_ONLY_MONITOR_RUNNING: true
network_mode: "none"
restart: "unless-stopped"
deploy:
replicas: 1
profiles:
- "manual"
# Test for example `./docker.mk setup` within `./docker.mk machine`
machine:
build:
context: "."
dockerfile: "./Dockerfile.development"
volumes:
- .:/app/machine
- ../development:/app/production
- ../development:/app/staging
ports:
- "0.0.0.0:${MONITOR_HTTP_PORT:?required}:${MONITOR_HTTP_PORT:?required}"
- "0.0.0.0:${TELEMETRY_GPRC_PORT:?required}:${TELEMETRY_GPRC_PORT:?required}"
- "0.0.0.0:${TELEMETRY_HTTP_PORT:?required}:${TELEMETRY_HTTP_PORT:?required}"
extra_hosts:
- "host.docker.internal:host-gateway"
restart: "no"
profiles:
- "manual"
volumes:
logs:
metrics: