Detection

migetpacks detects Python when any of these files are present in your project root:
  • requirements.txt
  • setup.py
  • Pipfile
  • pyproject.toml

Version Detection

Python version is resolved in this order: Version constraints are normalized for Docker compatibility (e.g., >=3.13 becomes 3.13).

Build Process

migetpacks generates a multi-stage Dockerfile with virtualenv isolation:

Standard pip/pipenv/poetry

uv Projects

When uv.lock is present, migetpacks uses the uv package manager natively:

Package Manager Detection

Dependency Detection

migetpacks automatically detects database and XML libraries from your dependency files and installs the required system packages:

Runtime Cleanup

The following are removed from the final image:
  • .git/, .github/
  • test/, tests/
  • __pycache__/, .pytest_cache/
  • .coverage, htmlcov/

Django Support

If manage.py is detected, python manage.py collectstatic --noinput is automatically run during the build.

Run Command

The default run command is determined in this order:

Caching

Docker Layer Caching

Dependencies are installed in a separate layer using a virtualenv. pip install is only re-run when dependency files change.

BuildKit Cache Mounts

When BUILD_CACHE_DIR is configured, BuildKit cache mounts are used:

Registry Cache

Use CACHE_IMAGE to push/pull BuildKit inline cache layers to a registry for cross-build caching.

DHI Support

Python is fully supported with Docker Hardened Images.
The -dev variant includes a shell and build tools. The runtime image is distroless with no shell, providing a minimal attack surface.
The virtualenv is copied from the builder stage to the distroless runtime, ensuring all installed packages are available without needing pip in the runtime image.

Example

With Custom Options