From ae18e9328e581db098978466a146f4f01901c10b Mon Sep 17 00:00:00 2001 From: Richard Lister Date: Tue, 17 Feb 2015 15:20:50 -0500 Subject: [PATCH] add nginx-confd --- nginx-confd/Dockerfile | 25 +++++++++++++++++++++++++ nginx-confd/app.sh | 20 ++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 nginx-confd/Dockerfile create mode 100755 nginx-confd/app.sh diff --git a/nginx-confd/Dockerfile b/nginx-confd/Dockerfile new file mode 100644 index 0000000..bc25d88 --- /dev/null +++ b/nginx-confd/Dockerfile @@ -0,0 +1,25 @@ +FROM debian:jessie + +MAINTAINER Ric Lister + +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive \ + apt-get install -yq \ + curl \ + nginx && \ + rm /etc/nginx/sites-enabled/default + +WORKDIR /app + +## install confd +ENV CONFD_RELEASE 0.7.1 +RUN curl -Ls https://github.com/kelseyhightower/confd/releases/download/v${CONFD_RELEASE}/confd-${CONFD_RELEASE}-linux-amd64 -o confd && \ + chmod 0755 confd + +## confd setup and runner +ADD app.sh /app/ +RUN chmod 0755 app.sh + +EXPOSE 80 443 + +CMD [ "/app/app.sh" ] diff --git a/nginx-confd/app.sh b/nginx-confd/app.sh new file mode 100755 index 0000000..cdbd992 --- /dev/null +++ b/nginx-confd/app.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +## make sure this script bails on any failures +set -eo pipefail + +## how to get to etcd from inside container +export ETCD=${ETCD:-http://172.17.42.1:4001} + +## wait until we can make initial nginx config +until ./confd -verbose -onetime -node $ETCD -confdir /app ; do + echo "confd waiting to create initial nginx config" + sleep 5 +done + +## run confd to poll etcd for changes +echo "confd polling etcd ..." +./confd -verbose -interval 10 -node $ETCD -confdir /app & + +## run nginx in foreground +nginx -g 'daemon off;'