# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker # you will also find guides on how best to write your Dockerfile FROM python:3.10-slim WORKDIR /app # Cache all HF model downloads in a fixed location baked into the image ENV HF_HOME=/app/.cache/huggingface ENV HF_HUB_CACHE=/app/.cache/huggingface/hub RUN apt-get update && apt-get install -y \ build-essential \ curl \ git \ libxrender1 \ libxext6 \ libx11-6 \ libsm6 \ libfreetype6 \ libpng-dev \ libcairo2 \ && rm -rf /var/lib/apt/lists/* COPY ./requirements.txt requirements.txt RUN pip install --upgrade pip setuptools wheel \ && pip install -r requirements.txt # Pre-download all models at build time so they're on disk at runtime RUN python -c "\ from huggingface_hub import snapshot_download, hf_hub_download; \ models = { \ 'cn': 'SalZa2004/Cetane_Number_Predictor', \ 'ysi': 'SalZa2004/YSI_Predictor', \ 'bp': 'SalZa2004/Boiling_Point_Predictor', \ 'density': 'SalZa2004/Density_Predictor', \ 'lhv': 'SalZa2004/LHV_Predictor', \ 'dv': 'SalZa2004/Dynamic_Viscosity_Predictor', \ 'dcn': 'SalZa2004/MolPool_GNN_model', \ }; \ [snapshot_download(repo_id=v, repo_type='model') for v in models.values()]; \ hf_hub_download(repo_id='mrashid26/Biodiesel_CN_Predictor', filename='src/biodiesel_cn_model.pkl', repo_type='space'); \ hf_hub_download(repo_id='mrashid26/Biodiesel_CN_Predictor', filename='src/ood_stats.pkl', repo_type='space'); \ print('All models downloaded and cached.')" COPY . /app CMD ["gunicorn", "-b", "0.0.0.0:7860", "--workers", "1", "--timeout", "0", "--max-requests", "200", "--max-requests-jitter", "50", "app:app"]