Added support for networks
Changed DOCKER_GEN_VERSION to 0.6.0 Needed newer version to support Networks struct
This commit is contained in:
parent
2b24c1712a
commit
55e66d658a
2 changed files with 5 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 \
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
{{/* 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 }};
|
||||
server {{ .Network.IP }}:{{ .Address.Port }};
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
# {{ .Container.Name }}
|
||||
|
@ -75,15 +75,16 @@ server {
|
|||
upstream {{ $host }} {
|
||||
{{ range $container := $containers }}
|
||||
{{ $addrLen := len $container.Addresses }}
|
||||
{{ $network := index $container.Networks 0 }}
|
||||
{{/* If only 1 port exposed, use that */}}
|
||||
{{ if eq $addrLen 1 }}
|
||||
{{ $address := index $container.Addresses 0 }}
|
||||
{{ template "upstream" (dict "Container" $container "Address" $address) }}
|
||||
{{ template "upstream" (dict "Container" $container "Network" $network "Address" $address) }}
|
||||
{{/* 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) }}
|
||||
{{ template "upstream" (dict "Container" $container "Network" $network "Address" $address) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue