Skip to content

Commit

Permalink
Merge pull request #23 from autopilotpattern/nginx-coprocess
Browse files Browse the repository at this point in the history
Fixed Nginx and updated Consul image
  • Loading branch information
misterbisson authored Jul 22, 2016
2 parents 21e8c75 + bed131c commit 6f0e8d1
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 25 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` .
```
16 changes: 7 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
55 changes: 42 additions & 13 deletions nginx/etc/containerpilot.json
Original file line number Diff line number Diff line change
@@ -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/nginx-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"]
}
]
}
}
7 changes: 4 additions & 3 deletions nginx/etc/nginx/nginx.conf.ctmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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" }}
Expand Down

0 comments on commit 6f0e8d1

Please sign in to comment.