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:
@@ -2,14 +2,15 @@ FROM python:3.12-slim AS base
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN pip install uv
|
RUN pip install uv
|
||||||
|
|
||||||
FROM base AS development
|
FROM python:3.12-slim AS development
|
||||||
# python:3.12-slim has no bare 'python' binary; without this uv invalidates the baked venv on every start
|
WORKDIR /app
|
||||||
RUN ln -sf /usr/local/bin/python3 /usr/local/bin/python
|
|
||||||
COPY pyproject.toml .
|
COPY pyproject.toml .
|
||||||
COPY src/ src/
|
COPY src/ src/
|
||||||
RUN uv sync
|
# Install directly into system Python — no venv, so uvicorn's multiprocessing.spawn
|
||||||
COPY . .
|
# subprocess inherits the same interpreter and can always find rehearsalhub
|
||||||
CMD ["uv", "run", "uvicorn", "rehearsalhub.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
|
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
|
FROM base AS lint
|
||||||
COPY pyproject.toml .
|
COPY pyproject.toml .
|
||||||
|
|||||||
Reference in New Issue
Block a user