Skip to content

Commit 0c809b1

Browse files
committed
20210823 Telegraf - master branch - PR 1 of 3
1. Implements self-repair functionality by adding `Dockerfile` and `entrypoint.sh` to the Telegraf template. 2. Removes `telegraf.conf` from Telegraf template. The default configuration file is now the one supplied with the container downloaded from DockerHub. In other words, it will always be kept up-to-date by the container's maintainers. 3. Alters service definition to: * use a persistent storage area in `./volumes/telegraf` * remove the old `./services/telegraf/telegraf.conf` file mapping * add explicit mappings for all exposed ports. 4. Removes build.py as no longer required for copying the old `telegraf.conf` into the `services` directory. 5. Adds documentation for container.
1 parent 65fe9d9 commit 0c809b1

File tree

6 files changed

+289
-392
lines changed

6 files changed

+289
-392
lines changed

.templates/telegraf/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Download base image
2+
FROM telegraf:latest
3+
4+
# Add support tool
5+
RUN apt update && apt install -y rsync
6+
7+
# where IOTstack template files are stored
8+
ENV IOTSTACK_DEFAULTS_DIR="iotstack_defaults"
9+
10+
# make a copy of the default config file
11+
RUN mkdir -p /${IOTSTACK_DEFAULTS_DIR} && \
12+
cp /etc/telegraf/telegraf.conf /${IOTSTACK_DEFAULTS_DIR}/
13+
14+
# replace the docker entry-point script with a self-repairing version
15+
ENV IOTSTACK_ENTRY_POINT="entrypoint.sh"
16+
COPY ${IOTSTACK_ENTRY_POINT} /${IOTSTACK_ENTRY_POINT}
17+
RUN chmod 755 /${IOTSTACK_ENTRY_POINT}
18+
ENV IOTSTACK_ENTRY_POINT=
19+
20+
# EOF

.templates/telegraf/build.py

Lines changed: 0 additions & 153 deletions
This file was deleted.

.templates/telegraf/entrypoint.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
set -e
3+
4+
if [ "${1:0:1}" = '-' ]; then
5+
set -- telegraf "$@"
6+
fi
7+
8+
# perform IOTstack self-repair
9+
U="$(id -u)"
10+
T="/etc/telegraf"
11+
if [ "$U" = '0' -a -d "$T" ]; then
12+
rsync -arp --ignore-existing /${IOTSTACK_DEFAULTS_DIR}/ "$T"
13+
chown -R "$U:$U" "$T"
14+
fi
15+
16+
exec "$@"
17+
18+

.templates/telegraf/service.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
telegraf:
22
container_name: telegraf
3-
image: telegraf
3+
build: ./.templates/telegraf/.
44
restart: unless-stopped
5+
environment:
6+
- TZ=Etc/UTC
7+
ports:
8+
- "8092:8092/udp"
9+
- "8094:8094/tcp"
10+
- "8125:8125/udp"
511
volumes:
6-
- ./services/telegraf/telegraf.conf:/etc/telegraf/telegraf.conf:ro
12+
- ./volumes/telegraf/:/etc/telegraf
713
depends_on:
814
- influxdb
915
- mosquitto
1016
networks:
1117
- iotstack_nw
18+

0 commit comments

Comments
 (0)