arcshukla's picture
real db
7a1f075
Raw
History Blame Contribute Delete
2.16 kB
# ──────────────────────────────────────────────────────────────────────────────
# Build stage — install dependencies with uv
# ──────────────────────────────────────────────────────────────────────────────
FROM python:3.13-slim AS builder
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
# Use the same path as runtime so venv shebangs stay valid after copy
WORKDIR /home/app
COPY pyproject.toml uv.lock ./
# Install only production deps into a clean venv
RUN uv sync --frozen --no-dev --no-install-project
# ──────────────────────────────────────────────────────────────────────────────
# Runtime stage
# ──────────────────────────────────────────────────────────────────────────────
FROM python:3.13-slim
WORKDIR /home/app
# Copy installed venv from builder (paths match — no shebang breakage)
COPY --from=builder /home/app/.venv /home/app/.venv
# Copy application code
COPY . .
# Pre-create /data so local Docker runs work; on HF Spaces the volume is mounted
# here at runtime (owned by root, container also runs as root — no permission issue)
#RUN mkdir -p /data
RUN mkdir -p /data && chmod 777 /data
# Add venv to PATH
ENV PATH="/home/app/.venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
# PORT is overridden per-platform:
# HF Spaces → 7860 (default)
# Render → set PORT env var
# Cloud Run → set PORT env var (GCP sets it automatically)
EXPOSE 7860
CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port ${PORT:-7860} --loop asyncio"]