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)
  • {{login}}: Currently logged in used performing build
  • {{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.4.0.tar.gz (8.4 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.4.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for buildimage-1.4.0.tar.gz
Algorithm Hash digest
SHA256 d711a6c4038b2a0348ba860409429203c8b210cbe441fc49168d37f867a1237f
MD5 1d1ff35df73c6fa0b93f499501f40bae
BLAKE2b-256 0344625ed26d71afe0d62c5347d13ace188fbc6e42d9dda64ccb964dd62bae4b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for buildimage-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 00cf8646a92169b2cd5382f3af9185ee9054fff363089e2d35613d7423794f00
MD5 24ff10f5c685d7d3eefed4f7338bc37a
BLAKE2b-256 482269e5bd22d89601a1b0c3e3c0e44567ab262aa39f3baef8e093ab577225d7

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