Files
lnet_tutor/docs/deploy-minimal.md
2025-10-22 20:14:31 +08:00

1.2 KiB

Minimal Deployment (Nginx + Django + Angular)

Overview

Serve Angular as static assets via Nginx and proxy /api/ to Django. Use file system storage on a single host.

Build Outputs

  • Angular build → /var/www/app (or similar)
  • Django app → /srv/api (Gunicorn/Uvicorn on 127.0.0.1:8000)
  • Data folders: /srv/data/input, /srv/data/attempts, /srv/data/output, /srv/data/progress, /srv/data/manifest.json

Nginx (concept)

  • / → Angular index.html + assets
  • /api/ → proxy to Django (127.0.0.1:8000)
  • Cache static; no caching for /api/

Django Configuration

  • Env vars for folder paths (INPUT_DIR, ATTEMPTS_DIR, OUTPUT_DIR, PROGRESS_DIR, MANIFEST_FILE)
  • CORS/CSRF: allow Angular origin
  • Logging to files under /var/log/app

Health

  • /api/health endpoint returns { ok: true }
  • Nginx upstream failover not required (single host)

Backups

  • Periodic tar of /srv/data (retain N days)

TLS

  • Terminate HTTPS at Nginx (e.g., with Let's Encrypt)

Rollout Steps (high level)

  1. Build Angular → copy to web root
  2. Run Django server → behind Nginx
  3. Create data folders and set permissions
  4. Verify /api/exams and basic start/submit flows