nomad-coe / nomad

NOMAD lets you manage and share your materials science data in a way that makes it truly useful to you, your group, and the community.
https://nomad-lab.eu
Apache License 2.0
64 stars 14 forks source link

oasis fails to start due to missing git directory #73

Closed mdforti closed 11 months ago

mdforti commented 1 year ago

our NOMAD Oasis was working. Yesterday I rebased to get updates and now the command

docker compose up -d 

fails with this message:

ERROR [dev_python 28/29] RUN --mount=source=.git,target=.git,type=bind python -m build --sdist 
------
 > [dev_python 28/29] RUN --mount=source=.git,target=.git,type=bind python -m build --sdist:
------
failed to solve: failed to compute cache key: "/.git" not found: not found

my docker-compose.yaml is this:

https://github.com/mdforti/nomad/blob/develop-icams-oasis/ops/docker-compose/nomad-oasis/docker-compose.yaml_icams_oasis

I tried not ignoring any .git in .dockerignore but the result is still the same.

markus1978 commented 1 year ago

The error comes from a docker build command. The lines refer to our Dockerfile. It looks like you setup your docker-compose to build the nomad image locally? I am not sure how the build directive in docker-compose works, but it looks like it is not providing the .git files to the build context. The Dockerfile needs those because we use the setuptools.build_meta plugin that uses git to infer the nomad package version from git tags.

Either there is a way to change the behaviour of the docker-compose build directive, our you build the image manually. This is not a recent change, this is in the code for over 6 months.

If you want to hack your way out of this, there might be a dirty solution. If you look at those lines in the Dockerfile

RUN echo "git_describe_command = \"git describe --tags --long --match \\\"*[0-9]*\\\"\"" >> pyproject.toml
RUN --mount=source=.git,target=.git,type=bind python -m build --sdist

You need to change how setuptools.build_meta is determining the version. You could replace the command in the first line with something generic. Instead of git describe ..., you could do echo v1.2.0-latest or something. With this you can remove the --mount=source=.git,target=.git,type=bind in the next line, because it won't call git describe anymore.

mdforti commented 1 year ago

ok, this was my fault. I solved this in the past and now I had a missing word in the command.

the complete command for docker compose is:

DOCKER_BUILDKIT=1 docker compose build --build-arg BUILDKIT_CONTEXT_KEEP_GIT_DIR=1

where I was missing the 'compose', so plain docker was failing in building the image.

no need for dirty tricks

markus1978 commented 11 months ago

Seems to be fixed for you. I am closing this now.