Stream logs to stdout/err
Nginx and docker-gen logs can now be seen via docker logs.
This commit is contained in:
parent
95d4f67a59
commit
4f3d690cd3
4 changed files with 27 additions and 31 deletions
10
Dockerfile
10
Dockerfile
|
@ -3,7 +3,7 @@ MAINTAINER Jason Wilder jwilder@litl.com
|
||||||
|
|
||||||
# Install Nginx.
|
# Install Nginx.
|
||||||
RUN apt-get update
|
RUN apt-get update
|
||||||
RUN apt-get install -y python-software-properties wget supervisor
|
RUN apt-get install -y python-software-properties wget
|
||||||
RUN add-apt-repository -y ppa:nginx/stable
|
RUN add-apt-repository -y ppa:nginx/stable
|
||||||
|
|
||||||
RUN apt-get update
|
RUN apt-get update
|
||||||
|
@ -14,13 +14,13 @@ RUN mkdir /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ADD . /app
|
ADD . /app
|
||||||
|
|
||||||
|
RUN wget https://github.com/jwilder/forego/releases/download/v0.8.3-p2/forego-v0.8.3-p2-linux-amd64.tar.gz
|
||||||
|
RUN tar xvzf forego-v0.8.3-p2-linux-amd64.tar.gz && mv forego /usr/local/bin && rm forego-v0.8.3-p2-linux-amd64.tar.gz
|
||||||
|
|
||||||
RUN wget https://github.com/jwilder/docker-gen/releases/download/0.2.1/docker-gen-linux-amd64-0.2.1.tar.gz
|
RUN wget https://github.com/jwilder/docker-gen/releases/download/0.2.1/docker-gen-linux-amd64-0.2.1.tar.gz
|
||||||
RUN tar xvzf docker-gen-linux-amd64-0.2.1.tar.gz
|
RUN tar xvzf docker-gen-linux-amd64-0.2.1.tar.gz
|
||||||
|
|
||||||
RUN mkdir -p /var/log/supervisor
|
|
||||||
ADD supervisor.conf /etc/supervisor/conf.d/supervisor.conf
|
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
ENV DOCKER_HOST unix:///tmp/docker.sock
|
ENV DOCKER_HOST unix:///tmp/docker.sock
|
||||||
|
|
||||||
CMD ["/usr/bin/supervisord"]
|
CMD ["forego", "start", "-r"]
|
||||||
|
|
2
Procfile
Normal file
2
Procfile
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
nginx: nginx
|
||||||
|
dockergen: /app/docker-gen -watch -only-exposed -notify "nginx -s reload" /app/nginx.tmpl /etc/nginx/sites-enabled/default
|
35
nginx.tmpl
35
nginx.tmpl
|
@ -1,8 +1,11 @@
|
||||||
server {
|
server {
|
||||||
listen 80 default_server;
|
listen 80 default_server;
|
||||||
server_name _; # This is just an invalid value which will never trigger on a real hostname.
|
server_name _; # This is just an invalid value which will never trigger on a real hostname.
|
||||||
return 503;
|
error_log /proc/self/fd/2;
|
||||||
|
access_log /proc/self/fd/1;
|
||||||
|
return 503;
|
||||||
}
|
}
|
||||||
|
|
||||||
{{ range $host, $containers := groupBy $ "Env.VIRTUAL_HOST" }}
|
{{ range $host, $containers := groupBy $ "Env.VIRTUAL_HOST" }}
|
||||||
upstream {{ $host }} {
|
upstream {{ $host }} {
|
||||||
|
|
||||||
|
@ -28,12 +31,12 @@ upstream {{ $host }} {
|
||||||
{{/* Else default to standard web port 80 */}}
|
{{/* Else default to standard web port 80 */}}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ range $i, $address := $value.Addresses }}
|
{{ range $i, $address := $value.Addresses }}
|
||||||
{{ if eq $address.Port "80" }}
|
{{ if eq $address.Port "80" }}
|
||||||
# {{$value.Name}}
|
# {{$value.Name}}
|
||||||
server {{ $address.IP }}:{{ $address.Port }};
|
server {{ $address.IP }}:{{ $address.Port }};
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,15 +44,17 @@ server {
|
||||||
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
|
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
|
||||||
|
|
||||||
server_name {{ $host }};
|
server_name {{ $host }};
|
||||||
proxy_buffering off;
|
proxy_buffering off;
|
||||||
|
error_log /proc/self/fd/2;
|
||||||
|
access_log /proc/self/fd/1;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://{{ $host }};
|
proxy_pass http://{{ $host }};
|
||||||
include /etc/nginx/proxy_params;
|
include /etc/nginx/proxy_params;
|
||||||
|
|
||||||
# HTTP 1.1 support
|
# HTTP 1.1 support
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Connection "";
|
proxy_set_header Connection "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
[supervisord]
|
|
||||||
nodaemon=true
|
|
||||||
|
|
||||||
[program:nginx]
|
|
||||||
command=nginx
|
|
||||||
directory=/etc/nginx
|
|
||||||
|
|
||||||
[program:docker-gen]
|
|
||||||
command=./docker-gen -watch -only-exposed -notify "nginx -s reload" /app/nginx.tmpl /etc/nginx/sites-enabled/default
|
|
||||||
directory=/app
|
|
||||||
|
|
Reference in a new issue