build-python-dockerfiles
Build Python Dockerfiles
Use this skill to author Dockerfiles for Python projects using uv and multi-stage builds.
The default pattern is based on Hynek Schlawack's article Production-ready Python Docker Containers with uv.
Workflow
- Detect whether the project is packaged (installable) or unpackaged (run from copied source).
- Choose a base image strategy:
- Default to
python:<version>-slimfor generic Python services. - Use an OS image like
ubuntu:noblewhen system packages or org-standard base images matter. - Keep build and runtime on the same distro family.
- Avoid Alpine unless the user has a hard requirement.
- Default to
- Install dependencies before copying source so lockfile changes and app code changes stay in separate layers.
- Keep dependency sync and app install in separate
uv syncsteps. - Pick the runtime command pattern that matches the app type.
- Verify the final Dockerfile against the checklist in this file.
Required build patterns
More from baggiponte/skills
codebase-librarian
Create a comprehensive inventory of a codebase. Map structure, entry points, services, infrastructure, domain models, and data flows. Pure documentation—no opinions or recommendations. Use when onboarding to an unfamiliar codebase, documenting existing architecture before changes, preparing for architecture reviews or migration planning, or creating a reference for the team. Triggers on requests like "map this codebase", "document the architecture", "create an inventory", or "what does this codebase contain".
20code-refactor
Systematic refactoring of codebase components through a structured 3-phase process. Use when asked to refactor, restructure, or improve specific components, modules, or areas of code. Produces research documentation, change proposals with code samples, and test plans. Triggers on requests like "refactor the authentication module", "restructure the data layer", "improve the API handlers", or "clean up the payment service".
12architecture-design-critique
Perform a codebase-wide architectural review through a Ports & Adapters (hexagonal architecture) lens. Assess boundary violations, coupling issues, and dependency direction. Produces a prioritized improvement roadmap. Use when reviewing architecture for testability/portability, assessing technical debt, planning refactoring efforts, or evaluating codebase health. Triggers on requests like "review the architecture", "assess coupling", "hexagonal analysis", "check boundary violations", or "architecture critique".
9oracle
Submit an implementation plan to GPT 5.2-xhigh for review by a senior engineer persona. The Oracle provides direct, honest critique focused on simplicity and pragmatic excellence. Use when you have a detailed implementation plan and want a second opinion before coding. Triggers on "review my plan", "get Oracle feedback", "consult the Oracle", "plan review", or when you want senior engineer critique on an implementation approach.
2context7
Retrieve up-to-date documentation for software libraries, frameworks, and components via the Context7 CLI using `bunx ctx7`. Use this whenever you need current docs, API references, code examples, migration details, or verification for a library or framework instead of relying on training data. Triggers on requests like "look up the docs for X", "find the latest API for Y", "show me examples from the docs", "check the current React/Next.js/FastAPI docs", or "verify this library usage against current documentation".
2spark-context-curator
Ultra-fast, read-only codebase exploration and context curation for GPT-5.3 Codex Spark. Use when you need deep repository understanding without modifying anything: architecture mapping, flow tracing, ownership discovery, incident/code-review prep, or implementation planning. Triggers on requests like \"explore this codebase\", \"curate context\", \"map where X happens\", \"investigate before editing\", or \"read-only deep dive\".
2