Repository navigation
fix(docker): docker compose build app works without a .git directory in the image - #1737
Open
dimitri-yatsenko wants to merge 3 commits into
Open
dimitri-yatsenko wants to merge 3 commits into
dimitri-yatsenko wants to merge 3 commits into
Conversation
The Docker build context has no .git directory, so hatch-vcs found no version and 'docker compose build app' failed. The Dockerfile now builds the datajoint wheel with SETUPTOOLS_SCM_PRETEND_VERSION set from the DJ_BUILD_VERSION build argument (default 0.0.0+docker), then installs it. Dependencies are installed without the variable, so none built from source picks up that version. Fixes #1723.
dimitri-yatsenko
requested review from
MilagrosMarin,
lum-agilyti and
ttngu207
November 21, 2026 01:46
MilagrosMarin
previously approved these changes
Nov 28, 2026
MilagrosMarin
left a comment
Contributor
There was a problem hiding this comment.
Thanks @dimitri-yatsenko, I built the image to check this end to end:
- On master,
docker buildfails with the setuptools-scmLookupError; with this branch it succeeds. - Default build reports
0.0.0+docker(bothimportlib.metadataanddj.__version__);--build-arg DJ_BUILD_VERSION=2.3.7reports2.3.7. - In the 2.3.7 image, only datajoint got that version, so the pretend version stays scoped to the wheel as intended.
- An editable install from a clone with
.gitinside the built image reports the real git version (2.3.5.devN+g...), so thedjtestpath is unaffected; the env var is set inline in the RUN step and does not persist in the image. - Both new unit tests pass and both fail with master's Dockerfile and compose file restored.
Scoping the version to the datajoint wheel alone is the right call for keeping source-built dependencies honest.
…rsion # Conflicts: # Dockerfile
Member
Author
|
Merged master in (e97c974) after #1726. The Dockerfile conflict is resolved as the description says, keeping both changes: |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
docker compose build appfailed onmaster, and so diddocker compose --profile test up djtest --build. The package version comes from the git tag through hatch-vcs. The Docker build context has no.gitdirectory, so hatch-vcs found no version andpip install /mainstopped with aLookupError.The Dockerfile now gives the version explicitly. It comes from a new build argument,
DJ_BUILD_VERSION, which defaults to0.0.0+docker. To build an image that reports a release version, set it:DJ_BUILD_VERSION=2.3.7 docker compose build app.Fixes #1723.
Changes
Dockerfile: aDJ_BUILD_VERSIONbuild argument. The datajoint wheel is built alone (pip wheel --no-deps) withSETUPTOOLS_SCM_PRETEND_VERSIONset to it, then installed. Dependencies are installed without the variable. Otherwise a dependency built from source with setuptools-scm would get the same version. The per-package form of the variable does not work here, because hatch-vcs does not pass the package name to setuptools-scm.docker-compose.yaml: passDJ_BUILD_VERSIONto theappbuild (and so todjtest, which extends it).The
djtestcommand still runspip install -e ".[test]"from the mounted source, which has.git, so the tests run with the real version.Tests
docker compose build appfails onmasterwith theLookupErrorand succeeds with this change. The image reports0.0.0+dockerby default and2.3.7withDJ_BUILD_VERSION=2.3.7.docker compose --profile test build djtestsucceeds.tests/unit/test_docker_build.pychecks the build files: the Dockerfile builds the wheel with the version set and without dependencies, and the compose file passes the argument. It fails before the change. Building the image in the unit tests would be too slow.Note for merging
#1726 changes the same
pip installline, to add'pymysql[rsa]'. Whichever PR merges second resolves the conflict by keeping both changes:pip install -q --no-cache-dir /tmp/dist/datajoint-*.whl 'pymysql[rsa]'.