100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Merged haproxy and letsencrypt images
Christian Bauerb62abcdd601e
diff --git a/.gitignore b/.gitignoreindex b5d057c09..14172ec82 100644--- a/.gitignore+++ b/.gitignore@@ -25,5 +25,5 @@ console/iOS/Pods# Ignore build/runtime only datadeployment/manager/consoles/*/bower_components-deployment/haproxy+deployment/proxydeployment/postgresql\ No newline at end of filediff --git a/README.md b/README.mdindex 77d10550d..3bd91f897 100644--- a/README.md+++ b/README.md@@ -39,8 +39,7 @@ Perform a clean build and run all tests (before committing):```docker-compose -p openremote -f profile/dev.yml up -d./gradlew clean build installDist-docker build -t openremote/haproxy:latest haproxy-docker build -t openremote/letsencrypt:latest letsencrypt+docker build -t openremote/proxy:latest haproxydocker build -t openremote/postgresql:latest postgresqldocker build -t openremote/keycloak:latest keycloakdocker build -t openremote/manager:latest manager/build/install@@ -49,8 +48,7 @@ docker build -t openremote/manager:latest manager/build/installPush images to [Docker Hub](https://hub.docker.com/u/openremote):```-docker push openremote/haproxy:latest-docker push openremote/letsencrypt:latest+docker push openremote/proxy:latestdocker push openremote/postgresql:latestdocker push openremote/keycloak:latestdocker push openremote/manager:latestdiff --git a/haproxy/entrypoint.sh b/haproxy/entrypoint.shdeleted file mode 100644index 2974dabbf..000000000--- a/haproxy/entrypoint.sh+++ /dev/null@@ -1,63 +0,0 @@-#!/bin/bash--set -u--CERT_FILE="/opt/selfsigned/localhost.pem"--if [ -n "${DOMAINNAME}" ] && [ "${DOMAINNAME}" != "localhost" ]; then- CERT_FILE="/etc/letsencrypt/live/${DOMAINNAME}/haproxy.pem"-fi--export CERT_FILE=${CERT_FILE}--if [ ! -f ${CERT_FILE} ]; then- HAPROXY_CONFIG="/etc/haproxy/haproxy-init.cfg"-else- HAPROXY_CONFIG="/etc/haproxy/haproxy.cfg"-fi--HAPROXY_USER_PARAMS=$@-HAPROXY_PID_FILE="/var/run/haproxy.pid"-HAPROXY_CMD="haproxy -f ${HAPROXY_CONFIG} ${HAPROXY_USER_PARAMS} -D -p ${HAPROXY_PID_FILE}"-HAPROXY_CHECK_CONFIG_CMD="haproxy -f ${HAPROXY_CONFIG} -c"--log() {- if [[ "$@" ]]; then echo "[`date +'%Y-%m-%d %T'`] $@";- else echo; fi-}--log "DOMAINNAME: ${DOMAINNAME}"-log "CERT_FILE: ${CERT_FILE}"-log "CONFIG: ${HAPROXY_CONFIG}"--rsyslogd--$HAPROXY_CHECK_CONFIG_CMD-$HAPROXY_CMD-if [[ $? != 0 ]] || test -t 0; then exit $?; fi-log "HAProxy started with $HAPROXY_CONFIG config, pid $(cat $HAPROXY_PID_FILE)."--# Check if config or certificates were changed-while inotifywait -q -r --exclude '\.git/' -e modify,create,delete,move,move_self $HAPROXY_CONFIG /etc/letsencrypt; do- if [ -f $HAPROXY_PID_FILE ]; then- log "Restarting HAProxy due to config changes..."-- # Wait for the certificate to be present before restarting or might interrupt cert generation/renewal- log "Waiting for certificate '${CERT_FILE}' to exist..."- while ! ls -l "${CERT_FILE}" >/dev/null 2>&1; do sleep 0.1; done- log "Certificate '${CERT_FILE}' now exists!"- HAPROXY_CONFIG="/etc/haproxy/haproxy.cfg"- HAPROXY_CMD="haproxy -f ${HAPROXY_CONFIG} ${HAPROXY_USER_PARAMS} -D -p ${HAPROXY_PID_FILE}"- HAPROXY_CHECK_CONFIG_CMD="haproxy -f ${HAPROXY_CONFIG} -c"-- if $HAPROXY_CHECK_CONFIG_CMD; then- $HAPROXY_CMD -sf $(cat $HAPROXY_PID_FILE)- log "HAProxy restarted, pid $(cat $HAPROXY_PID_FILE)." && log- else- log "HAProxy config invalid, not restarting..."- fi- else- log "Error: no $HAPROXY_PID_FILE present, HAProxy exited."- break- fi-donediff --git a/letsencrypt/Dockerfile b/letsencrypt/Dockerfiledeleted file mode 100644index 5230a7233..000000000--- a/letsencrypt/Dockerfile+++ /dev/null@@ -1,18 +0,0 @@-# Adapted from https://github.com/bringnow/docker-letsencrypt-manager-FROM centos:7--RUN yum update -y && yum -y install epel-release && yum -y install certbot cronie && yum clean all--ARG DOMAINNAME-ENV DOMAINNAME=${DOMAINNAME:-localhost}-ENV TERM xterm--VOLUME ["/etc/letsencrypt", "/var/acme-webroot"]--COPY cli.ini /root/.config/letsencrypt/--COPY entrypoint.sh /-RUN chmod +x /entrypoint.sh--ENTRYPOINT ["/entrypoint.sh"]-CMD ["help"]\ No newline at end of filediff --git a/postgresql/Dockerfile b/postgresql/Dockerfileindex 23fa4c72f..de27bf167 100644--- a/postgresql/Dockerfile+++ b/postgresql/Dockerfile@@ -30,7 +30,7 @@ RUN curl -L -o /usr/local/bin/gosu https://github.com/tianon/gosu/releases/downl&& gosu nobody true# Prepare data directory-ENV PGDATA /data+ENV PGDATA /deploymentRUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA"# Some defaultsdiff --git a/postgresql/entrypoint.sh b/postgresql/entrypoint.shindex 6088df27e..65a387aaa 100644--- a/postgresql/entrypoint.sh+++ b/postgresql/entrypoint.sh@@ -48,10 +48,8 @@ elseecho "Using existing database(s) in: ${PGDATA}"fi-# Set permissions as on windows permissions will be too relaxed for postgreSQL+# Set permissions as on windows permissions will be too relaxed for postgreSQL (even in Docker volume)chmod -R 0700 ${PGDATA}echo "Starting database server..."exec gosu postgres ${PG_BIN}/postgres "$@"-#gosu postgres ${PG_BIN}/pg_ctl start -w "$@"-#/bin/bash -c "trap : TERM INT; sleep infinity & wait"\ No newline at end of filediff --git a/postgresql/rpi3.Dockerfile b/postgresql/rpi3.Dockerfileindex abee35b04..291421c8f 100644--- a/postgresql/rpi3.Dockerfile+++ b/postgresql/rpi3.Dockerfile@@ -29,7 +29,7 @@ RUN curl -L -o /usr/local/bin/gosu https://github.com/tianon/gosu/releases/downlRUN [ "cross-build-end" ]# Prepare data directory-ENV PGDATA /data+ENV PGDATA /deploymentRUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA"VOLUME ${PGDATA}diff --git a/profile/demo.yml b/profile/demo.ymlindex 6e4e1bc4c..83c5307d7 100644--- a/profile/demo.yml+++ b/profile/demo.yml@@ -5,38 +5,49 @@## Install Docker Community edition (https://docker.com/) on Windows, macOS, or Linux.#-# Start the stack with: docker-compose -p openremote -f profile/demo.yml up+# Start the stack with:#-# All persistent data is stored on your Docker host in the '../deployment' directory. To-# keep your data, set a custom directory with env variable DEPLOYMENT_DIRECTORY and disable-# SETUP_INIT_CLEAN_DATABASE.+# docker-compose -p openremote -f profile/demo.yml up## For full documentation, see deploy.yml#-# This file defines the services to run and their dependencies only.+# This configuration does not store SSL certificate data and allow changes to the+# proxy configuration. You can map a Docker volume or host directory to access/store+# these files.+#+# This configuration expects manager deployment-specific data such as map tiles, console+# application static resources (HTML, JS, CSS), and other configuration files+# to be available in the '../deployment' directory. To set a custom deployment+# directory, use env variable DEPLOYMENT_DIRECTORY.+#+# This configuration stores postgresql data in a Docker volume. You manage this volume+# independently from your stack with with 'docker volume ls', 'docker volume rm', etc.+# Alternatively, you can store postgresql data in a directory on your host.#version: '2.2'+# If you enable volume mappings in services, you need this. Otherwise, remove the volumesvolumes:- data:+# proxy-data:+# name: proxy-data+# manager-data:+# name: manager-data+ postgresql-data:+ name: postgresql-dataservices:- haproxy:+ proxy:extends:file: deploy.yml- service: haproxy+ service: proxydepends_on:manager:condition: service_healthy-- letsencrypt:- extends:- file: deploy.yml- service: letsencrypt- depends_on:- haproxy:- condition: service_healthy+ # volumes:+ # Store data either in host-mapped directory or a named Docker volume+ # - ${DEPLOYMENT_DIRECTORY:-../deployment}/proxy:/deployment+ # - proxy-data:/deploymentmanager:extends:@@ -45,6 +56,10 @@ services:depends_on:keycloak:condition: service_healthy+ volumes:+ # Store data either in host-mapped directory or a named Docker volume+ - ${DEPLOYMENT_DIRECTORY:-../deployment}/manager:/deployment+ # - manager-data:/deploymentkeycloak:extends:@@ -58,3 +73,7 @@ services:extends:file: deploy.ymlservice: postgresql+ volumes:+ # Store data either in host-mapped directory or a named Docker volume+ # - ${DEPLOYMENT_DIRECTORY:-../deployment}/postgresql:/deployment+ - postgresql-data:/deploymentdiff --git a/profile/deploy-rpi.yml b/profile/deploy-rpi.ymlindex 89d57c443..2e11ba1ab 100644--- a/profile/deploy-rpi.yml+++ b/profile/deploy-rpi.yml@@ -4,15 +4,10 @@ version: '2.1'services:- haproxy:+ proxy:extends:file: deploy.yml- service: haproxy-- letsencrypt:- extends:- file: deploy.yml- service: letsencrypt+ service: proxypostgresql:extends:diff --git a/profile/deploy.yml b/profile/deploy.ymlindex be58619f5..fce10e8a3 100644--- a/profile/deploy.yml+++ b/profile/deploy.yml@@ -5,30 +5,26 @@## Install Docker Community edition (https://docker.com/) on Windows, macOS, or Linux.#-# Start the stack with: docker-compose -p openremote -f profile/demo.yml up+# Start the stack with:#-# Note that the demo.yml extends this configuration and declares dependencies between the services.+# docker-compose -p openremote -f profile/demo.yml up#-# All persistent data is stored on your Docker host in the '${DEPLOYMENT_DIRECTORY:-../deployment}' directory.+# Note that you must extend this configuration to complete it with service+# dependencies and volume mappings, see demo.yml.#version: '2.2'services:# The frontend proxy, terminates SSL/TLS connections and forwards them to the Manager backend.- haproxy:+ proxy:# Image will be built when not already in the cache or when `--build` option is supplied to `docker-compose up`build:- context: '../haproxy'+ context: '../proxy'# Image will be pulled when using the `docker-compose pull` command or `docker-compose up --no-build`- image: openremote/haproxy:latest-- # Following volumes allow HAProxy to work with letsencrypt- volumes:- - ${DEPLOYMENT_DIRECTORY:-../deployment}/haproxy/letsencrypt:/etc/letsencrypt- - ${DEPLOYMENT_DIRECTORY:-../deployment}/haproxy/acme-webroot:/var/acme-webroot+ image: openremote/proxy:latestenvironment:@@ -38,10 +34,18 @@ services:# The public host name of this OpenRemote installation. This is used to resolve the SSL# certificate chain and manage your certificates. The localhost has a baked in self-signed- # certificate. If you change this name, also change letsencrypt#DOMAINNAME and don't forget- # to adjust manager#IDENTITY_NETWORK_HOST.+ # certificate. If you change this name, also adjust manager#IDENTITY_NETWORK_HOST.#DOMAINNAME: localhost+ # Provide your own email address for your SSL certificates!+ LE_EMAIL: '[email protected]'++ # --staging requests fake certificates to avoid hitting limits during testing+ #LE_EXTRA_ARGS: '--staging --logs-dir=/etc/letsencrypt'++ # Run proxy, obtain and automatically renew SSL certificates if DOMAINNAME is not localhost (see help)+ command: run+# Expose a public web service mapped to ports on the host.ports:- "80:80"@@ -53,46 +57,8 @@ services:max-size: 10m# Always restart the service- restart: always-- # A sidecar container that manages the SSL certificates for haproxy- letsencrypt:- build:- context: '../letsencrypt'-- image: 'openremote/letsencrypt'-- # Following volumes allow HAProxy to work with letsencrypt- volumes:- - ${DEPLOYMENT_DIRECTORY:-../deployment}/haproxy/letsencrypt:/etc/letsencrypt- - ${DEPLOYMENT_DIRECTORY:-../deployment}/haproxy/acme-webroot:/var/acme-webroot-- environment:-- # It is important that all services have the same timezone and are time synchronized.- TZ: Europe/Zurich-- # The public host name of this OpenRemote installation. This is used to resolve the SSL- # certificate chain and manage your certificates. The localhost has a baked in self-signed- # certificate. If you change this name, also change letsencrypt#DOMAINNAME and don't forget- # to adjust manager#IDENTITY_NETWORK_HOST.- #DOMAINNAME: localhost-- # Provide your own email address for your SSL certificates!- LE_EMAIL: '[email protected]'-- # --staging requests fake certificates to avoid hitting limits during testing- #LE_EXTRA_ARGS: '--staging --logs-dir=/etc/letsencrypt'-- logging:- options:- max-size: 10m-restart: on-failure- # Obtain and automatically renew SSL certificates if DOMAINNAME is not localhost- command: cron-auto-renewal-init-# The API gateway and Manager web application.manager:@@ -102,10 +68,6 @@ services:# Image will be pulled when using the `docker-compose pull` command or `docker-compose up --no-build`image: openremote/manager:latest- # Manager persistent data (other than database data)- volumes:- - ${DEPLOYMENT_DIRECTORY:-../deployment}/manager:/deployment-environment:TZ: Europe/Zurich@@ -134,8 +96,8 @@ services:#SETUP_KEYCLOAK_EMAIL_FROM: '[email protected]'# The public host name of this OpenRemote installation. This name is used in bearer tokens- # and must be the name you access the web services under. If you change haproxy#DOMAINNAME- # and letsencrypt#DOMAINNAME, also change this to match.+ # and must be the name you access the web services under. If you change proxy#DOMAINNAME, also+ # change this to match.#IDENTITY_NETWORK_HOST: localhost# Set if SSL is enabled on the frontend reverse proxy and all internal proxies should assume https@@ -242,9 +204,8 @@ services:KEYCLOAK_USER: admin# Change the admin root password if you make this application publicly accessible! Note- # that imported demo data uses the admin account and also creates a 'test' user with- # password 'test'. Importing will be broken if you change the password only here.- # Demo data should not be imported in production.+ # that imported demo data uses the admin account and also creates test users. Importing will+ # be broken if you change the password only here! Demo data should not be imported in production.KEYCLOAK_PASSWORD: secret# Configure how Keycloak connects to the database@@ -269,16 +230,12 @@ services:# Image will be pulled when using the `docker-compose pull` command or `docker-compose up --no-build`image: openremote/postgresql:latest- # Keep data in a persistent volume- volumes:- - ${DEPLOYMENT_DIRECTORY:-../deployment}/postgresql:/data-environment:TZ: Europe/Zurich- # Create transient database and user. For production, run this once- # with your volume mapping for the data directory, then remove the- # variables and restart to preserve the stored data+ # Create database and user if there is no data. For production, run+ # this once with your volume mapping for the data directory (see demo.yml),+ # then remove the variables and restart to preserve the stored dataPOSTGRES_DB: openremotePOSTGRES_USER: openremotePOSTGRES_PASSWORD: CHANGE_ME_DB_USER_PASSWORDdiff --git a/profile/dev-console.yml b/profile/dev-console.ymlindex 6dec5ece0..01e4539f7 100644--- a/profile/dev-console.yml+++ b/profile/dev-console.yml@@ -1,24 +1,16 @@# Profile for doing development on the consoles and keycloak theme only.# Starts haproxy, letsencrypt, keycloak with theme volumed mapped and postgres and exposes haproxy to localhost.-version: '2.1'+version: '2.2'services:- haproxy:+ proxy:extends:file: deploy.yml- service: haproxy+ service: proxydepends_on:manager:condition: service_healthy- letsencrypt:- extends:- file: deploy.yml- service: letsencrypt- depends_on:- haproxy:- condition: service_healthy-manager:extends:file: deploy.ymldiff --git a/haproxy/Dockerfile b/proxy/Dockerfilesimilarity index 85%rename from haproxy/Dockerfilerename to proxy/Dockerfileindex 60a4a84d2..6f0cb291f 100644--- a/haproxy/Dockerfile+++ b/proxy/Dockerfile@@ -1,6 +1,8 @@FROM centos:7-RUN yum update -y && yum -y install epel-release && yum -y install rsyslog inotify-tools make gcc pcre-devel openssl-devel readline-devel && yum clean all+RUN yum update -y && yum -y install epel-release && \+ yum -y install rsyslog inotify-tools make gcc pcre-devel openssl-devel readline-devel certbot cronie && \+ yum clean allARG HA_PROXY_MINOR_VERSION=1.7ARG HA_PROXY_VERSION=1.7.5@@ -8,6 +10,7 @@ ARG LUA_VERSION=5.3.4ARG ACME_PLUGIN_VERSION=0.1.1ARG DOMAINNAMEENV DOMAINNAME=${DOMAINNAME:-localhost}+ENV TERM xtermRUN mkdir /tmp/lua && cd /tmp/lua \&& curl -sSL https://www.lua.org/ftp/lua-${LUA_VERSION}.tar.gz -o lua.tar.gz \@@ -33,8 +36,7 @@ ADD haproxy-init.cfg /etc/haproxy/haproxy-init.cfgADD haproxy.cfg /etc/haproxy/haproxy.cfgADD selfsigned /opt/selfsigned-VOLUME /etc/letsencrypt-VOLUME /var/acme-webroot+ADD cli.ini /root/.config/letsencrypt/EXPOSE 80 443@@ -43,3 +45,4 @@ HEALTHCHECK --interval=3s --timeout=3s --start-period=2s --retries=30 CMD curl -COPY entrypoint.sh /RUN chmod +x /entrypoint.shENTRYPOINT ["/entrypoint.sh"]+CMD ["run"]\ No newline at end of filediff --git a/letsencrypt/cli.ini b/proxy/cli.inisimilarity index 100%rename from letsencrypt/cli.inirename to proxy/cli.inidiff --git a/letsencrypt/entrypoint.sh b/proxy/entrypoint.shsimilarity index 58%rename from letsencrypt/entrypoint.shrename to proxy/entrypoint.shindex 672c1180a..92972f237 100644--- a/letsencrypt/entrypoint.sh+++ b/proxy/entrypoint.sh@@ -1,9 +1,10 @@#!/bin/bash-if ! [ -f /var/run/crond.pid ]; then- crond-fi+# Create directories+mkdir -p /deployment/acme-webroot+mkdir -p /deployment/letsencrypt/live+# Configure letsencryptif [ -n "${LE_EMAIL}" ]; thenLE_EXTRA_ARGS+=" --email ${LE_EMAIL}"fi@@ -11,23 +12,84 @@ fiif [ -n "${LE_RSA_KEY_SIZE}" ]; thenLE_EXTRA_ARGS+=" --rsa-key-size ${LE_RSA_KEY_SIZE}"fi--LE_CERT_ROOT="/etc/letsencrypt/live"-LE_ARCHIVE_ROOT="/etc/letsencrypt/archive"-LE_RENEWAL_CONFIG_ROOT="/etc/letsencrypt/renewal"+LE_CERT_ROOT="/deployment/letsencrypt/live"+LE_ARCHIVE_ROOT="/deployment/letsencrypt/archive"+LE_RENEWAL_CONFIG_ROOT="/deployment/letsencrypt/renewal"LE_CMD="/usr/bin/certbot certonly ${LE_EXTRA_ARGS}"+# Configure haproxy+CERT_FILE="/opt/selfsigned/localhost.pem"+if [ -n "${DOMAINNAME}" ] && [ "${DOMAINNAME}" != "localhost" ]; then+ CERT_FILE="/deployment/letsencrypt/live/${DOMAINNAME}/haproxy.pem"+fi+export CERT_FILE=${CERT_FILE}++if [ ! -f ${CERT_FILE} ]; then+ HAPROXY_CONFIG="/etc/haproxy/haproxy-init.cfg"+else+ HAPROXY_CONFIG="/etc/haproxy/haproxy.cfg"+fi+HAPROXY_PID_FILE="/var/run/haproxy.pid"+HAPROXY_CMD="haproxy -f ${HAPROXY_CONFIG} ${HAPROXY_USER_PARAMS} -D -p ${HAPROXY_PID_FILE}"+HAPROXY_CHECK_CONFIG_CMD="haproxy -f ${HAPROXY_CONFIG} -c"+function print_help {echo "Available commands:"echo ""- echo "help - Show this help"- echo "list - List configured domains and their certificate's status"- echo "add - Add a new domain and create a certificate for it"- echo "renew - Renew the certificate for an existing domain. Allows to add additional domain names."- echo "remove - Remove and existing domain and its certificate"- echo "cron-auto-renewal - Run the cron job automatically renewing all certificates"- echo "auto-renew - Try to automatically renew all installed certificates"- echo "print-pin - Print the public key pin for a given domain for usage with HPKP"+ echo "help - Show this help"+ echo "run - Run proxy in foreground and monitor config changes, executes check and cron-auto-renewal-init"+ echo "check - Check proxy configuration only"+ echo "list - List configured domains and their certificate's status"+ echo "add - Add a new domain and create a certificate for it"+ echo "renew - Renew the certificate for an existing domain. Allows to add additional domain names."+ echo "remove - Remove and existing domain and its certificate"+ echo "cron-auto-renewal - Run the cron job automatically renewing all certificates"+ echo "cron-auto-renewal-init - Obtain missing certificates and automatically renew afterwards"+ echo "auto-renew - Try to automatically renew all installed certificates"+ echo "print-pin - Print the public key pin for a given domain for usage with HPKP"+}++function check_proxy {+ log_info "Checking HAProxy configuration: $HAPROXY_CONFIG"+ $HAPROXY_CHECK_CONFIG_CMD+}++function run_proxy {+ # Start rsyslogd+ rsyslogd++ check_proxy++ $HAPROXY_CMD+ if [[ $? != 0 ]] || test -t 0; then exit $?; fi+ log_info "HAProxy started with $HAPROXY_CONFIG config, pid $(cat $HAPROXY_PID_FILE)."++ cron_auto_renewal_init++ # Wait if config or certificates were changed, block this execution+ while inotifywait -q -r --exclude '\.git/' -e modify,create,delete,move,move_self $HAPROXY_CONFIG $LE_CERT_ROOT; do+ if [ -f $HAPROXY_PID_FILE ]; then+ log_info "Restarting HAProxy due to config changes..."++ # Wait for the certificate to be present before restarting or might interrupt cert generation/renewal+ log_info "Waiting for certificate '${CERT_FILE}' to exist..."+ while ! ls -l "${CERT_FILE}" >/dev/null 2>&1; do sleep 0.1; done+ log_info "Certificate '${CERT_FILE}' now exists!"+ HAPROXY_CONFIG="/etc/haproxy/haproxy.cfg"+ HAPROXY_CMD="haproxy -f ${HAPROXY_CONFIG} ${HAPROXY_USER_PARAMS} -D -p ${HAPROXY_PID_FILE}"+ HAPROXY_CHECK_CONFIG_CMD="haproxy -f ${HAPROXY_CONFIG} -c"++ if $HAPROXY_CHECK_CONFIG_CMD; then+ $HAPROXY_CMD -sf $(cat $HAPROXY_PID_FILE)+ log_info "HAProxy restarted, pid $(cat $HAPROXY_PID_FILE)." && log+ else+ log_info "HAProxy config invalid, not restarting..."+ fi+ else+ log_error"Error: no $HAPROXY_PID_FILE present, HAProxy exited."+ break+ fi+ done}function add {@@ -248,8 +310,8 @@ function die {exit 1}-function init {- log_info "Executing init at $(date -R)"+function cron_auto_renewal_init {+ log_info "Executing cron_auto_renewal_init at $(date -R)"if [ -n "${DOMAINNAME}" ] && [ "${DOMAINNAME}" != "localhost" ]; thenif [ ! -d "${LE_CERT_ROOT}/${DOMAINNAME}" ]; then@@ -258,40 +320,54 @@ function init {add ${DOMAINNAME}fi+ # TODO Multiple domains+ # while IFS= read -r -d '' domain_dir; do+ # DOMAINNAME=$(basename ${domain_dir})+ # log_info "Checking domain '${DOMAINNAME}'..."+ #+ # if [ -f "${domain_dir}/cert.pem" ]; then+ # log_info "Certificate exists"+ # else+ # log_info "Certificate doesn't exist so attempting to add it..."+ # log_info "Removing domain dir otherwise add will fail..."+ # log_info "CALL ADD ${DOMAINNAME}"+ # rm -rf ${domain_dir}+ # add ${DOMAINNAME}+ # fi+ #+ # done < <(find ${LE_CERT_ROOT} -mindepth 1 -maxdepth 1 -type d -print0)+auto_renewcron_auto_renewal+else- # Do nothing but don't let the container exit so the stack stays healthy- log_info "Not renewing dummy certificate for localhost, waiting forever..."- /bin/bash -c "trap : TERM INT; sleep infinity & wait"+ log_info "Not renewing dummy certificate for localhost"fi--# while IFS= read -r -d '' domain_dir; do-# DOMAINNAME=$(basename ${domain_dir})-# log_info "Checking domain '${DOMAINNAME}'..."-#-# if [ -f "${domain_dir}/cert.pem" ]; then-# log_info "Certificate exists"-# else-# log_info "Certificate doesn't exist so attempting to add it..."-# log_info "Removing domain dir otherwise add will fail..."-# log_info "CALL ADD ${DOMAINNAME}"-# rm -rf ${domain_dir}-# add ${DOMAINNAME}-# fi-#-# done < <(find ${LE_CERT_ROOT} -mindepth 1 -maxdepth 1 -type d -print0)}function cron_auto_renewal {- # CRON_TIME can be set via environment- # If not defined, the default is daily- CRON_TIME=${CRON_TIME:-@daily}- log_info "Running cron job with execution time ${CRON_TIME}"- log_info "${CRON_TIME} root /entrypoint.sh auto-renew >> /var/log/cron.log 2>&1" > /etc/cron.d/letsencrypt- touch /var/log/cron.log && tail -f /var/log/cron.log+ # CRON_TIME can be set via environment+ # If not defined, the default is daily+ CRON_TIME=${CRON_TIME:-@daily}+ log_info "Scheduling cron job with execution time ${CRON_TIME}"+ log_info "${CRON_TIME} root /entrypoint.sh auto-renew >> /var/log/cron.log 2>&1" > /etc/cron.d/letsencrypt++ # Start crond if not running+ if ! [ -f /var/run/crond.pid ]; then+ crond+ fi}+log_info "DOMAINNAME: ${DOMAINNAME}"+log_info "HAPROXY_CERT_FILE: ${CERT_FILE}"+log_info "HAPROXY_CONFIG: ${HAPROXY_CONFIG}"+log_info "HAPROXY_CMD: ${HAPROXY_CMD}"+log_info "HAPROXY_USER_PARAMS: ${HAPROXY_USER_PARAMS}"+log_info "LE_CERT_ROOT: ${LE_CERT_ROOT}"+log_info "LE_ARCHIVE_ROOT: ${LE_ARCHIVE_ROOT}"+log_info "LE_RENEWAL_CONFIG_ROOT: ${LE_RENEWAL_CONFIG_ROOT}"+log_info "LE_CMD: ${LE_CMD}"+if [ $# -eq 0 ]thenprint_help@@ -301,7 +377,11 @@ fiCMD="${1}"shift-if [ "${CMD}" = "add" ]; then+if [ "${CMD}" = "run" ]; then+ run_proxy "${@}"+elif [ "${CMD}" = "check" ]; then+ check_proxy "${@}"+elif [ "${CMD}" = "add" ]; thenadd "${@}"elif [ "${CMD}" = "list" ]; thenlist "${@}"@@ -318,10 +398,7 @@ elif [ "${CMD}" = "cron-auto-renewal" ]; thenelif [ "${CMD}" = "print-pin" ]; thenprint_pin "${@}"elif [ "${CMD}" = "cron-auto-renewal-init" ]; then- # THIS IS A CUSTOM MODE THAT WILL INITIALISE CERTIFICATES FOR ALL DIRECTORIES- # IN THE LE_CERT_ROOT SO FOLDERS CAN JUST BE CREATED USING DOCKER AND THEN LETSENCRYPT- # WILL INITIALISE THE CERTIFICATES AND CREATE CRON JOB TO AUTO RENEW THEM- init+ cron_auto_renewal_initelse- die "Unknown command ${CMD}"+ die "Unknown command: ${CMD}"fi\ No newline at end of filediff --git a/haproxy/haproxy-init.cfg b/proxy/haproxy-init.cfgsimilarity index 91%rename from haproxy/haproxy-init.cfgrename to proxy/haproxy-init.cfgindex 1f308bc32..ffc8fd2f0 100644--- a/haproxy/haproxy-init.cfg+++ b/proxy/haproxy-init.cfg@@ -6,11 +6,11 @@ globallog 127.0.0.1:514 local0 notice# Used for serving certificate validation challenges- chroot /var/acme-webroot+ chroot /deployment/acme-webrootlua-load /etc/haproxy/acme-http01-webroot.lua# Default SSL material locations, managed by letsencrypt container- crt-base /etc/letsencrypt/live+ crt-base /deployment/letsencrypt/livemaxconn 1024ssl-default-bind-ciphers AES256+EECDH:AES256+EDH:!aNULL;diff --git a/haproxy/haproxy.cfg b/proxy/haproxy.cfgsimilarity index 90%rename from haproxy/haproxy.cfgrename to proxy/haproxy.cfgindex 8643bcf3a..6a5d1525f 100644--- a/haproxy/haproxy.cfg+++ b/proxy/haproxy.cfg@@ -6,11 +6,11 @@ globallog 127.0.0.1:514 local0 notice# Used for serving certificate validation challenges- chroot /var/acme-webroot+ chroot /deployment/acme-webrootlua-load /etc/haproxy/acme-http01-webroot.lua- # Default SSL material locations, managed by letsencrypt container- crt-base /etc/letsencrypt/live+ # Default SSL material locations, managed by certbot+ crt-base /deployment/letsencrypt/livemaxconn 1024ssl-default-bind-ciphers AES256+EECDH:AES256+EDH:!aNULL;diff --git a/haproxy/rpi3.Dockerfile b/proxy/rpi3.Dockerfilesimilarity index 100%rename from haproxy/rpi3.Dockerfilerename to proxy/rpi3.Dockerfilediff --git a/haproxy/rsyslog.conf b/proxy/rsyslog.confsimilarity index 100%rename from haproxy/rsyslog.confrename to proxy/rsyslog.confdiff --git a/haproxy/selfsigned/localhost.pem b/proxy/selfsigned/localhost.pemsimilarity index 100%rename from haproxy/selfsigned/localhost.pemrename to proxy/selfsigned/localhost.pem