Skip to content

Commit 3df759b

Browse files
VijitSingh97claude
andcommitted
build(#283): uv best-practice polish (cache mounts, .python-version, drop redundant PYTHONPATH)
Follow-up tidy from a best-practices review of the uv adoption: - Dockerfile: swap UV_NO_CACHE for BuildKit cache mounts on the `uv sync` steps (the documented uv-in-Docker pattern) — faster rebuilds, and the cache stays out of the image layers. - Add build/dashboard/.python-version (3.11) so local `uv` defaults to the same interpreter as the digest-pinned Docker base and CI. - Drop the now-redundant PYTHONPATH=build/dashboard from the fakes test (Makefile + CI): uv editable-installs the project into the venv, so the source no longer needs to be on sys.path. Verified the fakes still pass (12). Re-verified: docker test stage (532 tests in-container) + prod stage build with cache mounts; make test-dashboard/test-fakes/lint-py green; uv lock --check clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7e7009d commit 3df759b

4 files changed

Lines changed: 6 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Fake-daemon contract test (real clients vs controllable fakes)
2929
# Points the real Monero/Tari clients at the integration fakes and asserts they parse
3030
# every state (synced/syncing/down). Docker-free, so it runs on every PR (issue #54).
31-
run: PYTHONPATH=build/dashboard uv run --locked --project build/dashboard --extra test python -m pytest tests/integration/fakes -q
31+
run: uv run --locked --project build/dashboard --extra test python -m pytest tests/integration/fakes -q
3232

3333
frontend:
3434
name: Frontend logic tests (node --test)

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ test-integration-selftest: ## Integration harness pure-logic self-test (no serve
1717
bash tests/integration/selftest.sh
1818

1919
test-fakes: ## Fake-daemon contract test — real dashboard clients vs controllable fakes (no docker)
20-
PYTHONPATH=build/dashboard uv run --locked --project build/dashboard --extra test \
21-
python -m pytest tests/integration/fakes -q
20+
uv run --locked --project build/dashboard --extra test python -m pytest tests/integration/fakes -q
2221

2322
test-mini-stack: ## Fake-daemon docker mini-stack end-to-end (needs docker; CI)
2423
bash tests/integration/mini-stack/run-mini-stack.sh

build/dashboard/.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.11

build/dashboard/Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ COPY --from=ghcr.io/astral-sh/uv:0.10.10@sha256:cbe0a44ba994e327b8fe7ed72beef1aa
1010

1111
# Install into a project venv on PATH (so entrypoint.sh's `python3` resolves to it); use the
1212
# digest-pinned base interpreter (never let uv download a different Python); compile bytecode and
13-
# copy (not hardlink) since the cache and target may be on different layers.
13+
# copy (not hardlink) from the BuildKit cache mount used on the sync steps below.
1414
ENV UV_PYTHON_DOWNLOADS=never \
1515
UV_PROJECT_ENVIRONMENT=/app/.venv \
1616
UV_COMPILE_BYTECODE=1 \
1717
UV_LINK_MODE=copy \
18-
UV_NO_CACHE=1 \
1918
PATH="/app/.venv/bin:$PATH"
2019

2120
# System dependencies.
@@ -36,7 +35,7 @@ COPY mining_dashboard/ ./mining_dashboard/
3635
# a normal `docker compose build` targets the production stage and skips it.
3736
# ==========================================================================
3837
FROM base AS test
39-
RUN uv sync --locked --extra test
38+
RUN --mount=type=cache,target=/root/.cache/uv uv sync --locked --extra test
4039
COPY tests/ ./tests/
4140
RUN python -m pytest --cov=mining_dashboard --cov-report=term-missing --cov-fail-under=80
4241

@@ -45,7 +44,7 @@ RUN python -m pytest --cov=mining_dashboard --cov-report=term-missing --cov-fail
4544
# ==========================================================================
4645
FROM base AS production
4746
# Runtime deps + the package only (no test/dev extras).
48-
RUN uv sync --locked
47+
RUN --mount=type=cache,target=/root/.cache/uv uv sync --locked
4948
COPY entrypoint.sh .
5049
RUN chmod +x entrypoint.sh
5150

0 commit comments

Comments
 (0)