-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
186 lines (165 loc) · 4.09 KB
/
docker-compose.yml
File metadata and controls
186 lines (165 loc) · 4.09 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
# Containers are prefixed with this name, if not overridden by
name: iot-ws24
# docker volume create ws24_influxdb
# docker volume create ws24_grafana
# create your volumes here
volumes:
influxdb-data:
name: "ws24_influxdb"
external: true
grafana_storage:
name: "ws24_grafana"
external: true
influxdb-config:
# SERVICES
services:
# Automatic container updates
watchtower:
image: containrrr/watchtower
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: --stop-timeout 60s --schedule "0 0 4 * * *" --cleanup=true
profiles: [tig]
# Telegraf
telegraf:
image: docker.io/telegraf:alpine
restart: unless-stopped
environment:
INFLUX_URL: influxdb:8086
INFLUX_ORGANISATION: iot
INFLUX_BUCKET: measurements
INFLUX_TOKEN: /run/secrets/influx-token
secrets:
- influx_token
configs:
- source: telegraf.conf
target: /etc/telegraf/telegraf.conf
depends_on:
- influxdb
labels:
- com.centurylinklabs.watchtower.monitor-only="true"
profiles: [tig]
networks:
- iot-net
# InfluxDB
influxdb:
image: influxdb:2
restart: unless-stopped
ports:
- 8086:8086
environment:
DOCKER_INFLUXDB_INIT_MODE: setup
DOCKER_INFLUXDB_INIT_USERNAME_FILE: /run/secrets/influxdb-admin-username
DOCKER_INFLUXDB_INIT_PASSWORD_FILE: /run/secrets/influxdb-admin-password
DOCKER_INFLUXDB_INIT_ORG: iot
DOCKER_INFLUXDB_INIT_BUCKET: measurements
INFLUXD_HARDENING_ENABLED: true
secrets:
- influxdb-admin-username
- influxdb-admin-password
volumes:
- type: volume
source: influxdb-data
target: /var/lib/influxdb
- type: volume
source: influxdb-config
target: /etc/influxdb
profiles: [tig]
networks:
- iot-net
# Grafana
grafana:
image: grafana/grafana
restart: unless-stopped
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_USER__FILE=/run/secrets/influxdb-admin-username
- GF_SECURITY_ADMIN_PASSWORD__FILE=/run/secrets/grafana-admin-password
secrets:
- influxdb-admin-username
- grafana-admin-password
volumes:
- 'grafana_storage:/var/lib/grafana'
profiles: [tig]
networks:
- iot-net
# MQTT
mqtt:
image: eclipse-mosquitto
restart: unless-stopped
ports:
- 1883:1883
configs:
- source: mosquitto.conf
target: /mosquitto/config/mosquitto.conf
profiles: [mqtt, tig]
networks:
- iot-net
# CoAP
coap:
restart: unless-stopped
build:
context: ./coap2mqtt
dockerfile: Dockerfile
environment:
- COAP_BIND_NAME=0.0.0.0
- MQTT_SERVER=mqtt
ports:
- "5683:5683"
- "5683:5683/udp"
depends_on:
- mqtt
profiles: [mqtt, tig]
networks:
- iot-net
# Network
# https://docs.docker.com/engine/daemon/ipv6/
networks:
iot-net:
enable_ipv6: true
ipam:
config:
- subnet: 2001:db8::/64
# All secrets
secrets:
influxdb-admin-username:
file: ~/secrets/influxdb-admin-username
influxdb-admin-password:
file: ~/secrets/influxdb-admin-password
grafana-admin-password:
file: ~/secrets/grafana-admin-password
influx_token:
file: ~/secrets/influx-token
# Config Files
configs:
telegraf.conf:
content: |
[[secretstores.docker]]
id = "docker_store"
[agent]
interval = "10m"
round_interval = true
#debug = true
quiet = false
[[inputs.mqtt_consumer]]
servers = ["tcp://mqtt:1883"]
topics = [
"sensor/#"
]
data_format = "json"
topic_tag = "topic"
[[outputs.file]]
files = ["stdout"]
data_format = "json"
json_timestamp_units = "1s"
[[outputs.influxdb_v2]]
urls = ["http://$${INFLUX_URL}"]
organization = "$${INFLUX_ORGANISATION}"
bucket = "$${INFLUX_BUCKET}"
token = "@{docker_store:influx_token}"
mosquitto.conf:
content: |
listener 1883
allow_anonymous true