Skip to content

add multi-stage Dockerfile with nginx for production deployment#3

Open
thuantan2060 wants to merge 6 commits intoNevaMind-AI:mainfrom
parasite2060:main
Open

add multi-stage Dockerfile with nginx for production deployment#3
thuantan2060 wants to merge 6 commits intoNevaMind-AI:mainfrom
parasite2060:main

Conversation

@thuantan2060
Copy link
Copy Markdown

📝 Pull Request Summary

Add a production-ready Docker setup using multi-stage build (Node.js build → nginx serve) with API reverse proxy
configuration for the memU server backend.


✅ What does this PR do?

  • Add Dockerfile with multi-stage build:
    • Stage 1 (builder): node:22-alpine installs dependencies and runs npm run build to produce optimized
      static assets via Vite
    • Stage 2 (runtime): nginx:alpine serves the built files (~25MB final image vs ~1GB with node_modules)
  • Add nginx.conf with:
    • Reverse proxy: /api/* requests forwarded to memu-server:8000 (Docker network), rewriting the /api
      prefix — matches the Vite dev proxy behavior
    • SPA fallback: try_files $uri $uri/ /index.html for client-side routing
    • Static asset caching: 1-year immutable cache headers for JS/CSS/images/fonts
  • Add .dockerignore to exclude node_modules, dist, .git from build context

🤔 Why is this change needed?

  • The project currently only supports local development via npm run dev with Vite's built-in proxy
  • There is no way to deploy the UI in a containerized environment alongside the memU server
  • This enables running the full memU stack (server + UI) via docker compose up with a single command
  • The nginx proxy configuration mirrors the Vite dev proxy (/api → backend), so the React app works
    identically in both environments without code changes

🔍 Type of Change

Please check what applies:

  • Bug fix
  • New feature
  • Documentation update
  • Refactor / cleanup
  • Other (please explain)

✅ PR Quality Checklist

  • PR title follows the conventional format (feat:, fix:, docs:)
  • Changes are limited in scope and easy to review
  • Documentation updated where applicable
  • No breaking changes (or clearly documented)
  • Related issues or discussions linked

📌 Optional

  • Edge cases considered
    • SPA routing: all non-file paths fall back to index.html so React Router works
    • API proxy: strips /api prefix to match backend routes (/api/retrieve/retrieve)
    • Docker network: nginx resolves memu-server hostname via Docker Compose service discovery
    • Build optimization: multi-stage keeps final image minimal (nginx:alpine ~40MB vs node:22 ~1GB)
  • Follow-up tasks mentioned
    • Consider adding VITE_API_BASE_URL build arg for custom API endpoints in non-Docker deployments
    • Consider adding gzip compression in nginx config for additional performance

thuantan2060 and others added 6 commits March 30, 2026 21:34
- Stage 1: Node 22-alpine builds Vite/React app
- Stage 2: nginx-alpine serves static files
- nginx.conf proxies /api/* to memu-server:8000
- SPA fallback for client-side routing
- Static asset caching (1 year, immutable)
- .dockerignore excludes node_modules, dist, .git

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Build and push memu-ui Docker image to ghcr.io/parasite2060/memu-ui
on push to main and version tags. Uses existing multi-stage Dockerfile
(node:22-alpine + nginx:alpine).
- actions/checkout v4 → v6
- docker/setup-buildx-action v3 → v4
- docker/login-action v3 → v4
- docker/metadata-action v5 → v6
- docker/build-push-action v6 → v7
Replace docker.yml with release.yml that uses release-please for
version management. Docker images tagged with semver on release.
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.

1 participant