FROM python:3.11-slim ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 \ HF_HOME=/app/.cache/huggingface RUN apt-get update && apt-get install -y --no-install-recommends \ libgl1 \ libglib2.0-0 \ && rm -rf /var/lib/apt/lists/* WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY model_core.py app.py gradio_app.py . # Pre-download weights at build time so cold starts are faster. RUN python -c "from huggingface_hub import hf_hub_download; hf_hub_download('jc-builds/CalorieCLIP', 'calorie_clip.pt')" EXPOSE 8000 HEALTHCHECK --interval=30s --timeout=5s --start-period=120s --retries=3 \ CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health')" CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]