-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to use pongo2 as an alternative to Go Template
refs #177
- Loading branch information
Showing
10 changed files
with
263 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
github.com/BurntSushi/toml 056c9bc7be7190eaa7715723883caffa5f8fa3e4 | ||
github.com/fsouza/go-dockerclient e0d22d30691bcc996eca51f729a4777b8c7dc2a8 | ||
github.com/flosch/pongo2 1f4be1efe3b3529b7e58861f75d70120a9567dc4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[[config]] | ||
template = "templates_pongo2/nginx.tmpl" | ||
engine = "pongo2" | ||
dest = "/tmp/nginx.conf" | ||
onlyexposed = true | ||
notifycmd = "/etc/init.d/nginx reload" | ||
|
||
[[config]] | ||
template = "templates_pongo2/fluentd.conf.tmpl" | ||
engine = "pongo2" | ||
dest = "/tmp/fluentd.conf" | ||
watch = true | ||
notifycmd = "echo test" | ||
|
||
[[config]] | ||
template = "templates_pongo2/etcd.tmpl" | ||
engine = "pongo2" | ||
dest = "/tmp/etcd.sh" | ||
watch = true | ||
notifycmd = "/bin/bash /tmp/etcd.sh" | ||
interval = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{% set domain = "docker.company.com" %} | ||
{% for container in containers %} | ||
# {{ container.Name }} ({{ container.ID }} from {{ container.Image.Repository }}) | ||
{{ container.IP }} {{ container.Name }}.{{ domain }} | ||
{% if container.IP6Global %} | ||
{{ container.IP6Global }} {{ container.Name }}.{{ domain }} | ||
{% endif %} | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
# Genenerated by {{ env.USER }} | ||
# Docker Version {{ docker.Version }} | ||
|
||
{% for container in containers %} | ||
{% if container.Addresses|length > 0 %} | ||
{% with address = container.Addresses.0 %} | ||
# {{ container.Name }} | ||
curl -XPUT -q -d value="{{ address.IP }}:{{ address.Port }}" -d ttl=15 http://127.0.0.1:4001/v2/keys/backends/{{ container.Image.Repository }}/{{ printf("%.*s", 12, container.ID) }} | ||
{% endwith %} | ||
{% endif %} | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
## File input | ||
## read docker logs with tag=docker.container | ||
|
||
{% for container in containers %} | ||
<source> | ||
type tail | ||
format json | ||
time_key time | ||
path /var/lib/docker/containers/{{ container.ID }}/{{ container.ID }}-json.log | ||
pos_file /var/lib/docker/containers/{{ container.ID }}/{{ container.ID }}-json.log.pos | ||
tag docker.container.{{ printf("%.*s", 12, container.ID) }} | ||
rotate_wait 5 | ||
</source> | ||
{% endfor %} | ||
|
||
<match docker.**> | ||
type stdout | ||
</match> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{% for container in containers %} | ||
{% set logs = container.Env.LOG_FILES %} | ||
{% if logs %} | ||
{% for logfile in split(logs, ",") %} | ||
/var/lib/docker/containers/{{ container.ID }}/root{{ logfile }}{% endfor %} | ||
{ | ||
daily | ||
missingok | ||
rotate 52 | ||
compress | ||
delaycompress | ||
notifempty | ||
create 644 root root | ||
} | ||
{% endif %} | ||
/var/lib/docker/containers/{{ container.ID }}/{{ container.ID }}-json.log | ||
{ | ||
daily | ||
missingok | ||
rotate 7 | ||
compress | ||
delaycompress | ||
notifempty | ||
create 644 root root | ||
} | ||
{% endfor %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
server { | ||
listen 80 default_server; | ||
server_name _; # This is just an invalid value which will never trigger on a real hostname. | ||
error_log /proc/self/fd/2; | ||
access_log /proc/self/fd/1; | ||
return 503; | ||
} | ||
|
||
{% for host, ctrs in groupByMulti(containers, "Env.VIRTUAL_HOST", ",") %} | ||
|
||
upstream {{ host }} { | ||
|
||
{% for value in ctrs %} | ||
|
||
{% set network = value.Networks.0 %} | ||
|
||
{# If only 1 port exposed, use that #} | ||
{% if value.Addresses|length == 1 %} | ||
{% with address = value.Addresses.0 %} | ||
# {{ value.Name }} | ||
server {{ network.IP }}:{{ address.Port }}; | ||
{% endwith %} | ||
|
||
{# If more than one port exposed, use the one matching VIRTUAL_PORT env var #} | ||
{% elif value.Env.VIRTUAL_PORT %} | ||
{% for address in value.Addresses %} | ||
{% if address.Port == value.Env.VIRTUAL_PORT %} | ||
# {{value.Name}} | ||
server {{ network.IP }}:{{ address.Port }}; | ||
{% endif %} | ||
{% endfor %} | ||
|
||
{# Else default to standard web port 80 #} | ||
{% else %} | ||
{% for address in value.Addresses %} | ||
{% if address.Port == "80" %} | ||
# {{value.Name}} | ||
server {{ network.IP }}:{{ address.Port }}; | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} | ||
{% endfor %} | ||
} | ||
|
||
server { | ||
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; | ||
|
||
server_name {{ host }}; | ||
proxy_buffering off; | ||
error_log /proc/self/fd/2; | ||
access_log /proc/self/fd/1; | ||
|
||
location / { | ||
proxy_pass http://{{ trim(host) }}; | ||
proxy_set_header Host http_host; | ||
proxy_set_header X-Real-IP remote_addr; | ||
proxy_set_header X-Forwarded-For proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto scheme; | ||
|
||
# HTTP 1.1 support | ||
proxy_http_version 1.1; | ||
proxy_set_header Connection ""; | ||
} | ||
} | ||
{% endfor %} |