Package a complete enterprise GenAI architecture into a multi-container Docker Compose topology with non-root user permissions, healthcheck probes, and Prometheus metrics for air-gapped private VPC deployment.
~120 minutes hands-on · FDE Track, Core Production difficulty.
A banking client’s infrastructure team demands a single-command deployable package that runs completely isolated inside their private AWS VPC, exposes real-time token telemetry to their existing Grafana dashboards, and includes zero hardcoded secrets.
Dockerfile: Multi-stage, non-root Python runtime container.docker-compose.yml: Multi-service compose file with API, Qdrant, and Redis.metrics.py: Prometheus exporter for tokens/sec, p95 latency, and cache hit ratios.Write the Production Dockerfile:
Use a lightweight Python base (python:3.12-slim), install dependencies, create an unprivileged user appuser, and define healthcheck endpoints.
Instrument Prometheus Metrics:
from prometheus_client import Counter, Histogram
REQUEST_COUNT = Counter("ai_requests_total", "Total AI queries processed", ["status"])
LATENCY_HISTOGRAM = Histogram("ai_latency_seconds", "Inference latency in seconds")
TOKEN_USAGE = Counter("ai_tokens_consumed", "Total tokens used", ["model"])
Wire Multi-Container Topology:
Configure docker-compose.yml linking the FastAPI app to private Qdrant and Redis services with explicit volume persistence.
Verify It Works:
Run docker compose up -d. Curl http://localhost:8000/metrics and verify that Prometheus gauges report live execution metrics.