From f47850ebfa3fd1d23a0863b3d99b49ea8440d678 Mon Sep 17 00:00:00 2001 From: Nabarun Date: Fri, 2 May 2025 08:23:22 +0000 Subject: [PATCH] Fix cache headers for index html file (#28) Part of - Use serve package for controlling separate cache headers for files Reviewed-on: https://git.vdb.to/LaconicNetwork/laconic-wallet-web/pulls/28 Co-authored-by: Nabarun Co-committed-by: Nabarun --- .../docker-compose-laconic-wallet-web.yml | 1 + stack/stack-orchestrator/config/app/run.sh | 4 ++-- .../stack-orchestrator/config/app/serve.json | 22 +++++++++++++++++++ .../cerc-laconic-wallet-web/Dockerfile | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 stack/stack-orchestrator/config/app/serve.json diff --git a/stack/stack-orchestrator/compose/docker-compose-laconic-wallet-web.yml b/stack/stack-orchestrator/compose/docker-compose-laconic-wallet-web.yml index 79bd086..0b62679 100644 --- a/stack/stack-orchestrator/compose/docker-compose-laconic-wallet-web.yml +++ b/stack/stack-orchestrator/compose/docker-compose-laconic-wallet-web.yml @@ -14,6 +14,7 @@ services: command: ["bash", "/scripts/run.sh"] volumes: - ../config/app/run.sh:/scripts/run.sh + - ../config/app/serve.json:/app/serve.json ports: - "80" healthcheck: diff --git a/stack/stack-orchestrator/config/app/run.sh b/stack/stack-orchestrator/config/app/run.sh index 72d0e17..084f89b 100755 --- a/stack/stack-orchestrator/config/app/run.sh +++ b/stack/stack-orchestrator/config/app/run.sh @@ -28,5 +28,5 @@ mkdir -p "$(dirname "$FILE_PATH")" # Write verification code to the file echo "$WALLET_CONNECT_VERIFY_CODE" > "$FILE_PATH" -# Serve build dir -http-server --proxy http://localhost:80? -p 80 /app/build +# Serve build dir with explicit config +serve -s -l 80 -c /app/serve.json /app/build diff --git a/stack/stack-orchestrator/config/app/serve.json b/stack/stack-orchestrator/config/app/serve.json new file mode 100644 index 0000000..2e60248 --- /dev/null +++ b/stack/stack-orchestrator/config/app/serve.json @@ -0,0 +1,22 @@ +{ + "headers": [ + { + "source": "/index.html", + "headers": [ + { + "key": "Cache-Control", + "value": "no-cache, must-revalidate" + } + ] + }, + { + "source": "/static/**/*.{js,css,png,jpg,jpeg,gif,svg,ico}", + "headers": [ + { + "key": "Cache-Control", + "value": "public, max-age=31536000, immutable" + } + ] + } + ] +} diff --git a/stack/stack-orchestrator/container-build/cerc-laconic-wallet-web/Dockerfile b/stack/stack-orchestrator/container-build/cerc-laconic-wallet-web/Dockerfile index e00ac66..f186f45 100644 --- a/stack/stack-orchestrator/container-build/cerc-laconic-wallet-web/Dockerfile +++ b/stack/stack-orchestrator/container-build/cerc-laconic-wallet-web/Dockerfile @@ -33,7 +33,7 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ RUN mkdir -p /scripts # Install simple web server for now (use nginx perhaps later) -RUN yarn global add http-server +RUN yarn global add serve WORKDIR /app COPY . .