uv run spawns uvicorn, which uses multiprocessing.spawn for hot reload. The spawned subprocess starts a fresh Python interpreter that bypasses uv's venv activation — so it never sees the venv's packages. Fix: use a standalone python:3.12-slim dev stage with pip install -e . directly into the system Python. No venv means the spawn subprocess uses the same interpreter with the same packages. The editable install creates a .pth file pointing to /app/src, so the mounted host source is live. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
27 lines
917 B
Docker
27 lines
917 B
Docker
FROM python:3.12-slim AS base
|
|
WORKDIR /app
|
|
RUN pip install uv
|
|
|
|
FROM python:3.12-slim AS development
|
|
WORKDIR /app
|
|
COPY pyproject.toml .
|
|
COPY src/ src/
|
|
# Install directly into system Python — no venv, so uvicorn's multiprocessing.spawn
|
|
# subprocess inherits the same interpreter and can always find rehearsalhub
|
|
RUN pip install --no-cache-dir -e "."
|
|
# ./api/src is mounted as a volume at runtime; the editable .pth file points here
|
|
CMD ["python3", "-m", "uvicorn", "rehearsalhub.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
|
|
|
|
FROM base AS lint
|
|
COPY pyproject.toml .
|
|
RUN uv sync --frozen
|
|
COPY src/ src/
|
|
RUN uv run ruff check src/ && uv run mypy src/
|
|
|
|
FROM base AS production
|
|
COPY pyproject.toml .
|
|
RUN uv sync --no-dev --frozen || uv sync --no-dev
|
|
COPY . .
|
|
ENTRYPOINT ["sh", "entrypoint.sh"]
|
|
CMD ["uv", "run", "uvicorn", "rehearsalhub.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "2"]
|