|
Download docker/README.md from yusufcalisir/Collaborative-Fraud-Intelligence-Simulator: direct link, hf CLI and curl.
- Browser
- Download file 6.82 kB
-
https://huggingface.co/spaces/yusufcalisir/Collaborative-Fraud-Intelligence-Simulator/resolve/main/docker/README.md
- Command line
-
hf download hf://spaces/yusufcalisir/Collaborative-Fraud-Intelligence-Simulator/docker/README.md
-
curl -L -o README.md https://huggingface.co/spaces/yusufcalisir/Collaborative-Fraud-Intelligence-Simulator/resolve/main/docker/README.md
6.82 kB
Enterprise Docker Infrastructure & Container Topology
This directory contains production-hardened container manifests, multi-stage Dockerfiles, reverse proxy configurations, cold-start database schemas, and observability provisioning for the Privacy-Preserving Cross-Bank Fraud Detection Platform (CFI).
1. Directory Structure
docker/
βββ Dockerfile.backend # Multi-stage hardened Python 3.12 API & FL runtime (non-root UID 1000, libpq drivers)
βββ Dockerfile.frontend # Multi-stage Node 22 / Nginx 1.27 Alpine SPA container
βββ nginx/
β βββ nginx.conf # Enterprise reverse proxy, WebSocket upgrade map & security headers
β βββ frontend-nginx.conf # SPA routing fallback, gzip compression & static asset caching
βββ postgres/
β βββ 01-init.sql # PostgreSQL 16 cold-start DDL, extensions, schemas & consortium seed
βββ otel/
β βββ otel-collector-config.yaml # OpenTelemetry Collector pipeline (OTLP receiver, Prometheus exporter)
βββ prometheus/
β βββ prometheus.yml # Prometheus 2.50 scrape configurations for API & OTel collector
βββ grafana/
βββ provisioning/
βββ datasources/
β βββ prometheus.yaml # Automated Prometheus datasource link
βββ dashboards/
βββ dashboards.yaml # Dashboard provider specification
βββ fl_platform_dashboard.json # Pre-configured FL metrics, drift (PSI), latency & alerts
2. Multi-Stage Dockerfiles
2.1 Backend API & FL Engine (Dockerfile.backend)
- Stage 1 (Builder):
python:3.12-slim-bookwormutilizinguvwithlibpq-devfor reproducible, sub-second dependency installation into/opt/venv. - Stage 2 (Runtime): Minimal slim image with pre-compiled wheels,
libpq5shared libraries, and zero build tools (gcc/gitstripped). - Security Posture: Enforces non-root user
user:user(UID1000, GID1000) with strict directory ownership. - Ports Exposed:
8000(FastAPI HTTP / WebSocket) and50051(gRPC Mutual TLS Consortium Coordinator). - Healthcheck Probe:
curl -f http://127.0.0.1:8000/health || exit 1(interval=10s,timeout=3s,retries=3).
2.2 Frontend SPA (Dockerfile.frontend)
- Stage 1 (Builder):
node:22-alpinecompiling React 19 + TypeScript bundle vianpm ciandnpm run build. - Stage 2 (Runtime):
nginx:1.27-alpine-slimhardened web server serving compiled static assets. - Routing: Client-side SPA routing fallback (
try_files $uri $uri/ /index.html;) with immutable cache headers for/assets/. - Healthcheck Probe:
wget -qO- http://127.0.0.1/health || exit 1(supports/health,/ready, and/live).
3. Nginx Reverse Proxy & Routing Blueprint (docker/nginx/)
The outer gateway (cfi-gateway) terminates HTTP/HTTPS traffic and routes requests through an internal bridge network (cfi-network):
| Route Path | Upstream Target | Protocol / Purpose |
|---|---|---|
/api/* |
http://backend_api (cfi-api-server:8000) |
REST API with connection pooling (keepalive 32) |
/ws/* |
http://backend_api (cfi-api-server:8000) |
Bidirectional WebSockets with Upgrade headers & 86400s timeout |
/docs, /redoc, /scalar, /openapi.json |
http://backend_api (cfi-api-server:8000) |
Interactive OpenAPI, Swagger, ReDoc & Scalar documentation & schema |
/health, /ready, /live |
http://backend_api (cfi-api-server:8000) |
Health, readiness, and liveness probe endpoints |
/gateway-health |
Local Nginx response | Gateway healthcheck probe (HTTP 200 "cfi_gateway_healthy") |
/* (Root Fallback) |
http://frontend_spa (cfi-frontend:80) |
Frontend Single Page Application |
Security Headers Enforced
X-Frame-Options: SAMEORIGIN(Clickjacking defense)X-Content-Type-Options: nosniff(MIME sniffing prevention)X-XSS-Protection: 1; mode=blockReferrer-Policy: strict-origin-when-cross-originPermissions-Policy: geolocation=(), microphone=(), camera=()
4. Cold-Start Database Initialization (docker/postgres/01-init.sql)
Mounted to /docker-entrypoint-initdb.d/01-init.sql:ro inside PostgreSQL 16:
- Extensions: Installs
uuid-osspandpg_trgmfor trigram similarity fuzzy matching on transaction narratives. - Dedicated Schema: Isolates consortium tables under schema
cfi_fraud. - Core Entities:
cfi_fraud.banks: Consortium registry (bank_id,name,tier,jurisdiction,connector_type).cfi_fraud.simulations: Federated training run metadata (simulation_id,champion_auc,privacy_epsilon,aggregation_strategy).cfi_fraud.alerts: Anti-money laundering alerts with JSONB feature payloads.cfi_fraud.cases: Four-Eyes investigation cases with SAR narrative drafts.cfi_fraud.audit_chain: Append-only cryptographic audit trail with SHA-256 payload hashes and digital signatures.
- Idempotent Seeding: Seeds initial consortium members (
bank_alpha,bank_beta,bank_gamma) usingON CONFLICT (bank_id) DO UPDATE.
5. Telemetry & Observability Pipeline
- OpenTelemetry Collector (
docker/otel/): Listens on gRPC4317and HTTP4318, applies 1-second batching, and exports metrics to Prometheus (0.0.0.0:8889) and traces to logs. - Prometheus (
docker/prometheus/): Scrapescfi-api-server:8000(/metrics) andotel-collector:8889on a 5-second interval. - Grafana (
docker/grafana/): Automatically provisions Prometheus datasource and loads theCross-Bank FL Intelligence Platform Dashboardfeaturing:- Federated Learning Loss Convergence (
cfi_fl_round_loss) - Feature Drift Population Stability Index (
cfi_model_drift_psi) - Inference Latency SLA P95/P99 (
cfi_http_request_duration_seconds_bucket) - Active Cross-Bank Fraud Risk Alert Counter (
cfi_active_alerts_total)
- Federated Learning Loss Convergence (
6. Execution & Docker Compose Profiles
# Standard Production Stack (Gateway, Frontend, Backend API, PostgreSQL, Redis)
docker compose up -d --build
# With Observability Stack (Adds OTel Collector, Prometheus, Grafana)
docker compose --profile monitoring up -d --build
# With Enterprise Security (Adds HashiCorp Vault KMS)
docker compose --profile enterprise up -d --build
# Full Enterprise Consortium Stack (All services)
docker compose --profile monitoring --profile enterprise --profile storage --profile ml up -d --build
7. Verification
Validate all deployment manifests, Dockerfiles, Nginx directives, healthchecks, and environment parity with the automated suite:
python scripts/verify_docker_deployment.py