Davy592's picture
Moved ENV variables from Dockerfile to HSpace variables
6246430 verified
FROM python:3.12-slim
# 1. Retrieve uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
# 2. System dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# 3. Setup non-root user (Standard HF)
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
WORKDIR $HOME/app
# 4. External Dependencies Installation
COPY --chown=user pyproject.toml uv.lock ./
# We install the frontend dependencies
RUN uv sync --frozen --no-install-project --extra frontend
# We add the venv to the PATH
ENV PATH="$HOME/app/.venv/bin:$PATH"
# 5. Cache Busting
LABEL build_date="$(date)"
ARG BUILD_DATE
RUN echo "Build check: ${BUILD_DATE}"
# 6. Code Copy and Installation
COPY --chown=user nygaardcodecommentclassification ./nygaardcodecommentclassification
COPY --chown=user app.py ./
# Very fast because the external dependencies are already installed above.
RUN uv sync --frozen --extra frontend
# Expose port
EXPOSE 7860
# Run
CMD ["uv", "run", "app.py"]