Deploy PluginMind with confidence using the existing Docker assets, environment validation tooling, and health checks.
🏗️ Deployment Building Blocks
- Dockerfile (
pluginmind_backend/Dockerfile) – Multi-stage build withdevelopment,production, andtestingtargets. - docker-compose.yml – Orchestrates FastAPI, Postgres, Redis (optional), and Nginx reverse proxy.
- scripts/validate_env.py – Fail-fast validation for critical environment variables.
- scripts/smoke_backend.sh /
smoke_errors.sh– Quick smoke tests post-deploy.
🐳 Production Image
Loading code snippet…
Key environment variables
Loading code snippet…
🧪 Validate Before You Deploy
Run the environment validator locally or in CI:
Loading code snippet…
It checks for:
- Required API keys and secrets.
- Proper Google Client ID format.
- Numeric config ranges (timeouts, rate limits).
- Production-only requirements (no wildcard CORS, etc.).
📦 docker-compose (Staging / Dev)
Loading code snippet…
Services launched:
backend– FastAPI app (gunicorn in production target).postgres– Data store.redis– Optional cache/rate-limit backend (not yet used but provisioned).nginx– Reverse proxy (under theproductionprofile).
Tune with environment overrides (see docker-compose.yml).
🧭 Health Checks & Observability
| Endpoint | Use Case |
|---|---|
/health | L7 health probe and legacy job cleanup. |
/ready | Kubernetes/Load balancer readiness; checks DB + env vars. |
/live | Simple process liveness. |
/services | Registry snapshot (registered services + health). |
/services/health | Raw health map from the analysis service. |
Configure your orchestrator (Kubernetes, ECS, Nomad) to poll these endpoints.
📚 Database Migrations
- Copy
alembic.iniandalembic/to your deployment context. - Run migrations after provisioning the database:
Loading code snippet…
- To create new migrations:
Loading code snippet…
🔒 Security Considerations
- Set
ENVIRONMENT=productionso/auth/googleissues secure cookies. - Provide
SESSION_COOKIE_DOMAINif using subdomains. - Terminate TLS at Nginx or your ingress controller; forward
X-Forwarded-Protoso FastAPI knows it’s secure. - Rate limiting is enforced per IP/user via Redis-like token bucket (
app/utils/rate_limit.py). Ensure latency between app and store is low.
🧾 Logging & Metrics
- Logs are structured through
app/core/logging.py; configureLOG_FORMATandLOG_LEVELvia env. - Correlation IDs flow from the
X-Request-IDheader. Upstream proxies should preserve it. - Metrics endpoints (
/metrics) are not yet implemented—see the roadmap for planned Prometheus integration.
🧯 Disaster Recovery Tips
- Database – Back up the
analysis_jobs,analysis_results, andquery_logstables regularly. - Secrets – Rotate
BACKEND_SESSION_SECRETafter suspected compromise. Active sessions will immediately become invalid. - Failover – Use
/services/healthto decide when to route traffic away if either OpenAI or Grok goes down.
✅ Deployment Checklist
- Run
scripts/validate_env.py. - Build the production image.
- Run alembic migrations.
- Smoke test with
scripts/smoke_backend.sh. - Confirm
/readyand/servicesreturn healthy response. - Enable monitoring for error rates and rate-limit spikes.
Happy shipping! 🌟