diff --git a/docker/Mosquitto/Dockerfile b/docker/Mosquitto/Dockerfile index e72064c74..f2e7c766c 100644 --- a/docker/Mosquitto/Dockerfile +++ b/docker/Mosquitto/Dockerfile @@ -3,6 +3,8 @@ FROM centos:7.9.2009 COPY aclfile /root/ COPY startMosquitto.sh /bin +ENV CONGIF_FROM_ENV true + RUN yum update -y && yum install -y wget \ && yum install -y epel-release \ && yum update -y epel-release \ @@ -10,17 +12,9 @@ RUN yum update -y && yum install -y wget \ && chmod 755 /bin/startMosquitto.sh \ && mkdir /var/log/mosquitto \ && chown mosquitto:mosquitto /var/log/mosquitto \ - && touch /etc/mosquitto/pwfile \ - && sed -i '$ i acl_file /etc/mosquitto/aclfile\npassword_file /etc/mosquitto/pwfile' /etc/mosquitto/mosquitto.conf \ - && echo "log_timestamp true" >> /etc/mosquitto/mosquitto.conf \ - && echo "log_timestamp_format %Y-%m-%dT%H:%M:%S" >> /etc/mosquitto/mosquitto.conf \ - && echo 'listener 9001' >> /etc/mosquitto/mosquitto.conf \ - && echo 'protocol websockets' >> /etc/mosquitto/mosquitto.conf \ - && echo 'listener 1883' >> /etc/mosquitto/mosquitto.conf \ - && echo 'protocol mqtt' >> /etc/mosquitto/mosquitto.conf \ - && mv /root/aclfile /etc/mosquitto/aclfile \ && yum clean all + EXPOSE 1883 EXPOSE 9001 diff --git a/docker/Mosquitto/startMosquitto.sh b/docker/Mosquitto/startMosquitto.sh index 24569d5da..0a24603d9 100755 --- a/docker/Mosquitto/startMosquitto.sh +++ b/docker/Mosquitto/startMosquitto.sh @@ -1,4 +1,16 @@ #!/usr/bin/env bash -mosquitto_passwd -b /etc/mosquitto/pwfile iota ${IOTA_PASS} +if [ "${CONGIF_FROM_ENV}" = true ] ; then + touch /etc/mosquitto/pwfile + sed -i '$ i acl_file /etc/mosquitto/aclfile\npassword_file /etc/mosquitto/pwfile' /etc/mosquitto/mosquitto.conf + echo "log_timestamp true" >> /etc/mosquitto/mosquitto.conf + echo "log_timestamp_format %Y-%m-%dT%H:%M:%S" >> /etc/mosquitto/mosquitto.conf + echo 'listener 9001' >> /etc/mosquitto/mosquitto.conf + echo 'protocol websockets' >> /etc/mosquitto/mosquitto.conf + echo 'listener 1883' >> /etc/mosquitto/mosquitto.conf + echo 'protocol mqtt' >> /etc/mosquitto/mosquitto.conf + mv /root/aclfile /etc/mosquitto/aclfile + mosquitto_passwd -b /etc/mosquitto/pwfile iota ${IOTA_PASS} +fi + /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf