keyvault-api / Dockerfile
hashir-qt's picture
Upload folder using huggingface_hub
e656014 verified
Raw History Blame Contribute Delete
1.18 kB
# ── Build stage ────────────────────────────────────────────────────────────────
FROM python:3.13-slim AS builder
# Install uv (fast Python package manager)
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
WORKDIR /app
# Copy dependency files first (layer caching)
COPY pyproject.toml uv.lock ./
# Install production deps into .venv
RUN uv sync --frozen --no-dev
# ── Runtime stage ───────────────────────────────────────────────────────────────
FROM python:3.13-slim AS runtime
WORKDIR /app
# Copy venv from builder
COPY --from=builder /app/.venv /app/.venv
# Copy application source
COPY src/ ./src/
# Make the venv the active Python
ENV PATH="/app/.venv/bin:$PATH"
# Hugging Face Spaces requires port 7860
EXPOSE 7860
# Non-root user for security
RUN useradd -m -u 1000 appuser && chown -R appuser /app
USER appuser
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "7860"]