File size: 961 Bytes
803ad5c 4cf63e7 dab5e76 93b9db8 dab5e76 93b9db8 920c564 93b9db8 4cf63e7 920c564 4cf63e7 93b9db8 920c564 4cf63e7 920c564 4cf63e7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | FROM python:3.11-slim
# Install uv from official image (fast, no pip bootstrap needed)
COPY --from=ghcr.io/astral-sh/uv:0.9.30 /uv /bin/uv
ENV HF_HUB_ENABLE_HF_TRANSFER=1
# Install dependencies from requirements.in - resolved on the target platform,
# no cross-compilation flags needed. CPU-only torch via extra index.
COPY requirements.in /tmp/requirements.in
RUN --mount=type=cache,target=/root/.cache/uv \
uv pip install --system \
--extra-index-url https://download.pytorch.org/whl/cpu \
-r /tmp/requirements.in
# Create non-root user (HF Spaces runs as user ID 1000)
RUN useradd -m -u 1000 user
USER user
# Set home and path
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app
# Copy application (as user)
COPY --chown=user . .
# Create data directory for dataset download
RUN mkdir -p $HOME/app/data
# HF Spaces expects port 7860
EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|