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
This commit is contained in:
Thomas LEVEIL 2017-02-16 01:15:24 +01:00
parent 68816390ee
commit 19d0d33322
4 changed files with 20 additions and 6 deletions

View file

@ -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

View file

@ -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

View file

@ -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

10
dump.sh Executable file
View file

@ -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