Skip to main content

PyBuilder Docker Build Plugin

Summary

This project is a plugin for PyBuilder that will perform a docker build for a Python package. PyBuilder Docker Build Plugin attempts to use sane defaults so that in most cases you only need add a Dockerfile to your project base directory and a docker image will be built when you call the appropriate task.

Usage

To use this plugin in your build.py file add the following line to the plugins section:

use_plugin('pypi:pybuilder_docker_build')

This will add the following tasks to your build:

Task Description
docker_build Performs docker build
docker_save Saves docker image to dist dir
docker_push Pushes docker image upstream to your repo

The following properties are available:

Property Value Default Usage
docker_cli True / False False Use docker cli to do build
docker_path str docker Path to docker executable
docker_build_path str basedir property Path to docker build directory
docker_build_file str Dockerfile Dockerfile to use for build, relative path from docker_build_path
docker_build_force_rm True / False False Use the force rm feature of docker build
docker_image_repo str project.name The name of the image repository
docker_image_tag str latest A tag to apply to the repository
docker_build_args dict None A dict of build args
docker_registry_auth dict None A dict containing username and password for login / auth
docker_registry str None A http / https URL of registry for authentication and push

By default there are several build args that are supplied to the docker build, additional args can be added with the docker_build_args property. The default build args are:

Argument Value
PROJECT_NAME project.name
PROJECT_VERSION project.version
PROJECT_DIST_VERSION project.dist_version
PROJECT_DIST_DIR The relative path from the docker_build_path property to $dir_dist

Authentication

If you need to push images to a registry then you probably need to set credentials. Don't do this directly in your build file but rather look them up from environment or use some other method for passing secrets to code. The following is an extract from the hello-world sample project in the samples directory:

@init
def set_properties(project: Project):
    project.set_property("docker_build_args", {"EXTRA_ARG": "Extra build arg"})
    project.set_property("docker_image_repo", "dockerhubusername/hello-world")
    # Don't put your credentials in code, look them up from environment or
    # use some other way to pass secrets to your code
    project.set_property(
        "docker_registry_auth",
        {
            "username": os.getenv("DOCKER_HUB_USERNAME"),
            "password": os.getenv("DOCKER_HUB_PASSWORD")
        }
    )

Metadata

Release files for pybuilder-docker-build 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pybuilder-docker-build 0.5.1
File Size Uploaded
pybuilder-docker-build-0.5.1.tar.gz 4.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pybuilder-docker-build 0.5.1
File Interpreter ABI Platform
pybuilder_docker_build-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.7 kB

Release files / pybuilder-docker-build-0.5.1.tar.gz

Download URL pybuilder-docker-build-0.5.1.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
81182aa3578883f7bc694e8ab49721492f6c00421bd312854ca29a06df7bbbd3
BLAKE2b-256 checksum
How to use checksums
2a4d7fca45a874f94f9de8aaf19ca3a53d99989da7ed3f484f514fd7b7f9f9c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.6

Release files / pybuilder_docker_build-0.5.1-py3-none-any.whl

Download URL pybuilder_docker_build-0.5.1-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9145b02e305c4ea6e173807fbb67b2626876ac4c9ca7d9cf5c08ebd9f54a836a
BLAKE2b-256 checksum
How to use checksums
3b2844a3becc726a9d126ff1455993e1133608f39d89837dce13676f7d5bc03b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page