Closed BlackZork closed 1 year ago
As I misunderstood that I can pass version to POETRY_DYNAMIC_VERSIONING_BYPASS this case is not as important for me, because now I can run poetry install --no-root
without mounting .git directory.
To avoid installation of dependencies on every build of devel container I had to set version as constant this way:
# Set version to constant value to prevent
# dependencies layer invalidation
ENV POETRY_DYNAMIC_VERSIONING_BYPASS=1
RUN poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR
ARG my_version
ENV POETRY_DYNAMIC_VERSIONING_BYPASS=$my_version
# At runtime we will mount sources permanently from docker-compose
# rw is needed for poetry install to overwrite __version__ variable
# which will be lost anyway. We have to use pkg_resources.get_distribution to
# discover package version at runtime
RUN --mount=type=bind,src=pd-docker,target=pd-docker,rw poetry install --without dev && rm -rf $POETRY_CACHE_DIR
I think you can close this issue.
docker --version Docker version 24.0.2, build cb74dfcd85
Due to #122 I have to bind a whole repository when trying to use poetry inside a docker image.
Running
poetry version
outside invalidates a docker layer that stores poetry dependencies.I attached a sample project pd-docker.tar.gz
To replicate:
poetry install
docker build --build-context=git=.git .
docker build --build-context=git=.git .
again. It should not download anything:poetry version
docker build --build-context=git=.git .
againRepeat steps 6 and 7. Sometimes docker considers layer 6/6 as not changed, but most of the time it is rebuild.
This layer should not be rebuild after running
poetry version