bmuschko / gradle-docker-plugin

Gradle plugin for managing Docker images and containers.
https://bmuschko.github.io/gradle-docker-plugin/current/user-guide/
Apache License 2.0
1.23k stars 361 forks source link

Feature: buildx & cache-to #1186

Closed nbrugger-tgm closed 1 year ago

nbrugger-tgm commented 1 year ago

Expected Behaviour

When defining a task of the type DockerBuildImage i should be able to define a buildx docker build along the lines of:

buildx.set(true)

With this comes a new, not yet usable argument called cache-to which would be the output equivalent to the current cache-from.

Current Behaviour

to execute a buildx build a large setup of multiple tasks is needed and all the work from DockerBuildImage needs to be redone (gradle caching use for example). (using DockerOperation) with tasks such as: createDockerContainerBuilder, useDockerContainerBuilder, revertUsingDockerContainerBuilder and of course dockerxBuild

Context

This is needed to use remote caches with docker

bmuschko commented 1 year ago

Docker Java and more specifically the Docker remote API doesn't support buildx AFAIK. Please point me to the relevant method/API/documentation that explains how to use it if you think it is available.

nbrugger-tgm commented 1 year ago

As far as I was able to figure out there is an option in the api to use buildkit using grpc (see https://github.com/moby/moby/issues/41711 first comment)

That said "There is a Grpc endpoint" is... not a flawlessly documented api to say the least. So for buildx/buildkit to work with this plugin the following things would need to happen:

Right? This sounds like a "in the best case it just takes a very long time" thing and might not happen at all.

Docker for Java has no open ticket because all of them were closed as stale, but at least the ticket on docker/moby side is open althought there seems to be minor to no interest from both sides

bmuschko commented 1 year ago

OK, thanks for the info. It's a long shot. I'd try opening an issue for the Docker Java project first and see where it goes. Once supported there, we can think about integrating it into the plugin. Thanks! I am going to close the issue here for now. Comment here if the feature gets more traction.

sschuberth commented 9 months ago

OK, thanks for the info. It's a long shot. I'd try opening an issue for the Docker Java project

For reference: https://github.com/docker-java/docker-java/issues/1657