Feature 24: Admin PWA Hosting (#221)
Co-authored-by: dev_agent <17+dev_agent@code.cubecraftcreations.com> Co-committed-by: dev_agent <17+dev_agent@code.cubecraftcreations.com>
This commit was merged in pull request #221.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
# Admin PWA image (Feature 24): builds the Vite bundle from admin/ and
|
||||
# serves it with nginx. Build context is the REPOSITORY ROOT (it needs
|
||||
# admin/); deploy/pwa/Dockerfile.dockerignore limits that context to
|
||||
# admin/ and this directory's nginx.conf.
|
||||
#
|
||||
# docker compose -f deploy/compose.yaml build pwa
|
||||
#
|
||||
# The VITE_* values are baked into the bundle at build time. None is a
|
||||
# secret (the OIDC client is a public PKCE client), and all three are
|
||||
# required: the build fails fast rather than relying on app defaults.
|
||||
|
||||
FROM node:22-alpine@sha256:0a7108bf6c7bf5de370ffb1a3ed6be93d405b43ff159f681a8d18c0e2bc2e402 AS build
|
||||
|
||||
ARG VITE_AUTHENTIK_CLIENT_ID
|
||||
ARG VITE_AUTHENTIK_ISSUER
|
||||
ARG VITE_API_BASE_URL
|
||||
|
||||
WORKDIR /src/admin
|
||||
COPY admin/package.json admin/package-lock.json ./
|
||||
RUN npm ci
|
||||
COPY admin/ ./
|
||||
RUN test -n "$VITE_AUTHENTIK_CLIENT_ID" && test -n "$VITE_AUTHENTIK_ISSUER" && test -n "$VITE_API_BASE_URL" \
|
||||
|| { echo "VITE_AUTHENTIK_CLIENT_ID, VITE_AUTHENTIK_ISSUER and VITE_API_BASE_URL build args are required" >&2; exit 1; }
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:alpine@sha256:1ed1b0e1d7652937d6cbdaf4018c7b6fc009a7dd6c3047351e2eddda745de43f
|
||||
|
||||
COPY deploy/pwa/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY --from=build /src/admin/dist/ /usr/share/nginx/html/
|
||||
@@ -0,0 +1,11 @@
|
||||
# Build-context filter for deploy/pwa/Dockerfile (BuildKit reads
|
||||
# <Dockerfile>.dockerignore in place of the root .dockerignore, which
|
||||
# excludes deploy/). Only admin/ sources and nginx.conf enter the
|
||||
# build; local dependencies, build output and .env files never do.
|
||||
*
|
||||
!admin/
|
||||
!deploy/pwa/nginx.conf
|
||||
admin/node_modules
|
||||
admin/dist
|
||||
**/.env
|
||||
**/.env.*
|
||||
@@ -0,0 +1,53 @@
|
||||
# nginx server for the NestQuest admin PWA (Feature 24). Replaces the
|
||||
# image's /etc/nginx/conf.d/default.conf. The shared Traefik on
|
||||
# nukapi-03 (10.60.1.33) terminates TLS for nestquest.cubecraftlabs.com
|
||||
# and forwards every path that is not the API (/api, /health,
|
||||
# /openapi.json, /docs) here; see deploy/RUNBOOK.md section 10.
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
# Only the reverse proxy and the API box itself may connect; every
|
||||
# other source is refused (403) even if the port is reachable.
|
||||
allow 10.60.1.33;
|
||||
allow 10.60.1.14;
|
||||
deny all;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
server_tokens off;
|
||||
|
||||
# Content-hashed bundle files: cache forever, and a missing asset is
|
||||
# a real 404 rather than the SPA shell.
|
||||
location /assets/ {
|
||||
try_files $uri =404;
|
||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||
}
|
||||
|
||||
# The service worker must be revalidated on every load so a new
|
||||
# release's worker (fresh revision, see admin/vite-sw-plugin.ts) is
|
||||
# picked up.
|
||||
location = /sw.js {
|
||||
try_files $uri =404;
|
||||
add_header Cache-Control "no-cache";
|
||||
}
|
||||
|
||||
# nginx's stock mime.types has no .webmanifest entry.
|
||||
location = /manifest.webmanifest {
|
||||
types { }
|
||||
default_type application/manifest+json;
|
||||
try_files $uri =404;
|
||||
add_header Cache-Control "no-cache";
|
||||
}
|
||||
|
||||
# SPA fallback: client routes such as /auth/callback resolve to the
|
||||
# app shell, which is never cached so it always names the current
|
||||
# hashed assets.
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location = /index.html {
|
||||
add_header Cache-Control "no-cache";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user