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 \
|
||||
&& 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 \
|
||||
&& tar -C /usr/local/bin -xvzf docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz \
|
||||
|
|
21
nginx.tmpl
21
nginx.tmpl
|
@ -7,7 +7,11 @@
|
|||
{{/* If there is no swarm node or the port is not published on host, use container's IP:PORT */}}
|
||||
{{ else }}
|
||||
# {{ .Container.Name }}
|
||||
server {{ .Address.IP }}:{{ .Address.Port }};
|
||||
{{ if .Network }}
|
||||
server {{ .Network.IP }}:{{ .Address.Port }};
|
||||
{{ else }}
|
||||
server {{ .Address.IP }}:{{ .Address.Port }};
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
# {{ .Container.Name }}
|
||||
|
@ -75,15 +79,26 @@ server {
|
|||
upstream {{ $host }} {
|
||||
{{ range $container := $containers }}
|
||||
{{ $addrLen := len $container.Addresses }}
|
||||
{{ $networkLen := len $container.Networks }}
|
||||
{{/* If only 1 port exposed, use that */}}
|
||||
{{ if eq $addrLen 1 }}
|
||||
{{ $address := index $container.Addresses 0 }}
|
||||
{{ template "upstream" (dict "Container" $container "Address" $address) }}
|
||||
{{ 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) }}
|
||||
{{ end }}
|
||||
{{/* If more than one port exposed, use the one matching VIRTUAL_PORT env var, falling back to standard web port 80 */}}
|
||||
{{ else }}
|
||||
{{ $port := coalesce $container.Env.VIRTUAL_PORT "80" }}
|
||||
{{ $address := where $container.Addresses "Port" $port | first }}
|
||||
{{ template "upstream" (dict "Container" $container "Address" $address) }}
|
||||
{{ 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) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue