| |
| |
| |
| |
| |
|
|
| FROM python:3.10-slim |
|
|
| |
| WORKDIR /app |
|
|
| |
| RUN apt-get update && apt-get install -y --no-install-recommends \ |
| gcc \ |
| libgomp1 \ |
| curl \ |
| && rm -rf /var/lib/apt/lists/* |
|
|
| |
| COPY requirements.txt . |
| RUN pip install --no-cache-dir --upgrade pip \ |
| && pip install --no-cache-dir -r requirements.txt |
|
|
| |
| COPY . . |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| RUN mkdir -p models/heart_disease/preprocessors models/diabetes/preprocessors && \ |
| HF="https://huggingface.co/yahyoha/omnidiag-models/resolve/main" && \ |
| echo "=== heart_disease ===" && \ |
| curl -fsSL "${HF}/omni_diag_xgb_optimized.pkl" -o models/heart_disease/omni_diag_xgb_optimized.pkl && \ |
| curl -fsSL "${HF}/label_encoders.pkl" -o models/heart_disease/preprocessors/label_encoders.pkl && \ |
| curl -fsSL "${HF}/standard_scaler.pkl" -o models/heart_disease/preprocessors/standard_scaler.pkl && \ |
| echo "=== diabetes ===" && \ |
| curl -fsSL "${HF}/diabetes/xgb_model.pkl" -o models/diabetes/xgb_model.pkl && \ |
| curl -fsSL "${HF}/diabetes/lgb_model.pkl" -o models/diabetes/lgb_model.pkl && \ |
| curl -fsSL "${HF}/diabetes/rf_model.pkl" -o models/diabetes/rf_model.pkl && \ |
| curl -fsSL "${HF}/diabetes/meta_learner.pkl" -o models/diabetes/meta_learner.pkl && \ |
| curl -fsSL "${HF}/diabetes/preprocessors/standard_scaler.pkl" -o models/diabetes/preprocessors/standard_scaler.pkl && \ |
| echo "=== all models downloaded ===" |
|
|
| |
| RUN useradd -m -u 1000 omnidiag && chown -R omnidiag:omnidiag /app |
| USER omnidiag |
|
|
| |
| RUN printf '#!/bin/bash\n\ |
| echo "===== Application Startup at $(date -u +%%Y-%%m-%%d\\ %%H:%%M:%%S) ====="\n\ |
| exec uvicorn backend.main:app --host 0.0.0.0 --port 7860\n\ |
| ' > /app/startup.sh && chmod +x /app/startup.sh |
|
|
| |
| EXPOSE 7860 |
|
|
| |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ |
| CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/')" || exit 1 |
|
|
| |
| CMD ["/app/startup.sh"] |
|
|