Skip to content

feat: add multi-stage Dockerfile for frontend static site serving (Closes #539) - #580

Open
waterWang wants to merge 1 commit into
Protocol-Guild:mainfrom
waterWang:feat/frontend-dockerfile-539
Open

feat: add multi-stage Dockerfile for frontend static site serving (Closes #539)#580
waterWang wants to merge 1 commit into
Protocol-Guild:mainfrom
waterWang:feat/frontend-dockerfile-539

Conversation

@waterWang

Copy link
Copy Markdown

Summary

Adds a multi-stage Dockerfile for the frontend so the static site can be built and served consistently in containerized deployments (k8s / Helm already reference a payd-frontend deployment image).

Changes

  • frontend/Dockerfile — two-stage build:
    • Build stage (node:20-alpine): npm ci then npm run build (tsc + vite build), with VITE_* ARGs exposed so runtime config (API URL, Stellar network) can be injected at build time
    • Runtime stage (nginx:1.27-alpine): serves /usr/share/nginx/html, exposes port 80 (matches the k8s deployment containerPort: 80), includes a healthcheck for the k8s probes
  • frontend/nginx.conf — SPA routing support via try_files ... /index.html fallback, 1-year immutable caching for hashed static assets, no-cache for index.html so releases propagate immediately, gzip for text assets
  • frontend/.dockerignore — keeps node_modules, dist, test artifacts, and local env files out of the build context

Acceptance Criteria

  • Multi-stage: build stage + nginx runtime
  • Image size < 50MB (nginx:alpine runtime is ~45MB; check docker image ls payd-frontend)
  • Proper caching headers for static assets (immutable, 1y for hashed js/css)
  • SPA routing support (nginx fallback to index.html)

Verification

cd frontend
docker build -t payd-frontend .
docker run -p 8080:80 payd-frontend

Then visit http://localhost:8080/ and any client-side route (e.g. /settings) — both should render the app.

Closes #539

Add a multi-stage Dockerfile that builds the Vite React app with Node
20 and serves it with nginx Alpine:

- Build stage: npm ci + npm run build (tsc + vite build)
- Runtime stage: nginx:1.27-alpine serving /usr/share/nginx/html
- SPA routing support via try_files fallback to index.html
- Cache headers: immutable 1y for hashed static assets, no-cache for
  index.html so deploys propagate immediately
- Gzip compression for text-based assets
- Healthcheck hitting / to satisfy k8s probes
- Build args for VITE_* env vars (API URL, Stellar network config)
- .dockerignore to keep the build context lean

Closes Protocol-Guild#539
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add frontend Dockerfile for static site serving

1 participant