Spaces:
Sleeping
Sleeping
# Use a minimal Python image | |
FROM python:3.12.1-slim | |
# Install system dependencies required for UV and Git | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
curl ca-certificates git && \ | |
rm -rf /var/lib/apt/lists/* | |
# Install UV (fast Python dependency manager) | |
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \ | |
mv /root/.local/bin/uv /usr/local/bin/uv && chmod +x /usr/local/bin/uv | |
# Verify UV installation | |
RUN uv --version | |
# Create a non-root user for security | |
RUN useradd -m -u 1000 user | |
# Switch to the "user" user | |
USER user | |
# Set environment variables properly | |
ENV HOME=/home/user | |
ENV PATH=/home/user/.local/bin:$PATH | |
ENV XDG_CACHE_HOME=$HOME/.cache | |
ENV GRADIO_SERVER_NAME="0.0.0.0" | |
ENV SYSTEM=spaces | |
# Set working directory | |
WORKDIR $HOME/app | |
# Install dependencies | |
RUN --mount=type=bind,source=uv.lock,target=uv.lock \ | |
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \ | |
uv sync --frozen --no-cache --no-install-project | |
COPY --chown=user . $HOME/app | |
RUN uv sync --no-cache --frozen | |
EXPOSE 7860 | |
# Run the application | |
CMD ["uv", "run", "python", "yourbench_space/app.py"] |