Docker for Production

Stario requires Python 3.14+. We recommend using uv for fast, reproducible builds.

This pattern separates dependency installation from your source code to maximize layer caching.

# 1. Builder stage
FROM python:3.14-slim AS builder
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/
WORKDIR /app

# Install dependencies (cached)
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-install-project --no-dev

# 2. Final stage
FROM python:3.14-slim
WORKDIR /app
COPY --from=builder /app/.venv /app/.venv
COPY . .

ENV PATH="/app/.venv/bin:$PATH"
ENV PYTHONUNBUFFERED=1

EXPOSE 8000
CMD ["python", "main.py"]

Docker Compose

services:
  web:
    build: .
    ports:
      - "8000:8000"
    environment:
      - WORKERS=4
      - HOST=0.0.0.0

Key Benefits of uv in Docker

  • Caching: uv sync is aware of Docker layer caching.
  • Size: Using --no-dev ensures your production image doesn't include testing tools.
  • Speed: uv can be up to 10x faster than pip during the build process.