Docker buildx is a CLI plugin that extends the docker command and enables the creation of multi-architecture Docker images.
The process of adding the build-info to an image build with buildx is the same as adding it to a regular docker image, however, some users may have difficulty exporting the built buildx image to the local docker images via the docker client. Therefore, we will use the JFrog CLI to add the build-info to an existing docker image that was already pushed to Artifactory.
The following command is an example of the docker buildx build command which was used to create a multi-architecture image from a simple Dockerfile. In this case, the image supports the linux/amd64 and linux/arm64 architectures:
docker buildx build --file Dockerfile --platform linux/amd64,linux/arm64 --tag <Artifactory_host>/workshop-docker/tdp/multi-arch-test:1.1.1-rc.1 --output=type=image --push .
After a successful docker push, the images pushed to Artifactory can be viewed under the created path workshop-docker-local/tdp/multi-arch-test:
Now, in order to attach the build-info to an image that was already pushed to Artifactory, we will use the JFrog CLI build docker create command. This command allows adding a docker image, which is already published to Artifactory, into the build-info. The command uses mandatory fields, which are the repository name and the --image-file flag. The --image-file will be the path to a file that includes one line in the following format:
IMAGE-TAG@sha256:MANIFEST-SHA256
For this example, we will use the following content to add the 1.1.1-rc.1 image into the build-info:
$ cat image-file-details
<Artifactory_host>/workshop-docker/tdp/multi-arch-test:1.1.1-rc.1@sha256:08f48947b09fdfdee641f49129cf0e528703f2e63b0afba231dd0324a3f53cb0
The jfrog rt bdc command is as follows:
jfrog rt bdc workshop-docker-local --image-file image-file-details --build-name $build-name --build-number $build-number
Next, we will publish the build-info to Artifactory using the build-publish command:
jfrog rt bp myBuild 2
After publishing the build-info, we will be able to see it under the ‘Builds’ section as well as under the artifactory-build-info repository:
Note: As the association of the list.manifest.json to the build-info using the jfrog rt bdc command is currently unsupported, the bdc command should be executed on each manifest.json file, meaning, on every tag.