From 746447f5fca5f5fb610e54b99239ab7b17862a7d Mon Sep 17 00:00:00 2001 From: Nabarun Date: Fri, 8 Dec 2023 14:58:48 +0530 Subject: [PATCH] Use nginx server to host files and handle page reloads --- .../compose/docker-compose-osmosis-front-end.yml | 14 +++++++------- .../data/config/osmosis/nginx/web-app.conf | 16 ++++++++++++++++ stack_orchestrator/data/stacks/osmosis/README.md | 4 ++-- 3 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 stack_orchestrator/data/config/osmosis/nginx/web-app.conf diff --git a/stack_orchestrator/data/compose/docker-compose-osmosis-front-end.yml b/stack_orchestrator/data/compose/docker-compose-osmosis-front-end.yml index b3b8aaab..f4a25b54 100644 --- a/stack_orchestrator/data/compose/docker-compose-osmosis-front-end.yml +++ b/stack_orchestrator/data/compose/docker-compose-osmosis-front-end.yml @@ -12,19 +12,19 @@ services: - ../config/osmosis/build-app.sh:/app/packages/web/build-app.sh - app_builds:/app-builds - python-server: - image: python:3 + nginx: + image: nginx:1.23-alpine + restart: always depends_on: osmosis-front-end: condition: service_completed_successfully - restart: on-failure - command: ["python3", "-m", "http.server", "-d" ,"/app-builds/osmosis/build", "3000"] volumes: - - app_builds:/app-builds + - ../config/osmosis/nginx:/etc/nginx/conf.d + - app_builds:/usr/share/nginx ports: - - "3000" + - "80" healthcheck: - test: ["CMD", "nc", "-vz", "localhost", "3000"] + test: ["CMD", "nc", "-vz", "localhost", "80"] interval: 20s timeout: 5s retries: 15 diff --git a/stack_orchestrator/data/config/osmosis/nginx/web-app.conf b/stack_orchestrator/data/config/osmosis/nginx/web-app.conf new file mode 100644 index 00000000..784df3b2 --- /dev/null +++ b/stack_orchestrator/data/config/osmosis/nginx/web-app.conf @@ -0,0 +1,16 @@ +server { + listen 80; + listen [::]:80; + server_name _; + + error_page 500 502 503 504 /50x.html; + + location / { + root /usr/share/nginx/osmosis/build; + index index.html index.htm index.nginx-debian.html; + + # First attempt to serve request as file, then as html, + # then as directory, then fall back to displaying a 404. + try_files $uri $uri.html $uri/ /index.html =404; + } +} diff --git a/stack_orchestrator/data/stacks/osmosis/README.md b/stack_orchestrator/data/stacks/osmosis/README.md index 6e5dd7af..b8700edc 100644 --- a/stack_orchestrator/data/stacks/osmosis/README.md +++ b/stack_orchestrator/data/stacks/osmosis/README.md @@ -42,8 +42,8 @@ network: ports: proxy-server: - '4000:4000' - python-server: - - '3000:3000' + niginx: + - '3000:80' ``` ### Data volumes