From cbe213a07403ce15c363a10699102961d5ef1577 Mon Sep 17 00:00:00 2001 From: Casey Bisson Date: Thu, 21 Jul 2016 20:56:12 -0700 Subject: [PATCH 1/4] containerpilot json --- nginx/etc/containerpilot.json | 55 ++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/nginx/etc/containerpilot.json b/nginx/etc/containerpilot.json index 248e9f8..c3011df 100644 --- a/nginx/etc/containerpilot.json +++ b/nginx/etc/containerpilot.json @@ -1,21 +1,50 @@ { - "backends": [ + "consul": "{{ if .CONSUL_AGENT }}localhost{{ else }}{{ .CONSUL }}{{ end }}:8500", + "preStart": "/usr/local/bin/reload.sh preStart", + "services": [ { - "onChange": "/usr/local/bin/reload.sh", - "poll": 5, - "name": "wordpress" + "name": "nginx", + "port": 80, + "health": "/usr/bin/curl --fail -s http://localhost/health", + "poll": 10, + "ttl": 25 } ], - "services": [ + "backends": [ { - "ttl": 25, - "poll": 10, - "health": "/usr/bin/curl --fail -s http://localhost/health.txt", - "publicIp": true, - "port": 80, - "name": "nginx" + "name": "wordpress", + "poll": 7, + "onChange": "/usr/local/bin/reload.sh" } ], - "preStart": "/usr/local/bin/reload.sh preStart", - "consul": "{{.CONSUL}}:8500" + "coprocesses": [{{ if .CONSUL_AGENT }} + { + "command": ["/usr/local/bin/consul", "agent", + "-data-dir=/data", + "-config-dir=/config", + "-rejoin", + "-retry-join", "{{ .CONSUL }}", + "-retry-max", "10", + "-retry-interval", "10s"], + "restarts": "unlimited" + }{{ end }}], + "telemetry": { + "port": 9090, + "sensors": [ + { + "name": "nginx_connections_unhandled_total", + "help": "Number of accepted connnections that were not handled", + "type": "gauge", + "poll": 5, + "check": ["/usr/local/bin/sensor.sh", "unhandled"] + }, + { + "name": "nginx_connections_load", + "help": "Ratio of active connections (less waiting) to the maximum worker connections", + "type": "gauge", + "poll": 5, + "check": ["/usr/local/bin/sensor.sh", "connections_load"] + } + ] + } } From 2a3a29d75c96e32ce31c8966d06087e147ac8479 Mon Sep 17 00:00:00 2001 From: Casey Bisson Date: Thu, 21 Jul 2016 20:59:41 -0700 Subject: [PATCH 2/4] add build notes --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index b0411fc..7fb56f7 100644 --- a/README.md +++ b/README.md @@ -176,3 +176,12 @@ This project has been fully tested and documented to run in Docker in local deve ### Sponsors Initial development of this project was sponsored by [Joyent](https://www.joyent.com) and [10up](http://10up.com). + +### Building + +This image implements [microbadger.com](https://microbadger.com/#/labels) label schema, but those labels require additional build args: + +``` +docker build --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ + --build-arg VCS_REF=`git rev-parse --short HEAD` . +``` \ No newline at end of file From 5554e42e4ebaa177501913e176053f4922f472fb Mon Sep 17 00:00:00 2001 From: Casey Bisson Date: Thu, 21 Jul 2016 21:07:45 -0700 Subject: [PATCH 3/4] more specific health url/path --- docker-compose.yml | 6 +++--- nginx/etc/containerpilot.json | 2 +- nginx/etc/nginx/nginx.conf.ctmpl | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 64854a9..2218539 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,7 +17,7 @@ wordpress: # NFS is used to store user uploads nfs: - image: autopilotpattern/nfsserver:latest + image: autopilotpattern/nfsserver:0.1.0-r2 restart: always mem_limit: 256m env_file: _env @@ -49,7 +49,7 @@ mysql: # Memcached is a high performance object cache memcached: - image: autopilotpattern/memcached:latest + image: autopilotpattern/memcached:1.4-alpine-r1 restart: always mem_limit: 512m env_file: _env @@ -63,7 +63,7 @@ memcached: # Nginx as a load-balancing tier and reverse proxy nginx: - image: autopilotpattern/wordpress-nginx:latest + image: autopilotpattern/wordpress-nginx:4.5.3-r1 restart: always mem_limit: 512m ports: diff --git a/nginx/etc/containerpilot.json b/nginx/etc/containerpilot.json index c3011df..216e096 100644 --- a/nginx/etc/containerpilot.json +++ b/nginx/etc/containerpilot.json @@ -5,7 +5,7 @@ { "name": "nginx", "port": 80, - "health": "/usr/bin/curl --fail -s http://localhost/health", + "health": "/usr/bin/curl --fail -s http://localhost/nginx-health", "poll": 10, "ttl": 25 } diff --git a/nginx/etc/nginx/nginx.conf.ctmpl b/nginx/etc/nginx/nginx.conf.ctmpl index 5996ebc..4225ac7 100644 --- a/nginx/etc/nginx/nginx.conf.ctmpl +++ b/nginx/etc/nginx/nginx.conf.ctmpl @@ -39,9 +39,10 @@ http { root /usr/share/nginx/html; - location /health.txt { - add_header content-type "text/html"; - alias /usr/share/nginx/html/index.html; + location /nginx-health { + stub_status; + allow 127.0.0.1; + deny all; } {{ if service "wordpress" }} From bed131c19423ffe8d9f9751207087b86d0049f36 Mon Sep 17 00:00:00 2001 From: Casey Bisson Date: Thu, 21 Jul 2016 23:13:33 -0700 Subject: [PATCH 4/4] switching to autopilotpattern/consul --- docker-compose.yml | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 2218539..cc60fa7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,7 +17,7 @@ wordpress: # NFS is used to store user uploads nfs: - image: autopilotpattern/nfsserver:0.1.0-r2 + image: autopilotpattern/nfsserver:latest restart: always mem_limit: 256m env_file: _env @@ -49,7 +49,7 @@ mysql: # Memcached is a high performance object cache memcached: - image: autopilotpattern/memcached:1.4-alpine-r1 + image: autopilotpattern/memcached:latest restart: always mem_limit: 512m env_file: _env @@ -63,7 +63,7 @@ memcached: # Nginx as a load-balancing tier and reverse proxy nginx: - image: autopilotpattern/wordpress-nginx:4.5.3-r1 + image: autopilotpattern/wordpress-nginx:latest restart: always mem_limit: 512m ports: @@ -78,20 +78,18 @@ nginx: # Consul is the service catalog that helps discovery between the components consul: - image: progrium/consul:latest - command: -server -bootstrap -ui-dir /ui + image: autopilotpattern/consul:latest + command: > + /usr/local/bin/containerpilot + /bin/consul agent -server + -bootstrap-expect 1 + -config-dir=/etc/consul + -ui-dir /ui restart: always mem_limit: 128m env_file: _env ports: - 8500 - expose: - - 53 - - 8300 - - 8301 - - 8302 - - 8400 - - 8500 dns: - 127.0.0.1 labels: