Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Nginx and updated Consul image #23

Merged
merged 4 commits into from
Jul 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tgross this works to create a one-node Consul cluster that we can then scale to N nodes via Docker Compose.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that works -- when a node comes up if it expects only 1 and the CNS name it resolves is itself, then it'll form a split brain cluter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Crap, you're right about that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix incoming.

-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