jfrog / jfrog-cli

JFrog CLI is a client that provides a simple interface that automates access to the JFrog products.
https://www.jfrog.com/confluence/display/CLI/JFrog+CLI
Apache License 2.0
536 stars 235 forks source link

Support multi-architecture images with build-docker-create #1877

Open chonton opened 1 year ago

chonton commented 1 year ago

Is your feature request related to a problem? Please describe. Build and push multi-architecture images using buildx and add resulting artifacts to an artifactory build

Describe the solution you'd like to see build-docker-create will support both traditional and multi-architecture images:

jf rt build-docker-create --server-id=<serverId> --build-name <buildName> --build-number <buildNumber> --project <project> <target-repo> <imageNameAndVersion>

e.g. Using environment variables for serverId, buildName, buildNumber, and project jf rt bdc temp-docker-local repo.mycorp.net/temp-docker-local/org/project:2.3.1

Describe alternatives you've considered Current build-docker-create command with --image-file. Unfortunately, a lot of work for the CI build system to hunt down the required arguments and does not support multi-image.

Additional context Current --image-file option is inconvenient to use. Also, it is not necessary to provide the digest to find the layers for a traditional image. You cannot specify a digest to find a multi-architecture index.

nshavitt commented 1 year ago

Can anyone please provide a detailed example of using this command? the --image-file is not clear, whatever used I get an error "no such file or directory". thanks

ciphero commented 8 months ago

Can anyone please provide a detailed example of using this command? the --image-file is not clear, whatever used I get an error "no such file or directory". thanks

Yeah, it's an extremely silly implementation. This should all be automated and collected properly when using the JFrog CLI tool and while wrapped as a step in Jenkins for ex.

What I'm doing is when you build the image using docker buildx you add --metadata-file to the docker buildx command to output the build metadata to a physical .json file. e.g. docker buildx build --metadata-file image-metadata.json ...

Then when you run the JFrog BuildInfo step (build-docker-create, or bdc for short) you need to convert this .json data to a format that JFrog CLI requires, i.e. <IMAGE-TAG>@sha256:<MANIFEST-SHA256> e.g. jq -r '.["image.name"] + "@" + .["containerimage.digest"]' image-metadata.json > jfrog-image-metadata then you run the JFrog CLI bdc command: jf rt build-docker-create <docker_repo> --image-file jfrog-image-metadata and finally you push this to Artifactory jf rt build-publish

If you're on a CI system like Jenkins you probably should add --build-name and --build-number variables to the commands as well (should also be implicitly set).