Fix API dev: use pip editable install instead of uv run

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>
This commit is contained in:
Mistral Vibe
2026-04-06 19:32:27 +02:00
parent ba90f581ae
commit a31f7db619

View File

@@ -2,14 +2,15 @@ FROM python:3.12-slim AS base
WORKDIR /app
RUN pip install uv
FROM base AS development
# python:3.12-slim has no bare 'python' binary; without this uv invalidates the baked venv on every start
RUN ln -sf /usr/local/bin/python3 /usr/local/bin/python
FROM python:3.12-slim AS development
WORKDIR /app
COPY pyproject.toml .
COPY src/ src/
RUN uv sync
COPY . .
CMD ["uv", "run", "uvicorn", "rehearsalhub.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
# 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 .