Integrating Python Poetry with Docker

后端 未结 7 431
轻奢々
轻奢々 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:22

    Here's a stripped example where first a layer with the dependencies (that is only build when these changed) and then one with the full source code is added to an image. Setting poetry to install into the global site-packages leaves a configuration artifact that could also be removed.

    FROM python:alpine
    
    WORKDIR /app
    
    COPY poetry.lock pyproject.toml ./
    RUN pip install --no-cache-dir --upgrade pip \
     && pip install --no-cache-dir poetry \
     \
     && poetry config settings.virtualenvs.create false \
     && poetry install --no-dev \
     \
     && pip uninstall --yes poetry \
    
    COPY . ./
    

提交回复
热议问题