FROM python:3.11-slim # ---- System deps ---- RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends \ build-essential \ git \ curl \ libgomp1 \ && rm -rf /var/lib/apt/lists/* # ---- Workdir ---- WORKDIR /app # ---- Copy requirement & install ---- COPY requirements.txt /app/requirements.txt RUN pip install --no-cache-dir -U pip \ && pip install --no-cache-dir -r /app/requirements.txt # ---- Runtime cache to /tmp (writeable) ---- ENV HF_HOME=/tmp/hf \ SENTENCE_TRANSFORMERS_HOME=/tmp/sentence_transformers \ XDG_CACHE_HOME=/tmp/.cache # ---- Copy app ---- COPY . /app # ---- Healthcheck ---- HEALTHCHECK --interval=30s --timeout=10s --retries=3 \ CMD curl -f http://localhost:${PORT:-7860}/health || exit 1 # ---- Port & CMD ---- EXPOSE 7860 ENV PORT=7860 \ PYTHONUNBUFFERED=1 CMD ["sh", "-c", "uvicorn app:app --host 0.0.0.0 --port ${PORT:-7860} --log-level info"]