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
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.
```pyproject.toml
...
[tool.poetry.dependencies]
python = "^3.8"
numpy = "^1.19.4"
pandas = "^1.1.4"
jupyterlab = "^2.2.9"
[tool.poetry.dev-dependencies]
mypackage = {path = "./mypackage", develop = true}
Installation in docker:
```Dockerfile
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.
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:
RUN poetry install ... && rm -rf ~/.cache/pypoetry/{cache,artifacts}
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.
Yes, these dirs contains some instalation balast. I removed them and container is much smaller, it works thanks.
EDIT: but keep it the issue open for feature request of --no-cache param.
Most helpful comment
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-cachefeature makes sense.