# HuggingFace Spaces Docker — read the doc: # https://huggingface.co/docs/hub/spaces-sdks-docker FROM python:3.12-slim # HF Spaces requires a non-root user with uid 1000 RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" WORKDIR /app RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ && rm -rf /var/lib/apt/lists/* || true COPY --chown=user requirements.txt . RUN pip install --no-cache-dir --upgrade -r requirements.txt COPY --chown=user . /app # Pre-download default model at build time — avoids cold-start delay RUN python -c "from transformers import pipeline; pipeline('token-classification', model='dslim/bert-base-NER', aggregation_strategy='simple')" # HuggingFace Spaces requires port 7860 ENV PORT=7860 ENV APP_ENV=staging EXPOSE 7860 CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--forwarded-allow-ips", "*"]