Spaces:
Sleeping
Sleeping
File size: 4,602 Bytes
e291508 b5d2527 e291508 b5d2527 e291508 b5d2527 e291508 b5d2527 e291508 b5d2527 e291508 b5d2527 e291508 b5d2527 e291508 71e552e c6a1224 b5d2527 e291508 be42d16 e291508 b5d2527 e291508 b5d2527 e291508 b5d2527 e291508 b5d2527 e291508 b5d2527 e291508 b5d2527 e291508 b5d2527 e291508 b5d2527 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | # ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# PolicyBridge β HuggingFace Docker Space
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Port : 7860 (HuggingFace requirement)
# DB : Clever Cloud MySQL via MYSQL_ADDON_* Secrets
# Models: .pkl files loaded from /app/models/ at runtime
# Workers: 1 β Clever Cloud free tier allows max 5 connections total
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
FROM python:3.11-slim
# ββ System dependencies βββββββββββββββββββββββββββββββββββββββββββββββ
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
default-libmysqlclient-dev \
pkg-config \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# ββ Working directory βββββββββββββββββββββββββββββββββββββββββββββββββ
WORKDIR /app
# ββ Install Python dependencies βββββββββββββββββββββββββββββββββββββββ
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# ββ Copy application code βββββββββββββββββββββββββββββββββββββββββββββ
COPY app.py .
COPY train_all_agents.py .
COPY agent1_ssn_kyc.py .
COPY agent2_property_risk.py .
COPY agent3_underwriting.py .
COPY agent4_pricing.py .
COPY agent5_issuance_orchestrator.py .
COPY agent6_audit.py .
COPY agent6_audit_integration.py .
COPY agent7_fnol_intake.py .
COPY agent8_coverage_verify.py .
COPY agent9_fraud_signal.py .
COPY agent10_severity.py .
COPY agent11_triage.py .
COPY agent12_riskradar.py .
# ββ Copy frontend HTML apps βββββββββββββββββββββββββββββββββββββββββββ
COPY pc_insurance_multiagent_v4.html .
COPY policybridge_app.html .
# ββ Copy trained model files ββββββββββββββββββββββββββββββββββββββββββ
COPY models/ ./models/
# ββ Create Silver output directory βββββββββββββββββββββββββββββββββββ
RUN mkdir -p silver/kyc_decisions \
silver/property_risk \
silver/uw_decisions \
silver/pricing \
silver/issued_policies
# ββ Non-root user (HuggingFace security requirement) ββββββββββββββββββ
RUN useradd -m -u 1000 appuser \
&& chown -R appuser:appuser /app
USER appuser
# ββ Environment defaults ββββββββββββββββββββββββββββββββββββββββββββββ
ENV PORT=7860 \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
# ββ Expose port βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
EXPOSE 7860
# ββ Health check ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/status')" \
|| exit 1
# ββ Launch via Gunicorn βββββββββββββββββββββββββββββββββββββββββββββββ
# 1 worker = max 2 DB connections (pool_size=1 + max_overflow=1)
# Clever Cloud free tier: 5 max connections β this leaves 3 free
CMD ["gunicorn", \
"--bind", "0.0.0.0:7860", \
"--workers", "1", \
"--timeout", "120", \
"--keep-alive", "5", \
"--log-level", "info", \
"--access-logfile", "-", \
"--error-logfile", "-", \
"app:app"]
|