Simple instalation without cache
See original GitHub issue- I have searched the issues of this repo and believe that this is not a duplicate.
- I have searched the documentation and believe that my question is not covered.
Feature Request
TL;DR
I’d like to use pyproject.toml
for instaling dependencies for project with minimal impact on size where the docker container provides sufficient isolation. E.G.:
poetry install --no-root --no-cache --no-interaction
Details, blockers and other similar issues
I’d like to use poetry in docker as simple as pip install --no-cache-dir -r requirements.txt
(with cleared cache), but have some trouble. I have a local dependency which is wanted to be editable in the same local folder.
...
[tool.poetry.dependencies]
python = "^3.8"
numpy = "^1.19.4"
pandas = "^1.1.4"
jupyterlab = "^2.2.9"
[tool.poetry.dev-dependencies]
# is installed as "python setup.py develop" and can be edited in mypackage folder
mypackage = {path = "./mypackage", develop = true}
Installation in docker:
FROM python:3.8-slim-buster
WORKDIR /lab
RUN pip install poetry --no-cache-dir && \
poetry config virtualenvs.create false
COPY poetry.lock pyproject.toml .
# my local dependency
COPY ./mypackage ./mypackage
# too big
RUN poetry install --no-root --no-interaction
EXPOSE 9180
CMD ["jupyter", "lab", "--allow-root", "--ip=0.0.0.0", "--port=9180", "."]
I’ve tried also RUN poetry install --no-root --no-interaction && poetry cache clear --no-interaction --all pypi
, but size is the same.
I found https://github.com/python-poetry/poetry/issues/1879#issuecomment-592133519, but there is too many rows and dockerfile is being complex.
I’ve also tried https://github.com/python-poetry/poetry/issues/1879#issuecomment-650384931:
RUN poetry export -f requirements.txt --dev --without-hashes | pip install --no-cache-dir -r /dev/stdin
This is fine workaround but its not suitable for mypackage
(local package) dependency. Export row of package is mypackage @ /home/vh/test-docker/mypackage; python_version >= "3.8" and python_version < "4.0"
and pip searching this package on pypi and fail.
When I remove the local dependency and run previous command without --dev
param:
RUN poetry export -f requirements.txt -v --without-hashes | pip install --no-cache-dir -r /dev/stdin && \
cd mypackage && \
poetry install --develop mypackage && \
cd ..
Also crashes with error that --develop
param was removed with release poetry v1.0.0. But I found opened issue: https://github.com/python-poetry/poetry/issues/2572.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:9 (6 by maintainers)
Another option to keep the cache out of the final image is to use docker BuildKit’s cache feature. I’ve used it with success.
Example
This way, docker keeps your poetry cache around for quick builds, layer sharing, etc. but not in the final image.
Personal opinion:
I see how it might be a helpful feature. On the other hand I can’t help but think that it should be quite easy to just delete the cache and other build artefacts and what not right after the installation:
We might spare us adding complexity into poetry’s code base. But maybe also it is not as simple as that and a
--no-cache
feature makes sense.