@@ -6,6 +6,10 @@ RUN apt update && apt install -y rsync
66
77# where IOTstack template files are stored
88ENV IOTSTACK_DEFAULTS_DIR="iotstack_defaults"
9+ ENV BASELINE_CONFIG=/${IOTSTACK_DEFAULTS_DIR}/telegraf-reference.conf
10+ ENV IOTSTACK_CONFIG=/${IOTSTACK_DEFAULTS_DIR}/telegraf.conf
11+ ENV IOTSTACK_ENTRY_POINT="entrypoint.sh"
12+ ENV BASELINE_ENTRY_POINT="entrypoint-reference.sh"
913
1014# copy template files to image
1115COPY ${IOTSTACK_DEFAULTS_DIR} /${IOTSTACK_DEFAULTS_DIR}
@@ -14,22 +18,25 @@ COPY ${IOTSTACK_DEFAULTS_DIR} /${IOTSTACK_DEFAULTS_DIR}
1418# a baseline reference for the user, and make it read-only.
1519# 2. strip comment lines and blank lines from the baseline reference to
1620# use as the starting point for the IOTstack default configuration.
17- # 3. edit the IOTstack default configuration to insert an appropriate
18- # URL for influxdb running in another container in the same stack.
19- ENV BASELINE_CONFIG=/${IOTSTACK_DEFAULTS_DIR}/telegraf-reference.conf
20- ENV IOTSTACK_CONFIG=/${IOTSTACK_DEFAULTS_DIR}/telegraf.conf
21+ # 3. append auto-inclusions which, among other things, sets up the
22+ # the appropriate URL for influxdb running in another container in
23+ # the same stack.
2124RUN cp /etc/telegraf/telegraf.conf ${BASELINE_CONFIG} && \
25+ cat /${IOTSTACK_DEFAULTS_DIR}/auto_include/*.conf >> ${BASELINE_CONFIG} && \
26+ rm -r /${IOTSTACK_DEFAULTS_DIR}/auto_include && \
2227 chmod 444 ${BASELINE_CONFIG} && \
23- grep -v -e "^[ ]*#" -e "^[ ]*$" ${BASELINE_CONFIG} >${IOTSTACK_CONFIG} && \
24- sed -i '/^\[\[ outputs.influxdb\]\] /a\ \ urls = ["http://influxdb:8086"]' ${IOTSTACK_CONFIG}
25- ENV BASELINE_CONFIG=
26- ENV IOTSTACK_CONFIG=
28+ grep -v -e "^[ ]*#" -e "^[ ]*$" ${BASELINE_CONFIG} >${IOTSTACK_CONFIG}
2729
2830# replace the docker entry-point script with a self-repairing version
29- ENV IOTSTACK_ENTRY_POINT= "entrypoint.sh"
31+ RUN cp /${ IOTSTACK_ENTRY_POINT} /${BASELINE_ENTRY_POINT}
3032COPY ${IOTSTACK_ENTRY_POINT} /${IOTSTACK_ENTRY_POINT}
3133RUN chmod 755 /${IOTSTACK_ENTRY_POINT}
34+
35+ # undefine variables not needed at runtime
36+ ENV BASELINE_CONFIG=
37+ ENV IOTSTACK_CONFIG=
3238ENV IOTSTACK_ENTRY_POINT=
39+ ENV BASELINE_ENTRY_POINT=
3340
3441# IOTstack declares this path for persistent storage
3542VOLUME ["/etc/telegraf" ]
0 commit comments