Skip to main content

Build Docker images for use in Kubernetes deployments

Project description

buildimage

Build Docker images for use in Kubernetes deployments. The build images can be tagged with configurable values. The recomended way is to tag it with the tree hash from the docker folder. This is the way the example below use.

The script uses a file named images.yaml to describe what images to build and what deployments to patch with new tags. Built images will also have some labels with metadata defined. The YAML file can use facts using the Jinja2 template format {{ name }}.

Installation

Install from PyPI:

pip install buildimage

Usage

Run the buildimage command in a directory containing an images.yaml file or specify the directory as an argument:

buildimage [OPTIONS] DIRECTORY

Options

  • --nopush: Skip pushing built images
  • --image IMAGE: Only build named images (can be specified multiple times)
  • DIRECTORY: Path to directory containing the images.yaml file (default: current directory)

Configuration

Create an images.yaml file in your project root with the following format:

images:
  - name: "image name"               (required)
    directory: "build-directory"     (required)
    dockerFile: "Dockerfile"
    tags:                            (required)
      - "tree-{{treeHash}}"
    labels:
      - name: com.mydomain.repository
        value: "{{repository}}"
    buildArgs:
      - name: "build-arg-name"
        value: "build-arg-value"
    deployments:
      - path: "path/to/deployment.yaml"
        match: "regex-to-match"
        replace: "replacement-value"

Available Facts

The following facts are available for templating in images.yaml:

  • {{ branch }}: Current Git branch
  • {{ remote }}: Git remote name
  • {{ repositoryFull }}: Full repository URL
  • {{ repository }}: Repository URL without user info
  • {{ commit }}: Hash for current HEAD commit
  • {{ topTreeHash }}: Git tree hash of the top directory
  • {{ treeHash }}: Git tree hash of the image directory (per image)
  • {{ top }}: Top directory path

Example

See the tests/docker/ directory for a complete example with test images and deployment updates.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

buildimage-1.3.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

buildimage-1.3.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file buildimage-1.3.0.tar.gz.

File metadata

  • Download URL: buildimage-1.3.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.22

File hashes

Hashes for buildimage-1.3.0.tar.gz
Algorithm Hash digest
SHA256 1b276c3432f2a413c0dd676b215ea22ef9b7a0fdd6746b523ae0634213d114c4
MD5 91c30d907e4d90b358231f9c4162ee3d
BLAKE2b-256 ae3677c9d3af047c03d72dac194397f0c4c83419b09ba595242b7d45f07adf60

See more details on using hashes here.

File details

Details for the file buildimage-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: buildimage-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.22

File hashes

Hashes for buildimage-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 42f30fc6b6884db4f70f0860722f4ee0e3b4c0810fa086def1b43cf5b2543216
MD5 21de8878152f6570137fdc1911d77ea5
BLAKE2b-256 edddfc92a4c04d4913489066906c86da9b853285363a923d76ce722e0121875d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page