|
1 | 1 | # (C) 2021 GoodData Corporation |
2 | 2 | ARG PY_TAG |
3 | | -FROM ghcr.io/astral-sh/uv:0.12 AS uv |
| 3 | +FROM ghcr.io/astral-sh/uv:0.12.5 AS uv |
4 | 4 | FROM python:${PY_TAG} |
5 | 5 |
|
6 | 6 | ARG PY_TAG |
@@ -40,16 +40,35 @@ WORKDIR /data |
40 | 40 | COPY pyproject.toml uv.lock ./ |
41 | 41 |
|
42 | 42 | # Install tox and tox-uv as system packages so they're available globally. |
43 | | -# NOTE: `uv pip install --group` reads the group's requirements from pyproject.toml but |
44 | | -# resolves them FRESH from the index -- it does NOT read uv.lock. Every version that must |
45 | | -# stay fixed therefore needs an explicit bound in the group itself; in particular `uv`, |
46 | | -# whose console script installs over the binary copied above. |
| 43 | +# Via `uv export` and not `uv pip install --group`: the latter re-resolves fresh from the |
| 44 | +# index, while export reads uv.lock, so the image gets exactly the pinned versions. |
| 45 | +# The group uses tox-uv-bare, so nothing here installs a `uv` console script over the |
| 46 | +# binary COPYed above -- that COPY is the image's only uv, hence its exact pin. |
47 | 47 | # Clean up dependency files after installation to reduce image size |
48 | 48 | RUN set -x \ |
49 | | - && uv pip install --system --group tox \ |
50 | | - && rm -f pyproject.toml uv.lock \ |
| 49 | + && uv export --frozen --only-group tox -o /tmp/tox-requirements.txt \ |
| 50 | + && uv pip install --system -r /tmp/tox-requirements.txt \ |
| 51 | + && rm -f pyproject.toml uv.lock /tmp/tox-requirements.txt \ |
51 | 52 | && true |
52 | 53 |
|
| 54 | +# Any uv command here must not REWRITE the bind-mounted host uv.lock if it thinks it is |
| 55 | +# stale -- fail instead. Not UV_FROZEN: tox-uv reads that and downgrades its own --locked |
| 56 | +# to --frozen, silently accepting a stale lock. Must be set AFTER the export above, which |
| 57 | +# is rejected in combination with UV_LOCKED and has to stay --frozen because only the root |
| 58 | +# pyproject.toml and uv.lock exist at that layer for --locked to validate against. |
| 59 | +ENV UV_LOCKED=1 |
| 60 | + |
| 61 | +# Use the lock-pinned tox installed system-wide above rather than project_common.mk's |
| 62 | +# default `uv run tox`, which would first sync the whole workspace into a throwaway |
| 63 | +# in-container project env (measured: 58 packages, ~7s) just to obtain the same tox. |
| 64 | +ENV TOX=tox |
| 65 | + |
| 66 | +# The repo is bind-mounted at /data, so the default project environment (/data/.venv) is |
| 67 | +# the developer's host venv; a `uv run` here would rebuild it against this image's Linux |
| 68 | +# interpreter. Redirect it somewhere container-local (/tmp, not a home dir: the runtime |
| 69 | +# user is created by entrypoint.sh, so no home exists when this ENV is evaluated). |
| 70 | +ENV UV_PROJECT_ENVIRONMENT=/tmp/uv-project-venv |
| 71 | + |
53 | 72 | COPY .docker/entrypoint.sh /entrypoint.sh |
54 | 73 |
|
55 | 74 | LABEL image_name="GoodData Python SDK test image with python, tox and make" |
|
0 commit comments