diff --git a/docker/Dockerfile b/docker/Dockerfile index ef10748..e3f9285 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -2,8 +2,10 @@ FROM alpine MAINTAINER Marios Andreopoulos WORKDIR / +VOLUME ["/tmp"] + # Add needed tools -RUN apk add --no-cache ca-certificates wget \ +RUN apk add --no-cache ca-certificates wget inotify-tools \ && echo "progress = dot:giga" | tee /etc/wgetrc # Add and Setup Caddy webserver @@ -24,8 +26,9 @@ RUN wget "$KAFKA_CONNECT_UI_URL" -O /kafka-connect-ui.tar.gz \ # Add configuration and runtime files ADD Caddyfile /caddy/Caddyfile.template -ADD run.sh / -RUN chmod +x /run.sh +ADD run.sh wait.sh / + +RUN chmod +x /run.sh /wait.sh EXPOSE 8000 diff --git a/docker/README.md b/docker/README.md index 7971131..4c0911f 100644 --- a/docker/README.md +++ b/docker/README.md @@ -60,6 +60,11 @@ The only option for the UI, is the URL(s) of your Connect cluster(s). Usually the main reason for using this is when you run the container with `--net=host`, where you can't use docker's publish flag (`-p HOST_PORT:8000`). + +- `RELOAD[true|false]` + + Whether to reload the caddy configuration in case it has been externally changed. + - `CADDY_OPTIONS=[OPTIONS]` The webserver that powers the image is Caddy. Via this variable diff --git a/docker/run.sh b/docker/run.sh index 4be719f..0f234b5 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -1,6 +1,8 @@ #!/bin/sh PROXY="${PROXY:-true}" +RELOAD="${RELOAD:-false}" + PROXY_SKIP_VERIFY="${PROXY_SKIP_VERIFY:-false}" INSECURE_PROXY="" CADDY_OPTIONS="${CADDY_OPTIONS:-}" @@ -99,5 +101,13 @@ http://0.0.0.0:$PORT EOF } 1>&2 +if echo "$RELOAD" | egrep -sq "true|TRUE|y|Y|yes|YES|1"; then + echo "Enabling watch on caddy config file." + ./wait.sh& + exec /caddy/caddy -conf /tmp/Caddyfile -quiet +else + exec /caddy/caddy -conf /tmp/Caddyfile -quiet +fi + + -exec /caddy/caddy -conf /tmp/Caddyfile -quiet diff --git a/docker/wait.sh b/docker/wait.sh new file mode 100755 index 0000000..62653f9 --- /dev/null +++ b/docker/wait.sh @@ -0,0 +1,5 @@ +#!/bin/sh +inotifywait -m -e modify,close_write /tmp/Caddyfile | while read file; do pkill -USR1 caddy; done + + +