buildx icon indicating copy to clipboard operation
buildx copied to clipboard

Can you split up the build and push steps?

Open MauriceNino opened this issue 2 years ago • 16 comments

Related to #166

I want to first build the image, then do some other release steps and then release the image to docker hub. For that, I thought I should use -o type=image,name=xxx. But when I run docker manifest inspect xxx after that, it just returns the latest manifest from docker hub.

Where is the built manifest, and how can I push it after the build?

I am building for --platform linux/amd64,linux/arm/v7,linux/arm64/v8 if that is important.

MauriceNino avatar Jun 07 '22 12:06 MauriceNino

To push from buildx you would run the build again with push option. If you have image in docker then you do docker push. If you have exported image in some other way(local registry, oci tarball) then there are external programs that can push from one registry to another etc.

tonistiigi avatar Jun 09 '22 05:06 tonistiigi

Thank you for your answer! Why is there no option to create the manifest and save it locally, so that it can later be picked up again? Or is that something that is technically not possible?

MauriceNino avatar Jun 09 '22 09:06 MauriceNino

@tonistiigi What is the best output format and external program for outputting a multi-platform image and later pushing it to docker hub? As far as I read there are still problems with pushing OCI images to docker hub: https://github.com/docker/hub-feedback/issues/1871

Building again with --cache-from and --push isn't very great because I'm using a multi-stage build, and only the first stage hits the cache.

jedwards1211 avatar Jul 06 '22 18:07 jedwards1211

Thank you for your answer! Why is there no option to create the manifest and save it locally, so that it can later be picked up again? Or is that something that is technically not possible?

@MauriceNino Hello, Have you received any answers to this question? I want the build and the push to be separated, too. Is there another way without using the --push option?

ssosso avatar Mar 23 '23 10:03 ssosso

Also interested. GitHub repository often returns errors, and I'll be interested in separating the build and push to be able to backoff retry the push step.

clemlesne avatar May 19 '23 12:05 clemlesne

Yeah, this becoming a necessity. There should be a method to build a multi arch image, and then push at a later time. I agree with @MauriceNino this is needed for additional CI processes.

rsavage-nozominetworks avatar Jun 23 '23 20:06 rsavage-nozominetworks

Another reason for the separation is that I would like to run those steps in parallel:

  • terraform apply that also creates the ECR repository,
  • in the meantime I want to start the docker build.

When the terraform apply has finished I can push the image to the newly created repository.

Oliniusz avatar Sep 29 '23 20:09 Oliniusz

@tonistiigi

To push from buildx you would run the build again with push option....

I would be concerned if I build again that it would be possible for something pulled in to do the build again would have changed in the interim. It's unlikely if the interim is short, but not impossible.

leemeador avatar Oct 27 '23 22:10 leemeador

Hello, I'm also intéressée on this topic. I want to build, then test and then push. Any workaround on that ?

jandry avatar Oct 28 '23 08:10 jandry

@tonistiigi

To push from buildx you would run the build again with push option....

I would be concerned if I build again that it would be possible for something pulled in to do the build again would have changed in the interim. It's unlikely if the interim is short, but not impossible.

If you have already ran the build previously and nothing has changed, then building with the --push flag will use the cached build (unless you add the --pull flag, which will attempt to pull any referenced external images)

mixja avatar Oct 30 '23 05:10 mixja

This issue is related to my discussion about running targets sequentially: https://github.com/docker/buildx/discussions/1976

sprat avatar Nov 10 '23 12:11 sprat

Also interested, in any pipeline we need security tests after build and before any push to external registry. Any help so far ?

sgasquet avatar Dec 04 '23 13:12 sgasquet

bump

lodotek avatar Mar 18 '24 19:03 lodotek

bump

th3wingman avatar Apr 07 '24 21:04 th3wingman

Bump

flowconic avatar May 16 '24 09:05 flowconic