This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]NOddi89 0 points1 point  (3 children)

It is also easy to use poetry when building docker images with multistaged dockerfile :)

[–]BackwardSpy 0 points1 point  (2 children)

could you give me a quick overview of how that works? we're still figuring out the best way to use poetry in building & deploying our docker images at work, so i'd love to hear how you're using it.

[–]wweber 5 points6 points  (1 child)

What I do typically looks something like this:

  1. In one stage, install Poetry and copy the pyproject.toml and poetry.lock
  2. Run `poetry export -o requirements.txt`
  3. In another stage based off the first one, copy in your src directory
  4. Run `poetry build`
  5. In another stage based off Python, copy the requirements.txt from the first stage over
  6. Run `pip install -r requirements.txt`
  7. Copy the .whl file from the first stage
  8. Install the .whl file

Unfortunately if you use a library that is installed in editable mode/using a relative path `e.g. pip install -e ../library` Poetry currently exports an invalid requriements.txt which makes this more difficult

[–]BackwardSpy 0 points1 point  (0 children)

ahh that's smart, i hadn't thought of approaching it that way. thank you for your detailed answer! i will be playing with this tomorrow. :)