From 48e7aa430656166b62483645abb475f880afc468 Mon Sep 17 00:00:00 2001 From: Maciej Hirsz Date: Thu, 2 Jul 2020 15:03:14 +0200 Subject: [PATCH] WIP: reworking docker --- docker-compose.yml | 8 +++--- frontend/Dockerfile | 1 + frontend/nginx/default | 55 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 frontend/nginx/default diff --git a/docker-compose.yml b/docker-compose.yml index ed67275..6b460ef 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,13 +3,13 @@ version: "3" services: telemetry-frontend: build: - dockerfile: frontend.Dockerfile - context: ./ + dockerfile: Dockerfile + context: ./frontend/ # Copy in changes to the ui, so no need to rebuild the images. volumes: - /app/node_modules - ./packages:/app/packages - command: yarn start:frontend + # command: yarn start:frontend ports: - 3000:3000 telemetry-backend: @@ -20,3 +20,5 @@ services: - PORT=8000 ports: - 8000:8000 + expose: + - 8000 diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 08c47eb..6b1946e 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -24,6 +24,7 @@ COPY --from=builder /opt/builder/env.sh /usr/bin/ RUN apk add --no-cache bash; chmod +x /usr/bin/env.sh COPY --from=builder /opt/builder/nginx/nginx.conf /etc/nginx/nginx.conf +COPY --from=builder /opt/builder/nginx/default /etc/nginx/sites-available/default COPY --from=builder /opt/builder/build /usr/share/nginx/html EXPOSE 80 diff --git a/frontend/nginx/default b/frontend/nginx/default new file mode 100644 index 0000000..b2ad03a --- /dev/null +++ b/frontend/nginx/default @@ -0,0 +1,55 @@ + +## +# You should look at the following URL's in order to grasp a solid understanding +# of Nginx configuration files in order to fully unleash the power of Nginx. +# http://wiki.nginx.org/Pitfalls +# http://wiki.nginx.org/QuickStart +# http://wiki.nginx.org/Configuration +# +# Generally, you will want to move this file somewhere, and start with a clean +# file but keep this around for reference. Or just disable in sites-enabled. +# +# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. +## + +server { + root /usr/share/nginx/html; + + index index.html; + + listen 3000; + listen [::]:3000; + server_name telemetry.polkadot.io localhost; + + location /feed/ { + proxy_pass http://127.0.0.1:8000; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + limit_req zone=zone burst=5; + } + + location /submit/ { + proxy_pass http://127.0.0.1:8000; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + limit_req zone=zone burst=5; + } + + location /network_state/ { + proxy_pass http://127.0.0.1:8000; + proxy_http_version 1.1; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + limit_req zone=zone burst=5; + } + + location /health/ { + proxy_pass http://127.0.0.1:8000; + proxy_http_version 1.1; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + limit_req zone=zone burst=5; + } +}