Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support multiple exporters for build #1555

Closed
tonistiigi opened this issue Jul 2, 2020 · 8 comments
Closed

support multiple exporters for build #1555

tonistiigi opened this issue Jul 2, 2020 · 8 comments

Comments

@tonistiigi
Copy link
Member

Eg. allow pushing and loading to local tarball with the same request.

moved from docker/buildx#316

@fahedouch
Copy link
Contributor

hello @tonistiigi

I am looking on this and ready to help. Can you orient me please: I don't understand why you moved the issue to buildkit. I saw that the logic is bloqued by this return : https://github.com/docker/buildx/blob/f3111bcbef8ce7e3933711358419fa18294b3daf/build/build.go#L356

thank you again

@tonistiigi
Copy link
Member Author

@fahedouch The problem is that if you would remove this return in buildx it would just fail in the next lines because buildkit doesn't support this case yet. Eg. https://github.com/moby/buildkit/blob/master/client/solve.go#L119 and then the field currently used by API doesn't even take an array https://github.com/moby/buildkit/blob/master/client/solve.go#L204 .

@adminy
Copy link

adminy commented Aug 1, 2022

any updates on this?

@AlonMiz
Copy link

AlonMiz commented Sep 6, 2022

is there any workaround?
what about a command of tag and push like we had with docker?

in our case, what's happening is that when we wanted to push to another tag/output,
we have to use bake/build so that it will push to another output. but then, something invalidates the cache and some steps are being rebuilt. as a result, a push phase can take as much time as the build.

@adminy
Copy link

adminy commented Sep 6, 2022

Nothing invalidates the cache for me so its really quick to export, I've created another step where I split into two more containers, one for export and one for interactive docker to use. That's the workaround.

Now in my docker file I have two extra lines like this:

FROM scratch AS file_to_export
COPY --from=os_img /file/to/export /

Then I just have the docker builds with the necessary outputs needed:

# --output=type=docker   -> interactive use, mostly to be able to use "docker run" command
# --output=type=registry -> a place where the image can be cached so that we can load it
# --output=type=local,dest=output -> save the entire docker image/file from docker to disk

and of course I tag the images differently too, and I use os_img with the docker export and the new file_to_export as the local file output.

@bityob
Copy link

bityob commented Oct 2, 2022

@adminy
Please share the script you use and specify the output types.
I don't understand what is your workaround exactly.
Thanks

@adminy
Copy link

adminy commented Oct 9, 2022

run: build
        # Interactive container
	docker buildx build $(FLAGS) --target silly_name_run --tag some_tag --output=type=docker --cache-from=type=registry,ref=$(PREFIX):build .
	docker run --privileged -p 8080:8080 -it some_tag /bin/bash
img: build
        # Output container
	docker buildx build $(FLAGS) --target silly_name_export -o type=local,dest=output --cache-from=type=registry,ref=$(PREFIX):build .
build: some other prequisites
        docker buildx build $(FLAGS) --target silly_build_$@ --output=type=registry --tag $(PREFIX):$@ --cache-from=type=registry,ref=$(PREFIX):$@ --cache-to=type=registry,ref=$(PREFIX):$@,mode=max .

nkuba added a commit to keep-network/keep-core that referenced this issue May 24, 2023
Since build-push-action doesn't support outputing an image to multiple outputs
we need to save it in a separate step. See: moby/buildkit#1555
Once multiple outputs are supported we can replace this step with
`outputs` property configured in `Build Docker Build Image`:
  outputs: |
    type=image
    type=docker,dest=/tmp/go-build-env-image.tar
samip5 added a commit to skyssolutions/containers that referenced this issue Dec 7, 2023
@tonistiigi
Copy link
Member Author

#4134

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants