-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker-compose.yml
410 lines (398 loc) · 14 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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
---
# networks for comm
networks:
socket_proxy:
internal: true
svcs:
# no access to other services
nosvcs:
services:
proxy:
# The official v2 Traefik docker image
image: traefik:v2.11.16
restart: always
# Enables the web UI and tells Traefik to listen to docker
command:
# we are gona use apis
- --api=true
- --api.insecure=true
- --api.dashboard=true
# need healthcheck
- --ping=true
# we run in docker so use it to provide info
- --providers.docker=true
- --providers.docker.exposedByDefault=false
- --providers.docker.endpoint=tcp://socket-proxy:2375
- --providers.file.directory=/rules
- --providers.file.watch=true
# be quiet please
- --global.checkNewVersion=false
- --global.sendAnonymousUsage=false
# debug levels
- --log.level=WARNING
# entrypoints definitions
- --entryPoints.traefik.address=:8080
- --entryPoints.web-bad.address=:80
- --entryPoints.web-sec.address=:443
# luftdaten2mqtt ingest
- --entryPoints.luftdaten.address=:8081
# cf ip's to resolve clients
- --entrypoints.web-sec.forwardedHeaders.trustedIPs=173.245.48.0/20,103.21.244.0/22,103.22.200.0/22,103.31.4.0/22,141.101.64.0/18,108.162.192.0/18,190.93.240.0/20,188.114.96.0/20,197.234.240.0/22,198.41.128.0/17,162.158.0.0/15,104.16.0.0/12,172.64.0.0/13,131.0.72.0/22,192.168.99.0/24,192.168.166.0/24
# certresolver ... attach to entrypoint
- --entrypoints.web-sec.http.tls.certresolver=dns-cloudflare
# domain names for all
- --entrypoints.web-sec.http.tls.domains[0].main=$BASE_DOMAIN
- --entrypoints.web-sec.http.tls.domains[0].sans=*.$BASE_DOMAIN
# letsencrypt via cf
# LetsEncrypt Staging Server - uncomment when testing
#- --certificatesResolvers.dns-cloudflare.acme.caServer=https://acme-staging-v02.api.letsencrypt.org/directory
- --certificatesResolvers.dns-cloudflare.acme.email=$CLOUDFLARE_EMAIL
- --certificatesResolvers.dns-cloudflare.acme.storage=/acme.json
- --certificatesResolvers.dns-cloudflare.acme.dnsChallenge.provider=cloudflare
- --certificatesResolvers.dns-cloudflare.acme.dnsChallenge.resolvers=1.1.1.1:53,1.0.0.1:53
- --certificatesResolvers.dns-cloudflare.acme.dnsChallenge.delayBeforeCheck=15
ports:
# The HTTP port
- "80:80"
- "443:443"
# The Web UI (enabled by --api.insecure=true)
- "8080:8080"
- "8081:8081"
volumes:
# So that Traefik can listen to the Docker events
- ./traefik/acme/acme.json:/acme.json
- ./traefik/rules:/rules
labels:
- "traefik.enable=true"
# HTTP-to-HTTPS Redirect
- "traefik.http.routers.http-catchall.entrypoints=web-bad"
- "traefik.http.routers.http-catchall.priority=1"
- "traefik.http.routers.http-catchall.rule=HostRegexp(`{host:.+}`)"
- "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
- "traefik.http.middlewares.redirect-to-https.redirectscheme.permanent=true"
# internal ip's middleware
- "traefik.http.middlewares.internal-ips.ipallowlist.sourcerange=127.0.0.0/8,192.168.0.0/16,172.16.0.0/12,10.0.0.0/8"
# prefix stripper middleware
- "traefik.http.middlewares.strip-prefix-1.redirectregex.regex=^(https?://[^/]+/[a-z0-9_]+)$$"
- "traefik.http.middlewares.strip-prefix-1.redirectregex.replacement=$${1}/"
- "traefik.http.middlewares.strip-prefix-1.redirectregex.permanent=true"
- "traefik.http.middlewares.strip-prefix-2.stripprefixregex.regex=/[a-z0-9_]+"
- "traefik.http.middlewares.strip-prefix.chain.middlewares=strip-prefix-1,strip-prefix-2"
networks:
- svcs
- socket_proxy
environment:
# secrets for cloudflare
- CF_API_EMAIL=$CLOUDFLARE_EMAIL
- CF_API_KEY=$CLOUDFLARE_API_TOKEN
depends_on:
- socket-proxy
healthcheck:
test: 'traefik healthcheck --ping | grep OK || exit 1'
traefik-certs-dumper:
image: ldez/traefik-certs-dumper:v2.9.3
entrypoint: sh -c '
apk add jq
; while ! [ -e /data/acme.json ]
|| ! [ `jq ".[] | .Certificates | length" /data/acme.json` != 0 ]; do
sleep 1
; done
&& traefik-certs-dumper file --version v2 --watch
--domain-subdir=true --crt-ext=.pem --key-ext=.pem
--crt-name=fullchain --key-name=privkey
--source /data/acme.json --dest /data/certs'
volumes:
- ./traefik/acme/acme.json:/data/acme.json:ro
- ./certdumper:/data/certs
networks:
- nosvcs
depends_on:
- proxy
homeassistant:
restart: always
image: homeassistant/home-assistant:2024.11.3
expose:
- "8123"
volumes:
- "./homeassistant-config:/config"
depends_on:
- mqtt
labels:
# enable
- "traefik.enable=true"
# Routers
- "traefik.http.routers.hass-rtr.rule=Host(`${HA_DOMAIN}`)"
- "traefik.http.routers.hass-rtr.entrypoints=web-sec"
- "traefik.http.routers.hass-rtr.tls=true"
# and finaly the services
- "traefik.http.routers.hass-rtr.service=hass-svc"
- "traefik.http.services.hass-svc.loadbalancer.server.port=8123"
networks:
- svcs
environment:
- TZ=$TZ
healthcheck:
test: 'curl -m 90 -sLf http://localhost:8123 || date >> /config/healthcheck' #| pkill -9 python3'
interval: 90s
timeout: 60s
retries: 2
mqtt:
restart: always
image: eclipse-mosquitto:2.0.20
user: "1001:1001"
volumes:
- "./mosquitto/config:/mosquitto/config"
- "./mosquitto/log:/mosquitto/log"
- "./mosquitto/data:/mosquitto/data"
ports:
- "1883:1883"
command: /usr/sbin/mosquitto -c /mosquitto/config/mosquitto.conf
networks:
- svcs
environment:
- TZ=$TZ
healthcheck:
test: "mosquitto_sub -E -t '#' -i healthcheck -u ${MQTT_HEALTHCHECK_USER} -P ${MQTT_HEALTHCHECK_PASS}"
interval: 60s
timeout: 5s
retries: 5
luftdaten2mqtt:
restart: unless-stopped
image: zeridon/luftdaten2mqtt:2.0.3
build:
context: https://github.com/zeridon/luftdaten2mqtt.git#v2.0.3
depends_on:
- mqtt
networks:
- svcs
expose:
- "8080"
environment:
- MQTT_HOST=mqtt
- MQTT_USER=${MQTT_LUFTDATEN_USER:-user}
- MQTT_PASS=${MQTT_LUFTDATEN_PASS:-pass}
- LOG_LEVEL=INFO
- TZ=$TZ
labels:
- "traefik.enable=true"
- "traefik.http.routers.luftdaten2mqtt-rtr.entrypoints=luftdaten"
- "traefik.http.routers.luftdaten2mqtt-rtr.rule=HostRegexp(`{host:.+}`)"
- "traefik.http.routers.luftdaten2mqtt-rtr.service=luftdaten2mqtt-svc"
- "traefik.http.routers.luftdaten2mqtt-rtr.middlewares=internal-ips"
- "traefik.http.services.luftdaten2mqtt-svc.loadbalancer.server.port=8080"
healthcheck:
retries: 2
# mDNS/Bonjour/SSDP repeater
# based on https://github.com/alsmith/multicast-relay
# unfortunately has to run in host mode.
#
# to discover shellies: --relay '224.0.1.187:5683'
# Used to enable discovery ... though if it is going to be used is another story
repeater:
image: zeridon/multicast-relay
build:
context: https://github.com/alsmith/multicast-relay.git
restart: unless-stopped
network_mode: "host"
command: --allowNonEther --wait --interfaces ${RELAY_INTERFACES}
#### # InfluxDB - Database for sensor data
#### # Create influxdb.conf
#### influxdb:
#### image: influxdb:latest
#### restart: unless-stopped
#### networks:
#### - svcs
#### security_opt:
#### - no-new-privileges:true
#### expose:
#### - "8086"
#### volumes:
#### # - $DOCKERDIR/influxdb/influxdb.conf:/etc/influxdb/influxdb.conf:ro
#### - ./influxdb/db:/var/lib/influxdb
####
#### # Grafana - Graphical data visualization for InfluxDB data
#### grafana:
#### image: grafana/grafana:latest
#### restart: unless-stopped
#### networks:
#### - svcs
#### security_opt:
#### - no-new-privileges:true
#### ports:
#### - "3000:3000"
#### user: "0"
#### volumes:
#### - ./grafana:/var/lib/grafana
#### # environment:
# yamllint disable-line rule:line-length
#### # GF_INSTALL_PLUGINS: "grafana-clock-panel,grafana-simple-json-datasource,grafana-worldmap-panel,grafana-piechart-panel"
#### depends_on:
#### - influxdb
#### labels:
#### # enable
#### - "traefik.enable=true"
#### # Routers
#### - "traefik.http.routers.grafana-rtr.rule=Host(`grafana.${BASE_DOMAIN}`)"
#### - "traefik.http.routers.grafana-rtr.entrypoints=web-sec"
#### - "traefik.http.routers.grafana-rtr.tls=true"
#### # and finaly the services
#### - "traefik.http.routers.grafana-rtr.service=grafana-svc"
#### - "traefik.http.services.grafana-svc.loadbalancer.server.port=3000"
# Docker Socket Proxy - Security Enchanced Proxy for Docker Socket
socket-proxy:
#image: tecnativa/docker-socket-proxy:edge
image: tecnativa/docker-socket-proxy:edge@sha256:e41b8f0ab1625697c71de0d4ac326822972e96a331999fdbf56f68017d7efc31
restart: always
networks:
- socket_proxy
privileged: true
ports:
- "127.0.0.1:2375:2375" # Port 2375 should only ever get exposed to the internal network.
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
environment:
- TZ=$TZ
- LOG_LEVEL=warning # debug,info,notice,warning,err,crit,alert,emerg
## Variables match the URL prefix (i.e. AUTH blocks access to /auth/* parts of the API, etc.).
# 0 to revoke access.
# 1 to grant access.
## Granted by Default
- EVENTS=1
- PING=1
- VERSION=1
## Revoked by Default
# Security critical
- AUTH=0
- SECRETS=0
- POST=1 # Watchtower
- DELETE=1 # Watchtower
# GET Optons
- BUILD=0
- COMMIT=0
- CONFIGS=0
- CONTAINERS=1 # Traefik, portainer, etc.
- DISABLE_IPV6=1 # no v6 here
- DISTRIBUTION=0
- EXEC=0
- IMAGES=1 # Portainer, Watchtower
- INFO=1 # Portainer
- NETWORKS=1 # Portainer, Watchtower
- NODES=0
- PLUGINS=0
- SERVICES=1 # Portainer
- SESSION=0
- SWARM=0
- SYSTEM=0
- TASKS=1 # Portaienr
- VOLUMES=1 # Portainer
# POST Options
- CONTAINERS_CREATE=1 # WatchTower
- CONTAINERS_START=1 # WatchTower
- CONTAINERS_UPDATE=1 # WatchTower
# DELETE Options
- CONTAINERS_DELETE=1 # WatchTower
- IMAGES_DELETE=1 # WatchTower
# Cloudflare-Companion - Automatic CNAME DNS Creation
cf-companion:
image: tiredofit/traefik-cloudflare-companion:7.3.3
security_opt:
- no-new-privileges:true
restart: unless-stopped
networks:
- socket_proxy
- svcs
environment:
# base container setup
- TZ=$TZ
- TIMEZONE=$TZ
- CONTAINER_COLORIZE_OUTPUT=FALSE
- CONTAINER_ENABLE_SCHEDULING=FALSE
- CONTAINER_ENABLE_MESSAGING=FALSE
- CONTAINER_ENABLE_MONITORING=FALSE
- CONTAINER_ENABLE_LOGROTATE=FALSE
- CONTAINER_ENABLE_LOGSHIPPING=FALSE
# companion setup
# where to point the cname
- TARGET_DOMAIN=$HA_DOMAIN
# domain in which to put the cnames
# cf on free plan does not allow multilevel subdomains over ssl
- DOMAIN1=$BASE_DOMAIN
- DOMAIN1_PROXIED=TRUE
- DOMAIN1_ZONE_ID=$CLOUDFLARE_ZONE_ID # Copy from Cloudflare Overview page
- TRAEFIK_VERSION=2
- CF_EMAIL=$CLOUDFLARE_EMAIL
- CF_TOKEN=$CLOUDFLARE_API_TOKEN
- DOCKER_HOST=tcp://socket-proxy:2375
- REFRESH_ENTRIES=TRUE
- CONTAINER_LOG_LEVEL=VERBOSE
#- DEFAULT_TTL=120
- ENABLE_TRAEFIK_POLL=TRUE
- TRAEFIK_POLL_URL=http://proxy:8080
depends_on:
- socket-proxy
- proxy
#labels:
# Add hosts specified in rules here to force cf-companion to create the CNAMEs
# Since cf-companion creates CNAMEs based on host rules, this a workaround for non-docker/external apps
#- "traefik.http.routers.cf-companion-rtr.rule=Host(`portainer.$DOMAIN`) || `synglances.$DOMAIN`)"
#### tasmopiler:
#### image: benzino77/tasmocompiler
#### restart: unless-stopped
#### networks:
#### - svcs
#### expose:
#### - "3000"
#### labels:
#### - "traefik.enable=true"
#### - "traefik.http.routers.tasmopiler-rtr.entrypoints=web-sec"
#### - "traefik.http.routers.tasmopiler-rtr.tls=true"
#### - "traefik.http.routers.tasmopiler-rtr.rule=Host(`tasmopiler.${BASE_DOMAIN}`)"
#### - "traefik.http.routers.tasmopiler-rtr.middlewares=internal-ips"
esphome:
image: esphome/esphome:2024.12.2
restart: unless-stopped
networks:
- svcs
volumes:
- "./esphome:/config"
expose:
- "6052"
labels:
- "traefik.enable=true"
- "traefik.http.routers.esphome-rtr.entrypoints=web-sec"
- "traefik.http.routers.esphome-rtr.tls=true"
- "traefik.http.routers.esphome-rtr.rule=Host(`home.${BASE_DOMAIN}`) && PathPrefix(`/esphome`)"
- "traefik.http.routers.esphome-rtr.middlewares=internal-ips,strip-prefix"
depends_on:
- proxy
environment:
- ESPHOME_DASHBOARD_USE_PING=true
healthcheck:
test: 'curl -f -m2 http://localhost:6052/ | grep ESPHome || exit 1'
timeout: 3s
retries: 2
zigbee2mqtt:
image: koenkk/zigbee2mqtt:1.42.0
restart: always
networks:
- svcs
volumes:
- "./zigbee2mqtt:/app/data"
- "/run/udev:/run/udev:ro"
environment:
- TZ=Europe/Sofia
expose:
- "9090"
labels:
- "traefik.enable=true"
- "traefik.http.routers.z2m-rtr.entrypoints=web-sec"
- "traefik.http.routers.z2m-rtr.tls=true"
- "traefik.http.routers.z2m-rtr.rule=Host(`home.${BASE_DOMAIN}`) && PathPrefix(`/z2m`)"
- "traefik.http.routers.z2m-rtr.middlewares=internal-ips,strip-prefix"
depends_on:
- proxy
healthcheck:
test: 'wget -q -T2 -O- http://localhost:9090/ | grep Zigbee2MQTT || exit 1'
timeout: 3s
retries: 2