-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#2822 Add dockerfile install instructions #3209
Conversation
@@ -29,6 +29,24 @@ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poet | |||
```powershell | |||
(Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | python - | |||
``` | |||
### dockerfile install instructions | |||
poetry.Dockerfile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is all this required? Shouldn't this just be pip install poetry
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if I change the whole thing to:
poetry.Dockerfile | |
This is not officially supported yet. Use your container/image as a virtual machine and install it using any way mentioned here and we recommend that you still use virtualenvs. |
|
||
COPY --from=poetry:1 /root/.poetry /root/.poetry | ||
ENV PATH="/root/.poetry/bin:${PATH}" | ||
RUN poetry config virtualenvs.create false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not something we recommend at all.
One of the reasons why we have yet to officially provide a "poetry contianer" is that poetry can be installed in container environments using What we might do later, is a provide a repository with container usage patterns for various use cases and build scenarios. |
The problem I see using Probably if you can explain why someone would go to the hassle of update the version of the interpreter when I could update the virtual environment? or in this case in the other way around why use the virtual environment when I could use directly the interpreter that I want? |
@abn I agree. There's no need for the Poetry team to maintain a Docker container image. The official Python image is adequate.
This would be nice to have. I work with Poetry in Docker frequently, and I'm happy to help with this in the future. I would suggest closing this PR, and providing info on Docker use cases outside of the core docs.
I've never seen dependency conflicts arise in this situation. I would guess it's quite rare, but I would welcome a reproducible example of Docker dependency conflicts.
@Saphyel if you're looking for a Docker configuration that might suit your preferences, I would suggest the following: FROM python:3.8
ENV POETRY_HOME=/opt/poetry POETRY_VIRTUALENVS_CREATE=false PYTHONPATH=/app
COPY poetry.lock pyproject.toml /app/
WORKDIR /app/
RUN curl -fsS -o get-poetry.py https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py && \
python get-poetry.py -y && . $POETRY_HOME/env && \
poetry install --no-dev --no-interaction --no-root
COPY mypackage /app/mypackage
CMD python /app/mypackage/main.py
|
Regarding dependency conflicts; there are a few things to note here.
Putting all that together, recommending not using a virtual environment is not necesarily the best idea. And unfortunately, there has been bugs in the issue history if you dig that have been caused due to this. All that said, I am not necesarily saying it is "wrong", but that it just shouldn't be the recommended pattern. |
I am really confused here. https://python-poetry.org/docs/#installing-with-pip The poetry docs state that "Be aware that it will also install Poetry's dependencies which might cause conflicts with other packages." is on par with what @Saphyel said. But the opposite is being recommended in this discussion. Then what is the recommended way @abn ? Can we see an example? Should we use the method @br3ndonland recommended or something else like in issues #856 or #1879 recommends? |
@9mido I think they are recommending using virtualenv inside of docker, I know is sort of defeating the whole purpose of using containers and having an even bigger image. So, my recommendation is if you have a cloud based project the recommendation is use pip, poetry, as being probed here, it is not ready yet. |
I don't think this defeats the whole purpose of using containers at all. Containers provide sealed, standardised deployment units. Using virtual environments in them will still do that. |
I have to agree with @robertlagrant here -- that is what is being said. Containers do not eliminate the desire to keep your app's dependencies separate from Poetry. While you could subvert Poetry by installing it into a virtualenv in your Anyway, this suggestion is the real takeaway here:
Any work to provide such a resource would be appreciated. It could be officially promoted/supported by the Poetry team, or remain a standalone resource with 'community' status in the docs. I'm going to close this PR for now, but please do use it as a base for the above repo/resource. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Pull Request Check List
Resolves: #2822
Ideally if the poetry team can provide an official poetry.Dockerfile that would be amazing, I'd be happy to help/maintining/looking after so people can only need to implement the project.Dockerfile file.
it's also possible to do it in one file combining the commands if you do not care too much about the best practices in docker.
I'm happy to push or accept any changes on my commit/s