Spaces:
Runtime error
Runtime error
File size: 1,366 Bytes
1ffd0a4 | 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 37 38 39 40 41 | # ββ Stage 1: Build ββββββββββββββββββββββββββββββββββββββββββββββββββββ
FROM python:3.11-slim AS builder
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
WORKDIR /app
# Copy dependency manifests first (Docker layer caching)
COPY pyproject.toml uv.lock ./
# Install production dependencies only β frozen ensures lockfile is respected
RUN uv sync --frozen --no-dev --no-install-project
# Copy application source
COPY src/ src/
COPY README.md ./
# Install the project itself
RUN uv sync --frozen --no-dev
# ββ Stage 2: Runtime ββββββββββββββββββββββββββββββββββββββββββββββββββ
FROM python:3.11-slim
# UV is needed at runtime for 'uv run'
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
WORKDIR /app
# Copy the entire virtual environment and source from builder
COPY --from=builder /app /app
# Port is supplied by the host (Cloud Run: 8080, HF Spaces: 7860).
# Default to 8080 for local runs when PORT is unset.
ENV PORT=8080
EXPOSE ${PORT}
# Shell form so ${PORT} is expanded at runtime by the host environment.
CMD ["sh", "-c", "uv run uvicorn backend.main:app --host 0.0.0.0 --port ${PORT:-8080}"]
|