diff --git a/Dockerfile b/Dockerfile index 4508a8d..c0145fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,9 +21,11 @@ RUN \ COPY opt/ /opt COPY etc/ /opt/etc COPY supervisor-mosquitto.conf /etc/supervisor/conf.d/ +COPY crontab /etc/crontab VOLUME /opt/etc VOLUME /opt/data +VOLUME /var/log/supervisor EXPOSE 80/TCP EXPOSE 443/TCP @@ -33,5 +35,5 @@ EXPOSE 9001/tcp WORKDIR /opt -CMD ["env", "LD_LIBRARY_PATH=/opt/lib", "/opt/sbin/mosquitto", "-c", "/opt/etc/mosquitto/mosquitto.conf"] +CMD [ "/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf" ] diff --git a/LICENSE b/LICENSE index 55e92f1..5e88819 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Wolfgang Hottgenroth +Copyright (c) 2019, 2022 Wolfgang Hottgenroth Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/crontab b/crontab new file mode 100644 index 0000000..c35bd55 --- /dev/null +++ b/crontab @@ -0,0 +1,3 @@ +SHELL=/bin/sh +PATH=/usr/bin +*/2 * * * * root supervisorctl start certbot diff --git a/mosquitto-start.sh b/mosquitto-start.sh index 952f0fa..18e9871 100755 --- a/mosquitto-start.sh +++ b/mosquitto-start.sh @@ -3,20 +3,25 @@ IMAGE=registry.gitlab.com/wolutator/mosquitto-with-auth:latest VOLUME_CONFIG=mosquitto-config VOLUME_DATA=mosquitto-data +VOLUME_LOG docker volume inspect $VOLUME_CONFIG > /dev/null || docker volume create $VOLUME_CONFIG docker volume inspect $VOLUME_DATA > /dev/null || docker volume create $VOLUME_DATA +docker volume inspect $VOLUME_LOG > /dev/null || docker volume create $VOLUME_LOG docker pull $IMAGE docker run \ -d \ --rm \ + -p80:80 \ + -p443:443 \ -p1883:1883 \ -p8883:8883 \ -p9001:9001 \ -v $VOLUME_CONFIG:/opt/etc/mosquitto \ -v $VOLUME_DATA:/opt/data \ + -v $VOLUME_LOG:/var/log/supervisor \ --link mariadb \ --name mosquitto \ $IMAGE diff --git a/supervisor-mosquitto.conf b/supervisor-mosquitto.conf index 7348967..090486e 100644 --- a/supervisor-mosquitto.conf +++ b/supervisor-mosquitto.conf @@ -1,3 +1,7 @@ +[supervisord] +nodaemon=true +user=root + [program:mosquitto] environment=LD_LIBRARY_PATH="/opt/lib" command=/opt/sbin/mosquitto -c /opt/etc/mosquitto/mosquitto.conf @@ -8,3 +12,10 @@ autorestart=true command=/usr/bin/certbot renew --standalone autostart=false autorestart=false +startsecs=0 + +[program:cron] +command=/usr/sbin/cron -f +autostart=true +autorestart=true +