Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Docker image with poetry pre-installed

License

Notifications You must be signed in to change notification settings

biggates/poetry-docker

Repository files navigation

poetry-docker

2.2.1-py3.13-bookworm badge 2.2.1-py3.13-slim badge 2.2.1-py3.12-bookworm badge 2.2.1-py3.12-slim badge 2.2.1-py3.11-bookworm badge 2.2.1-py3.11-slim badge 2.2.1-py3.10-bookworm badge 2.2.1-py3.10-slim badge Docker Publish Badge

a Docker image that includes Poetry for CI/CD pipelines.

Supported tags

  • 2.2.1-py3.13-bookworm
  • 2.2.1-py3.13-slim
  • 2.2.1-py3.12-bookworm
  • 2.2.1-py3.12-slim
  • 2.2.1-py3.11-bookworm
  • 2.2.1-py3.11-slim
  • 2.2.1-py3.10-bookworm
  • 2.2.1-py3.10-slim

See versions.json for further information.

Usage

In your pipeline / actions, replace docker image from python to biggates/poetry, for example:

# FROM python:3.10-slim
FROM biggates/poetry:2.1.4-py3.10-slim

details

Poetry is installed to /root/.local/bin. In case the path fails, use the following line in Dockerfile:

ENV PATH="/root/.local/bin:$PATH"

Usage in multistage builds

A typical usage is use poetry to install all the dependencies in one stage, and copy the whole venv to another stage and use it.

# first stage
FROM biggates/poetry:2.1.4-py3.10-slim as venv-creator
ENV POETRY_NO_INTERACTION=1 \
 POETRY_VIRTUALENVS_IN_PROJECT=1 \
 POETRY_VIRTUALENVS_CREATE=1 \
 POETRY_CACHE_DIR=/tmp/poetry_cache
WORKDIR /app
# add poetry managed dependencies
ADD poetry.lock poetry.toml pyproject.toml README.md ./
# let poetry create the venv
RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry install
# second stage
FROM python:3.10-slim as runtime
# activate the venv
ENV VIRTUAL_ENV=/app/.venv \
 PATH="/app/.venv/bin:$PATH"
WORKDIR /app
# copy the previously created venv
COPY --from=venv-creator ${VIRTUAL_ENV} ${VIRTUAL_ENV}
# add current project files
COPY . /app
# rest of your dockerfile
CMD ["python", "myscript.py"]

reference: Blazing fast Python Docker builds with Poetry

About

Docker image with poetry pre-installed

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

AltStyle によって変換されたページ (->オリジナル) /