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:
- Build release notes | Docker Docs: https://docs.docker.com/build/release-notes
- Getting Started · Cloud Native Buildpacks: https://buildpacks.io/docs/getting-started
- Introducing kustomize; Template-free Configuration Customization for Kubernetes | Kubernetes: https://kubernetes.io/blog/2018/05/29/introducing-kustomize-template-free-configuration-customization-for-kubernetes
- pack builder create · Cloud Native Buildpacks: https://buildpacks.io/docs/tools/pack/cli/pack_builder_create
- Environment variables for Docker Build | Docker Docs: https://docs.docker.com/build/building/env-vars
- Announcing the Backstage Search platform: a customizable search tool built just for you | Backstage Software Catalog and Developer Platform: https://backstage.io/blog/2021/06/24/announcing-backstage-search-platform
- Builder · Cloud Native Buildpacks: https://buildpacks.io/docs/concepts/components/builder
- Technology and tool builders - Docs: https://devfile.io/docs/2.0.0/technology-and-tool-builders
- Getting started with the Orx open gaming engine | Opensource.com: https://opensource.com/article/17/5/getting-started-orx-open-gaming-engine
- An introduction to Red Hat Trusted Application Pipeline | Red Hat Developer: https://developers.redhat.com/articles/2023/07/18/introduction-red-hat-trusted-application-pipeline
- One post tagged with “extensibility” | KubeVela: https://kubevela.io/blog/tags/extensibility
- Daniel Helfand | Red Hat Developer: https://developers.redhat.com/author/daniel-helfand
- Capturing Build Information with BuildKit | Docker: https://www.docker.com/blog/capturing-build-information-buildkit
- How I containerize a build system | Opensource.com: https://opensource.com/article/20/4/how-containerize-build-system