diff --git a/Dockerfile b/Dockerfile index f3279d3..e4c90ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,8 @@ RUN set -ex; \ bind-tools \ nano \ vim \ - envsubst; \ + envsubst \ + jq; \ chmod -R 777 /tmp COPY --chmod=775 *.sh / diff --git a/README.md b/README.md index 49c3e24..c4acba7 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,8 @@ You should set `BIND_ADDRESS` to the IP on which server with ExApps can accept r `TIMEOUT_SERVER`: timeout for ExApp to start responding to NC request, default: **1800s** +`NC_AUTOSTART_CONTAINERS`: if set, automatically start managed app containers (useful for Podman users) + `NC_HAPROXY_PASSWORD_FILE`: Specifies path to a file containing the password for HAProxy. > [!NOTE] diff --git a/start.sh b/start.sh index 9f91d86..b546007 100644 --- a/start.sh +++ b/start.sh @@ -52,12 +52,21 @@ fi echo "HaProxy config:" +start_app_containers() { + if ! [ -z ${NC_AUTOSTART_CONTAINERS+x} ]; then + echo "Autostarting existing app containers per NC_AUTOSTART_CONTAINERS." + curl --silent --globoff -XGET --unix-socket /run/docker.sock 'http://localhost/containers/json?filters={"status":["exited"]}' | jq -r '.[] | select(.Names[0] | startswith("/nc_app_")) | .Id' | xargs -I% curl --silent --globoff -XPOST --fail-with-body --unix-socket /run/docker.sock 'http://localhost/containers/%/start' + fi +} + if [ -f "/certs/cert.pem" ]; then cat /haproxy.cfg cat /haproxy_ex_apps.cfg + start_app_containers haproxy -f /haproxy.cfg -f /haproxy_ex_apps.cfg -db else cat /haproxy.cfg + start_app_containers haproxy -f /haproxy.cfg -db fi