-
Notifications
You must be signed in to change notification settings - Fork 645
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
buildx cache-from / cache-to #1621
Comments
I'm not directly connected to the buildx implementation, but it sounds like a useful addition. @chonton maybe something that could be considered in the future ? Would this make sense ? |
Maybe. The problem is that you get one export location per build - either the local filesystem or the registry. If we build the base image into the local filesystem, we can then build the dependent image and push that into registry. However, the base image will not be available in the registry. So you have to introduce another build that basically is a FROM base image and pushes to registry. I wonder if a multi-stage build might work out. If the base stages are identical in the two dependents, then buildx is smart enough to use the cached layers. It is a build, but it is a fast build. I also wonder if the problem is a side effect of how the build/push mojos are working. The build mojo builds the native image into the cache, not into the registry. The push mojo builds both native platform (fast build due to cache) and non-native platforms and pushes all platforms to the registry. @owetterau Please comment on the docker cli commands you think would work for your use case. |
We would be interested in this feature. Our builds already leverage layered Jars for our Spring Boot services, but lack of support for From what I can see, it should be straightforward to pass the config from Maven mojo into buildX command line arguments: docker-maven-plugin/src/main/java/io/fabric8/maven/docker/service/BuildXService.java Lines 159 to 161 in 1b4dec5
Will maintainers accept the minimalist PR to pass the values through? |
@orange-buffalo : Do you think #1717 is related to this issue? Do you propose to pass already existing property |
Yes, this PR is related. It provides existing configuration option into buildX To me it sounds logical to include this configuration into <configuration>
<images>
<image>
<name>my-registry/my-image:${project.version}</name>
<build>
<buildx>
<!-- already supported properties -->
<builderName>my_name</builderName>
<platforms>
<platform>linux/amd64,linux/arm64</platform>
</platforms>
<!-- new properties -->
<cacheFrom>my-registry/my-image-cache:latest</cacheFrom>
<cacheTo>my-registry/my-image-cache:latest</cacheTo>
</buildx> And also add support to override them with system properties, like in the referenced PR: docker-maven-plugin/src/main/java/io/fabric8/maven/docker/config/ConfigHelper.java Lines 176 to 180 in 1b4dec5
|
@owetterau : Sounds good to me (however, I would prefer these properties as maven mojo parameters rather than system properties), Shall I assign this issue to you? |
Sure, let's do that. I expect to provide a PR during the next week or two. |
@orange-buffalo : Thanks a lot! |
Closes fabric8io#1621 Signed-off-by: Bogdan Ilchyshyn <[email protected]>
Closes #1621 Signed-off-by: Bogdan Ilchyshyn <[email protected]>
Having two |
Hello,
I am wondering how to set 'cache-from' and 'cache-to' when using buildx to build multi-platform images.
I have a maven project in which several Docker images are being built and some of them depend on each other. Unfortunately, when a depending Docker image is being built, Docker tries to download the base Docker image (as defined by 'FROM' in the Dockerfile) instead of reusing the already built one. This obviously fails.
I have already tested if using 'dockerStateDir' helps, but it did not work either.
Because of this I would like to use the 'cache-from' and 'cache-to' option of buildx but do not know how to do this with the docker-maven-plugin (and if it is possible at all).
Does anybody have an idea how to solve this issue?
Info
mvn -v
) : 3.8.1The text was updated successfully, but these errors were encountered: