Merge 0cb799d251
into 2b24c1712a
This commit is contained in:
commit
fdb472897d
2 changed files with 19 additions and 4 deletions
|
@ -17,7 +17,7 @@ RUN echo "daemon off;" >> /etc/nginx/nginx.conf \
|
||||||
RUN wget -P /usr/local/bin https://godist.herokuapp.com/projects/ddollar/forego/releases/current/linux-amd64/forego \
|
RUN wget -P /usr/local/bin https://godist.herokuapp.com/projects/ddollar/forego/releases/current/linux-amd64/forego \
|
||||||
&& chmod u+x /usr/local/bin/forego
|
&& chmod u+x /usr/local/bin/forego
|
||||||
|
|
||||||
ENV DOCKER_GEN_VERSION 0.4.2
|
ENV DOCKER_GEN_VERSION 0.6.0
|
||||||
|
|
||||||
RUN wget https://github.com/jwilder/docker-gen/releases/download/$DOCKER_GEN_VERSION/docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz \
|
RUN wget https://github.com/jwilder/docker-gen/releases/download/$DOCKER_GEN_VERSION/docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz \
|
||||||
&& tar -C /usr/local/bin -xvzf docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz \
|
&& tar -C /usr/local/bin -xvzf docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz \
|
||||||
|
|
15
nginx.tmpl
15
nginx.tmpl
|
@ -7,8 +7,12 @@
|
||||||
{{/* If there is no swarm node or the port is not published on host, use container's IP:PORT */}}
|
{{/* If there is no swarm node or the port is not published on host, use container's IP:PORT */}}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
# {{ .Container.Name }}
|
# {{ .Container.Name }}
|
||||||
|
{{ if .Network }}
|
||||||
|
server {{ .Network.IP }}:{{ .Address.Port }};
|
||||||
|
{{ else }}
|
||||||
server {{ .Address.IP }}:{{ .Address.Port }};
|
server {{ .Address.IP }}:{{ .Address.Port }};
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
# {{ .Container.Name }}
|
# {{ .Container.Name }}
|
||||||
server {{ .Container.IP }} down;
|
server {{ .Container.IP }} down;
|
||||||
|
@ -75,17 +79,28 @@ server {
|
||||||
upstream {{ $host }} {
|
upstream {{ $host }} {
|
||||||
{{ range $container := $containers }}
|
{{ range $container := $containers }}
|
||||||
{{ $addrLen := len $container.Addresses }}
|
{{ $addrLen := len $container.Addresses }}
|
||||||
|
{{ $networkLen := len $container.Networks }}
|
||||||
{{/* If only 1 port exposed, use that */}}
|
{{/* If only 1 port exposed, use that */}}
|
||||||
{{ if eq $addrLen 1 }}
|
{{ if eq $addrLen 1 }}
|
||||||
{{ $address := index $container.Addresses 0 }}
|
{{ $address := index $container.Addresses 0 }}
|
||||||
|
{{ if gt $networkLen 0 }}
|
||||||
|
{{ $network := index $container.Networks 0 }}
|
||||||
|
{{ template "upstream" (dict "Container" $container "Network" $network "Address" $address) }}
|
||||||
|
{{ else }}
|
||||||
{{ template "upstream" (dict "Container" $container "Address" $address) }}
|
{{ template "upstream" (dict "Container" $container "Address" $address) }}
|
||||||
|
{{ end }}
|
||||||
{{/* If more than one port exposed, use the one matching VIRTUAL_PORT env var, falling back to standard web port 80 */}}
|
{{/* If more than one port exposed, use the one matching VIRTUAL_PORT env var, falling back to standard web port 80 */}}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ $port := coalesce $container.Env.VIRTUAL_PORT "80" }}
|
{{ $port := coalesce $container.Env.VIRTUAL_PORT "80" }}
|
||||||
{{ $address := where $container.Addresses "Port" $port | first }}
|
{{ $address := where $container.Addresses "Port" $port | first }}
|
||||||
|
{{ if gt $networkLen 0 }}
|
||||||
|
{{ $network := index $container.Networks 0 }}
|
||||||
|
{{ template "upstream" (dict "Container" $container "Network" $network "Address" $address) }}
|
||||||
|
{{ else }}
|
||||||
{{ template "upstream" (dict "Container" $container "Address" $address) }}
|
{{ template "upstream" (dict "Container" $container "Address" $address) }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{ $default_host := or ($.Env.DEFAULT_HOST) "" }}
|
{{ $default_host := or ($.Env.DEFAULT_HOST) "" }}
|
||||||
|
|
Loading…
Reference in a new issue