Customization and Extensibility - docker/buildx

Customization and Extensibility for buildx project (Golang Module name: “github.com/docker/buildx”) can be achieved using plugins and other mechanisms. Here are some possible options with examples:

Customizing your Buildpacks Build

You can customize your buildpacks build using the pack command-line tool. The pack builder create command allows you to specify a builder TOML file, which defines the build image, lifecycle, buildpacks, and run image. Here’s an example:

$ pack builder create --config my-builder.toml

The builder TOML file may look like this:

[build]
image = "my-build-image"
lifecycle = "my-lifecycle"
buildpacks = ["my-buildpack1", "my-buildpack2"]
run-image = "my-run-image"

You can also flatten each composite buildpack into a single layer or exclude certain buildpacks from flattening.

Environment Variables for Docker Build

buildx supports several environment variables that can be used to customize the build process. For example, you can configure text color for the terminal output using the BUILDKIT_COLORS variable, specify the builder instance to use with the BUILDX_BUILDER variable, or enable experimental features with the BUILDX_EXPERIMENTAL variable.

Here’s an example:

$ BUILDKIT_COLORS=always BUILDX_BUILDER=my-builder buildx build --progress plain my-app

Customizing Search Results in Backstage

Backstage allows you to customize the display of search results using custom result list item components. For example, you can create a TechDocsResultListItem component that displays the text content as the most important information for results returned from the TechDocs plugin.

Here’s an example:

import React from 'react';
import { ResultListItem } from '@backstage/core-components';

export const TechDocsResultListItem = ({ result }) => (
<ResultListItem
title={result.title}
description={result.description}
action={result.action}
icon={result.icon}
metadata={
<div>
<p>{result.textContent}</p>
</div>
}
/>
);

Creating a Custom Builder Image on Red Hat OpenShift

You can create a custom builder image on Red Hat OpenShift using a container image that supports a particular language or framework. This can be done using the Source-to-Image (S2I) builder, which allows you to create a new container image that includes your application and its dependencies.

Here’s an example:

$ oc new-build --name my-app --binary --strategy source=docker
$ oc start-build my-app --from-dir=.

Capturing Build Information with BuildKit

buildx supports capturing build information using BuildKit, which allows you to generate a software bill of materials (SBOM) for your application. This can be done using the --sbom flag with the buildx build command.

Here’s an example:

$ buildx build --sbom my-app

Customizing your Devfile

You can customize your devfile using the kubectl command-line tool. The kubectl apply command allows you to apply a devfile configuration file, which defines the build image, lifecycle, buildpacks, and run image. Here’s an example:

$ kubectl apply -f my-devfile.yaml

The devfile configuration file may look like this:

apiVersion: 1.0.0
kind: Devfile
metadata:
name: my-devfile
spec:
projects:
- name: my-project
source:
type: git
url: https://github.com/my-user/my-project.git
build:
type: buildpack
builder: my-builder
buildpacks:
- id: my-buildpack1
version: 1.0.0
- id: my-buildpack2
version: 2.0.0
run:
type: container
image: my-run-image

Sources: