Skip to content

What are the best practices for using poetry with docker? #8780

Answered by sbrunner
axiangcoding asked this question in Q&A
Discussion options

You must be logged in to vote

I don't know if it's the best practice, but personally, I use multistage build like:

FROM ubuntu as base-all

RUN --mount=type=cache,target=/var/lib/apt/lists \
    --mount=type=cache,target=/var/cache,sharing=locked \
    apt-get update \
    && apt-get upgrade --assume-yes \
    && apt-get install --assume-yes --no-install-recommends python3-pip

FROM base-all as poetry

# Install Poetry
WORKDIR /tmp
COPY requirements.txt ./ # that contains poetry=<version>
RUN --mount=type=cache,target=/root/.cache \
    python3 -m pip install --disable-pip-version-check --requirement=requirements.txt

# Do the conversion
COPY poetry.lock pyproject.toml ./
RUN poetry export --output=requirements.txt

#…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@axiangcoding
Comment options

@elephantum
Comment options

@agirault
Comment options

Answer selected by axiangcoding
Comment options

You must be logged in to vote
1 reply
@axiangcoding
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants