Optimizing Production Images with Poetry Dependency Groups
Learn how to use Poetry dependency groups to separate production runtime requirements from development tools, reducing Docker image size and improving security.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Learn how to use Poetry dependency groups to separate production runtime requirements from development tools, reducing Docker image size and improving security.
Learn how Poetry's lock file and dependency groups give you reproducible Python installs and smaller deployment artifacts, with a concrete example and version-specific cautions.
Poetry's lock file pins exact versions and hashes while dependency groups separate runtime from dev tooling. Here's how to use both for reproducible installs and slim production images.
Use Poetry dependency groups to keep pytest, black, and mypy out of production while one committed lock file keeps every environment reproducible. Covers group syntax, install flags, and verification.
Python projects still use fragile setup.py files. Switching to pyproject.toml centralizes metadata, separates packaging from runtime, and unlocks modern build backends like Poetry. This blog walks through the why, how, and trade‑offs with a concrete example and actionable next steps.
Poetry's dependency groups (1.2.0+) let you split runtime, test, lint, and optional dependencies into named sets and install only what each CI stage or environment needs — smaller images, faster pipelines.
Learn how to declare dependency groups in pyproject.toml, install only runtime deps for production, and verify a lean environment.
Poetry 1.2+ dependency groups keep dev tooling out of published wheels, while extras remain the only way to let downstream users select optional features via pip. Use both: groups for test/lint/docs, extras for public feature flags like [redis] or [async].
pyproject.toml declares what you want; poetry.lock records what you actually get. A look at Poetry's resolver, a verifiable example, and the trade-offs.