Skip to content

Commit ea8d7cc

Browse files
committed
Self-healing Mosquitto (Dockerfile build) - PR 2 of 2 - old-menu branch
Implements discussion contained in [Issue 331](SensorsIot#331): 1. Removes `directoryfix.sh`. No longer appropriate. 2. Adds Dockerfile to template folder. 3. Adds docker-entrypoint.sh to template folder (customised version of original). 4. Adds iotstack_defaults folder structure to template folder. 5. Moves filter.acl and mosquitto.conf into iotstack_defaults/config/ 6. Alters service.yml: * Builds from Dockerfile. * Adds environment key and TZ default. * Moves /mosquitto/config mapping from services to volumes and omits ":ro" flag Does not alter documentation on old-menu branch. Does not remove terminal.sh (mentioned in original old-menu documentation). Both approaches to password creation "work". I decided to leave terminal.sh to minimise the risk of confusion if someone was following the old-menu documentation and was unable to find terminal.sh.
1 parent b71dd61 commit ea8d7cc

File tree

7 files changed

+41
-29
lines changed

7 files changed

+41
-29
lines changed

.templates/mosquitto/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Download base image
2+
FROM eclipse-mosquitto:latest
3+
4+
# Add support tools
5+
RUN apk update && apk add --no-cache rsync tzdata
6+
7+
# where IOTstack template files are stored
8+
ENV IOTSTACK_DEFAULTS_DIR="iotstack_defaults"
9+
10+
# copy template files to image
11+
COPY --chown=mosquitto:mosquitto ${IOTSTACK_DEFAULTS_DIR} /${IOTSTACK_DEFAULTS_DIR}
12+
13+
# replace the docker entry-point script
14+
ENV IOTSTACK_ENTRY_POINT="docker-entrypoint.sh"
15+
COPY ${IOTSTACK_ENTRY_POINT} /${IOTSTACK_ENTRY_POINT}
16+
RUN chmod 755 /${IOTSTACK_ENTRY_POINT}
17+
ENV IOTSTACK_ENTRY_POINT=
18+
19+
# IOTstack also declares these paths
20+
VOLUME ["/mosquitto/config", "/mosquitto/pwfile"]
21+
22+
# EOF

.templates/mosquitto/directoryfix.sh

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/ash
2+
set -e
3+
4+
# Set permissions
5+
user="$(id -u)"
6+
if [ "$user" = '0' -a -d "/mosquitto" ]; then
7+
8+
rsync -arp --ignore-existing /${IOTSTACK_DEFAULTS_DIR}/ "/mosquitto"
9+
10+
chown -R mosquitto:mosquitto /mosquitto
11+
12+
fi
13+
14+
exec "$@"
15+

.templates/mosquitto/iotstack_defaults/pwfile/pwfile

Whitespace-only changes.

.templates/mosquitto/service.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
mosquitto:
22
container_name: mosquitto
3-
image: eclipse-mosquitto
3+
build: ./.templates/mosquitto/.
44
restart: unless-stopped
5-
user: "1883"
5+
environment:
6+
- TZ=Etc/UTC
67
ports:
78
- "1883:1883"
89
volumes:
10+
- ./volumes/mosquitto/config:/mosquitto/config
911
- ./volumes/mosquitto/data:/mosquitto/data
1012
- ./volumes/mosquitto/log:/mosquitto/log
1113
- ./volumes/mosquitto/pwfile:/mosquitto/pwfile
12-
- ./services/mosquitto:/mosquitto/config:ro

0 commit comments

Comments
 (0)