Integrating Python Poetry with Docker

后端 未结 7 546
轻奢々
轻奢々 2021-01-29 17:51

Can you give me an example of a Dockerfile in which I can install all the packages I need from poetry.lock and pyproject.toml into my imag

7条回答
  •  北恋
    北恋 (楼主)
    2021-01-29 18:14

    That's minimal configuration that works for me:

    FROM python:3.7
    
    ENV PIP_DISABLE_PIP_VERSION_CHECK=on
    
    RUN pip install poetry
    
    WORKDIR /app
    COPY poetry.lock pyproject.toml /app/
    
    RUN poetry config virtualenvs.create false
    RUN poetry install --no-interaction
    
    COPY . /app
    

    Note that it is not as safe as @sobolevn's configuration.

    As a trivia I'll add that if editable installs will be possible for pyproject.toml projects, a line or two could be deleted:

    FROM python:3.7
    
    ENV PIP_DISABLE_PIP_VERSION_CHECK=on
    
    WORKDIR /app
    COPY poetry.lock pyproject.toml /app/
    
    RUN pip install -e .
    
    COPY . /app
    

提交回复
热议问题