From 19d0d3332233004e9d320f230e718bc8dc497460 Mon Sep 17 00:00:00 2001 From: Thomas LEVEIL Date: Thu, 16 Feb 2017 01:15:24 +0100 Subject: [PATCH] display error message and dump nginx config file in case nginx failed to reload also add the `/app/dump.sh` script which dumps to the console the content of all nginx config files docker exec nginx-proxy /app/dump.sh --- Dockerfile | 6 ++++-- Dockerfile.alpine | 6 ++++-- Procfile | 4 ++-- dump.sh | 10 ++++++++++ 4 files changed, 20 insertions(+), 6 deletions(-) create mode 100755 dump.sh diff --git a/Dockerfile b/Dockerfile index 649a7ba..7a34d49 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,8 +14,9 @@ RUN echo "daemon off;" >> /etc/nginx/nginx.conf \ && sed -i 's/^http {/&\n server_names_hash_bucket_size 128;/g' /etc/nginx/nginx.conf # Install Forego -ADD https://github.com/jwilder/forego/releases/download/v0.16.1/forego /usr/local/bin/forego -RUN chmod u+x /usr/local/bin/forego +RUN wget --quiet -O- https://bin.equinox.io/a/aHZqYk1TwYN/forego-20170111202937-linux-amd64.tar.gz \ + | tar xz -C /usr/local/bin/ \ + && chmod u+x /usr/local/bin/forego ENV DOCKER_GEN_VERSION 0.7.3 @@ -24,6 +25,7 @@ RUN wget https://github.com/jwilder/docker-gen/releases/download/$DOCKER_GEN_VER && rm /docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz COPY . /app/ +RUN chmod +x /app/*.sh WORKDIR /app/ ENV DOCKER_HOST unix:///tmp/docker.sock diff --git a/Dockerfile.alpine b/Dockerfile.alpine index abb73e9..2e75311 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -11,8 +11,9 @@ RUN echo "daemon off;" >> /etc/nginx/nginx.conf \ && sed -i 's/^http {/&\n server_names_hash_bucket_size 128;/g' /etc/nginx/nginx.conf # Install Forego -ADD https://github.com/jwilder/forego/releases/download/v0.16.1/forego /usr/local/bin/forego -RUN chmod u+x /usr/local/bin/forego +RUN wget --quiet -O- https://bin.equinox.io/a/aHZqYk1TwYN/forego-20170111202937-linux-amd64.tar.gz \ + | tar xz -C /usr/local/bin/ \ + && chmod u+x /usr/local/bin/forego ENV DOCKER_GEN_VERSION 0.7.3 @@ -21,6 +22,7 @@ RUN wget --quiet https://github.com/jwilder/docker-gen/releases/download/$DOCKER && rm /docker-gen-alpine-linux-amd64-$DOCKER_GEN_VERSION.tar.gz COPY . /app/ +RUN chmod +x /app/*.sh WORKDIR /app/ ENV DOCKER_HOST unix:///tmp/docker.sock diff --git a/Procfile b/Procfile index 29fe166..2bd2401 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ -dockergen: docker-gen -watch -notify "nginx -s reload" /app/nginx.tmpl /etc/nginx/conf.d/default.conf -nginx: nginx +dockergen: docker-gen -watch -notify "nginx -s reload" -notify-output /app/nginx.tmpl /etc/nginx/conf.d/default.conf +nginx: nginx \ No newline at end of file diff --git a/dump.sh b/dump.sh new file mode 100755 index 0000000..32c49e1 --- /dev/null +++ b/dump.sh @@ -0,0 +1,10 @@ +#!/bin/bash +echo +echo "-------------------------------------------------------------------------------" +find /etc/nginx/ -type f -name '*.conf' -o -path '/etc/nginx/vhost.d/*' +echo +echo "-------------------------------------------------------------------------------" +find /etc/nginx/ -type f -name '*.conf' | while read config_file; do + echo "> $config_file" + awk '{printf "%3d %s\n", NR, $0}' "$config_file" +done \ No newline at end of file