Skip to content

poetry install needs a --force-root or similar flag for Docker #218

Closed

Description

@blakev

I've been hacking at this for a couple hours now and I can't find an elegant way to use poetry to install dependencies inside of a Docker container (during build).

It either creates it's own virtualenv which is tricky to use when you're doing multistage or multi-base (docker compose) deployments. Or, if you supply a .venv it won't activate it properly and installs can fail.

RUN curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python
COPY ./pyproject.toml /app
COPY ./pyproject.lock /app
RUN python -m poetry install --no-interaction --allow-root-install

I propose a documented config setting along the lines of settings.virtualenvs.use_root true or a install flag which conveys this as an exception to the normal flow.

Activity

  1. sdispater commented on Jun 15, 2018

    @sdispater
    Member

    If you don't want poetry to automatically create virtualenvs you can set the settings.virtualenvs.create to false like so:

    poetry config settings.virtualenvs.create false
    
  2. blakev commented on Jun 15, 2018

    @blakev
    Author

    This works! Thanks.

  3. blakev commented on Oct 25, 2018

    @blakev
    Author

    This does not work anymore as of poetry 0.12.1

  4. robertpro commented on Jan 12, 2019

    @robertpro

    @blakev can you share your Dockerfile?

  5. skorokithakis commented on Jan 28, 2019

    @skorokithakis

    @sdispater Can we get this reopened? Currently poetry doesn't have a satisfactory resolution for it, be that a flag or documentation for the existing way to do this. The setting is a bit too complicated currently because I don't know if I can include it in the pyproject.toml, or if I need to run it in Docker, or what...

  6. floer32 commented on Mar 14, 2019

    @floer32

    I'm curious about the details of this statement from OP @blakev, even if a change is not made to poetry in relation to it :) As I am about to use poetry with virtualenv with multistage builds, probably.

    It either creates it's own virtualenv which is tricky to use when you're doing multistage or multi-base (docker compose) deployments. Or, if you supply a .venv it won't activate it properly and installs can fail.

  7. hackrole commented on Nov 26, 2019

    @hackrole

    I think use config seems not a good idea compare to directly pass command line options.
    command-line-option is more self-explain, more close to where it was really used. And more convention while using in gitlab-ci or docker build, which will need only one command instead of two.
    And who would like to keep a config file in gitlab CI worker or docker images??

    anyway even if some command line tool use config file, they will provide command line option to override the default config as a choices.

    how ever the poetry seems high depend on config file and not provide equal command option, which make it something hard to use and hard to find the solution.

  8. blakev commented on Jan 9, 2020

    @blakev
    Author

    Amazing how this has come full circle, since I ran into this issue AGAIN today.

    This is the way to solve it,

    RUN POETRY_VIRTUALENVS_CREATE=false poetry install
  9. github-actions commented on Mar 3, 2024

    @github-actions

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  10. locked as resolved and limited conversation to collaborators on Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions