BuildKit/ buildctl is a toolkit that allows you to easily build multiarchitecture images.
To configure BuildKit to work with Artifactory:
Login using the following Docker command:
Note
Make sure to replace the placeholder in bold with your own JFrog host domain.
docker login <YOUR_JFROG_DOMAIN>
For example:
docker login my-awesome.jfrog.io
Run your container locally using the following command:
Note
Make sure to replace the placeholders in bold with your own container and image.
docker run --rm --privileged -d --name <CONTAINER> moby/buildkit
For example:
docker run --rm --privileged -d --name mybuildkit moby/buildkit
Push OCI Resources Using BuildKit
To push and tag your images from the running container, use the following command:
Note
Make sure to replace the placeholders in bold with your own architectures, JFrog host domain, desired repository path, image, and tag.
buildctl build \ --frontend=dockerfile.v0 \ --local context=. \ --local dockerfile=. \ --output type=image,name=<YOUR_JFROG_DOMAIN>/<REPOSITORY>/<IMAGE>:<TAG>,push=true \ --export-cache type=registry,ref=<YOUR_JFROG_DOMAIN>/<REPOSITORY>/<IMAGE>:<TAG>,mode=max,push=true \ --import-cache type=registry,ref=<YOUR_JFROG_DOMAIN>/<REPOSITORY>/<IMAGE>:<TAG>
For example:
buildctl build \ --frontend=dockerfile.v0 \ --local context=. \ --local dockerfile=. \ --output type=image,name=my-awesome.jfrog.io/myproject-oci-remote/myociimage:latest,push=true \ --export-cache type=registry,ref=my-awesome.jfrog.io/myproject-oci-remote/myociimage:latest,mode=max,push=true \ --import-cache type=registry,ref=my-awesome.jfrog.io/myproject-oci-remote/myociimage:latest