From 63eb324ba526faca608c3ec18332e50fb8391523 Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Sun, 23 Jun 2019 06:06:00 -0700 Subject: [PATCH] Add nginx service that provides a frontend to all the other services This allows us to run all the different services and expose all their metrics, all on one port. --- build | 2 +- docker-compose.jsonnet | 12 ++++++++++-- nginx/Dockerfile | 3 +++ nginx/nginx.conf | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 nginx/Dockerfile create mode 100644 nginx/nginx.conf diff --git a/build b/build index e231e7d..bf29601 100755 --- a/build +++ b/build @@ -8,7 +8,7 @@ set -eu # Pass PUSH=true to also push the resulting images, or PUSH=latest to push them as :latest tag # The different images we can build -COMPONENTS=(downloader restreamer backfiller thrimshim cutter sheetsync) +COMPONENTS=(downloader restreamer backfiller thrimshim cutter sheetsync nginx) # Define push if not already defined PUSH=${PUSH:-} diff --git a/docker-compose.jsonnet b/docker-compose.jsonnet index c0df90d..4482946 100644 --- a/docker-compose.jsonnet +++ b/docker-compose.jsonnet @@ -19,6 +19,7 @@ cutter: false, sheetsync: false, thrimshim: false, + nginx: true, }, // Twitch channel to capture @@ -34,12 +35,13 @@ // The host's port to expose each service on. // Only the restreamer needs to be externally accessible - the others are just for monitoring. ports:: { - restreamer: 8080, - thrimshim: 8081, + restreamer: 8000, + thrimshim: 8004, downloader: 8001, backfiller: 8002, cutter: 8003, sheetsync: 8005, + nginx: 80, }, // The local port within each container to bind the backdoor server on. @@ -199,6 +201,12 @@ [if "sheetsync" in $.ports then "ports"]: ["%s:8005" % $.ports.sheetsync] }, + [if $.enabled.nginx then "nginx"]: { + image: "quay.io/ekimekim/wubloader-nginx:%s" % image_tag, + restart: "on-failure", + [if "nginx" in $.ports then "ports"]: ["%s:80" % $.ports.nginx], + }, + }, } diff --git a/nginx/Dockerfile b/nginx/Dockerfile new file mode 100644 index 0000000..6a6a9ff --- /dev/null +++ b/nginx/Dockerfile @@ -0,0 +1,3 @@ +# nginx container contains config that exposes all the various services metrics +FROM nginx:latest +ADD nginx/nginx.conf /etc/nginx/nginx.conf diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..c442cd1 --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,37 @@ + +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + server { + listen 80; + location / { + proxy_pass http://restreamer:8000; + } + location /thrimshim { + proxy_pass http://thrimshim:8004; + } + # Restreamer metrics would be available regardless, this is just for consistency + location /metrics/restreamer { + proxy_pass http://restreamer:8000/metrics; + } + location /metrics/downloader { + proxy_pass http://downloader:8001/metrics; + } + location /metrics/backfiller { + proxy_pass http://backfiller:8002/metrics; + } + location /metrics/cutter { + proxy_pass http://cutter:8003/metrics; + } + location /metrics/thrimshim { + proxy_pass http://thrimshim:8004/metrics; + } + location /metrics/sheetsync { + proxy_pass http://sheetsync:8005/metrics; + } + } +}