Skip to content

Commit cf794a1

Browse files
committed
include mosquitto mqtt server
1 parent 0946e8e commit cf794a1

5 files changed

+34
-27
lines changed

docker-compose.override.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ services:
2222
- 'default.docker-env'
2323

2424
# Consider adding mosquitto broker
25-
# mqtt:
26-
# ports:
27-
# - 1884:1883
28-
# env_file:
29-
# - 'default.docker-env'
25+
mqtt:
26+
ports:
27+
- 1884:1883
28+
env_file:
29+
- 'default.docker-env'

docker-compose.yml

+11-11
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ services:
2020
# MYSQL Database
2121
db:
2222
# Official MYSQL docker image
23-
image: mariadb:latest
23+
image: mariadb:11.0
2424
environment:
2525
- "MYSQL_HOST=localhost"
2626
- "MARIADB_AUTO_UPGRADE=1"
@@ -34,22 +34,22 @@ services:
3434

3535
redis:
3636
# Official redis image
37-
image: redis:latest
37+
image: redis:7.0
3838
volumes:
3939
- emon-redis-data:/data
4040
logging:
4141
driver: json-file
4242
options:
4343
max-size: "10m"
44-
45-
# Consider including mosquitto broker service
46-
# Needs to be running elsewhere otherwise
47-
# but maybe thats best..
48-
49-
# mqtt:
50-
# image: eclipse-mosquitto:latest
51-
# build: mqtt/.
52-
# restart: always
44+
45+
mqtt:
46+
image: eclipse-mosquitto:2.0
47+
build: mqtt/.
48+
restart: always
49+
logging:
50+
driver: json-file
51+
options:
52+
max-size: "10m"
5353

5454
volumes:
5555
emon-phpfiwa:

mqtt/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
FROM eclipse-mosquitto:latest
2-
1+
FROM eclipse-mosquitto:2.0
2+
COPY mosquitto.conf /mosquitto/config/mosquitto.conf
33
COPY setup.sh /
44
RUN chmod +x /setup.sh
55
RUN /setup.sh

mqtt/mosquitto.conf

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
persistence false
2+
allow_anonymous false
3+
password_file /mosquitto/config/passwd
4+
5+
6+
log_timestamp true
7+
log_timestamp_format %Y-%m-%dT%H:%M:%S
8+
log_type error
9+
log_type warning
10+
log_type notice
11+
log_type information
12+
log_dest file /mosquitto/log/mosquitto.log
13+
log_dest stdout
14+
15+
listener 1883
16+

mqtt/setup.sh

-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
# Disable mosquitto persistance
2-
sed -i "s/^persistence true/persistence false/" /mosquitto/config/mosquitto.conf
3-
# append line: allow_anonymous false
4-
sed -i -n '/allow_anonymous false/!p;$a allow_anonymous false' /mosquitto/config/mosquitto.conf
5-
# append line: password_file /etc/mosquitto/passwd
6-
sed -i -n '/password_file \/mosquitto\/config\/passwd/!p;$a password_file \/mosquitto\/config\/passwd' /mosquitto/config/mosquitto.conf
7-
# append line: log_type error
8-
sed -i -n '/log_type error/!p;$a log_type error' /mosquitto/config/mosquitto.conf
9-
101
# Create mosquitto password file
112
touch /mosquitto/config/passwd
123
mosquitto_passwd -b /mosquitto/config/passwd emonpi emonpimqtt2016

0 commit comments

Comments
 (0)