diff --git a/src/haproxy/Dockerfile b/src/haproxy/Dockerfile index 8d10f5d165..d8bb7575a1 100644 --- a/src/haproxy/Dockerfile +++ b/src/haproxy/Dockerfile @@ -1,10 +1,3 @@ -FROM haproxy:1.9-alpine - -VOLUME [ "/certs" ] - -RUN apk add --update inotify-tools +FROM balena/open-balena-haproxy:master COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg -COPY start-haproxy.sh /start-haproxy - -CMD /start-haproxy diff --git a/src/haproxy/start-haproxy.sh b/src/haproxy/start-haproxy.sh deleted file mode 100755 index dad19daa95..0000000000 --- a/src/haproxy/start-haproxy.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -OPENBALENA_CERT=/etc/ssl/private/open-balena.pem -mkdir -p "$(dirname "${OPENBALENA_CERT}")" - -if [ -f "/certs/open-balena.pem" ]; then - echo "Using certificate from cert-provider..." - cp /certs/open-balena.pem "${OPENBALENA_CERT}" -else - echo "Building certificate from environment variables..." - ( - echo "${BALENA_HAPROXY_CRT}" | base64 -d - echo "${BALENA_HAPROXY_KEY}" | base64 -d - echo "${BALENA_ROOT_CA}" | base64 -d - ) > "${OPENBALENA_CERT}" -fi - -haproxy -f /usr/local/etc/haproxy/haproxy.cfg -W & -HAPROXY_PID=$! - -while true; do - inotifywait -r -e create -e modify -e delete /certs - - if [ -f "/certs/open-balena.pem" ]; then - echo "Updating certificate from cert-provider..." - cp /certs/open-balena.pem "${OPENBALENA_CERT}" - fi - - echo "Certificate change detected. Reloading..." - kill -SIGUSR2 $HAPROXY_PID - sleep 1; -done