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.2.0.tar.gz (8.1 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.2.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for buildimage-1.2.0.tar.gz
Algorithm Hash digest
SHA256 b6b27faa5b40d3469acc5d8329ea65152c3568839cd137575809606b218948f8
MD5 d4ddb4cfa13a6f5a5828edccb4ee732c
BLAKE2b-256 1e4c14cfc39d3c6dcd763fd47922762eafa4c01185b92acc9cfa71cdddc34e8d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: buildimage-1.2.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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ef59829cf87294c2d8315b8a3b44ef4cae86869ed65aa19601155692ff30e3b
MD5 0a2b9dd7aad93873c0b187f0e7eb2607
BLAKE2b-256 c45a8596792212151ce8cca9515a629cae38bc28f395caa88d0bdae9ebbd88e7

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