Skip to content

Instantly share code, notes, and snippets.

@Nklya
Forked from freeseacher/Dockerfile
Created May 23, 2018 10:27
Show Gist options
  • Save Nklya/0149770e0efe1a93cee9f86978baf117 to your computer and use it in GitHub Desktop.
Save Nklya/0149770e0efe1a93cee9f86978baf117 to your computer and use it in GitHub Desktop.
front:
image: nginx
container_name: nginx-proxy
restart: always
command: consul-template -consul-addr=consul:8500 -template /etc/nginx/upstream.ctmpl:/etc/nginx/upstream.conf -exec "/usr/sbin/nginx -c /etc/nginx/nginx.conf -g 'daemon off;'"
networks:
- backend
- frontend
depends_on:
- web
ports:
- "443:443"
volumes:
- ./config/nginx:/etc/nginx/
- static:/opt/noc
- assets:/usr/lib/python2.7/site-packages/django
FROM nginx:alpine
ENV CONSUL_TEMPLATE_VERSION=0.18.5
RUN apk add --update curl unzip ca-certificates \
&& curl -Ls https://releases.hashicorp.com/consul-template/${CONSUL_TEMPLATE_VERSION}/consul-template_${CONSUL_TEMPLATE_VERSION}_linux_amd64.zip -o consul-template.zip \
&& unzip consul-template.zip -d /bin \
&& rm -f consul-template* \
&& apk del curl unzip \
&& rm -rf /var/cache/apk/*
include upstream.conf;
.....
server {
listen 443;
upstream grafana {
{{range service "grafana"}}server {{.Address}}:{{.Port}} weight={{keyOrDefault (printf "noc/nginx/%s/grafana/weight" .Node) "1"}} max_fails=3 fail_timeout=10;
{{else}}server 127.0.0.1:65535; # check consul for grafana service{{end}}
}
upstream notebook {
{{range service "notebook"}}server {{.Address}}:{{.Port}} max_fails=3 fail_timeout=10;
{{else}}server 127.0.0.1:65535; # check consul for notebook service{{end}}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment