Creating index.html with a list of URLs to published containers
This commit is contained in:
parent
c33dedf10b
commit
ff3916ab41
4 changed files with 96 additions and 21 deletions
1
Procfile
1
Procfile
|
|
@ -1,2 +1,3 @@
|
||||||
dockergen: docker-gen -watch -notify "nginx -s reload" /app/nginx.tmpl /etc/nginx/conf.d/default.conf
|
dockergen: docker-gen -watch -notify "nginx -s reload" /app/nginx.tmpl /etc/nginx/conf.d/default.conf
|
||||||
|
dockergen2: docker-gen -watch /app/index.tmpl /usr/share/nginx/html/index.html
|
||||||
nginx: nginx
|
nginx: nginx
|
||||||
|
|
|
||||||
46
README.md
46
README.md
|
|
@ -48,15 +48,53 @@ services:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||||
|
networks:
|
||||||
|
- webproxy
|
||||||
|
|
||||||
whoami:
|
networks:
|
||||||
image: jwilder/whoami
|
webproxy:
|
||||||
environment:
|
|
||||||
- VIRTUAL_HOST=whoami.local
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ docker-compose up
|
$ docker-compose up
|
||||||
|
```
|
||||||
|
|
||||||
|
Deploy a service
|
||||||
|
```yaml
|
||||||
|
version: '2'
|
||||||
|
|
||||||
|
services:
|
||||||
|
whoami:
|
||||||
|
image: jwilder/whoami
|
||||||
|
environment:
|
||||||
|
- VIRTUAL_HOST=whoami.local
|
||||||
|
networks:
|
||||||
|
- nginx-proxy_webproxy
|
||||||
|
|
||||||
|
networks:
|
||||||
|
nginx-proxy_webproxy:
|
||||||
|
external: true
|
||||||
|
```
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ docker-compose up
|
||||||
|
$ curl localhost
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
|
<title>List</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a target="_blank" href="http://whoami.local">whoami.local</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
$ curl -H "Host: whoami.local" localhost
|
$ curl -H "Host: whoami.local" localhost
|
||||||
I'm 5b129ab83266
|
I'm 5b129ab83266
|
||||||
```
|
```
|
||||||
|
|
|
||||||
24
index.tmpl
Normal file
24
index.tmpl
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
|
<title>List</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<ul>
|
||||||
|
{{ range $host, $containers := groupByMulti $ "Env.VIRTUAL_HOST" "," }}
|
||||||
|
|
||||||
|
{{ $host := trim $host }}
|
||||||
|
{{ $is_regexp := hasPrefix "~" $host }}
|
||||||
|
{{ $upstream_name := when $is_regexp (sha1 $host) $host }}
|
||||||
|
<li>
|
||||||
|
<a target="_blank" href="http://{{ $host }}">{{ $host }}</a>
|
||||||
|
</li>{{ end }}
|
||||||
|
</ul>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
12
nginx.tmpl
12
nginx.tmpl
|
|
@ -115,6 +115,18 @@ server {
|
||||||
}
|
}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80 default_server;
|
||||||
|
listen [::]:80 default_server;
|
||||||
|
server_name _;
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ =404;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{{ range $host, $containers := groupByMulti $ "Env.VIRTUAL_HOST" "," }}
|
{{ range $host, $containers := groupByMulti $ "Env.VIRTUAL_HOST" "," }}
|
||||||
|
|
||||||
{{ $host := trim $host }}
|
{{ $host := trim $host }}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue