fabric8io / docker-maven-plugin

Maven plugin for running and creating Docker images
https://dmp.fabric8.io
Apache License 2.0
1.87k stars 640 forks source link

Multi-Arch support #1557

Open viragtripathi opened 2 years ago

viragtripathi commented 2 years ago

Description

I followed the multi-arch example with buildx but it seems like this is not released yet as the example shows a snapshot version of docker-maven-plugin. When will be the new version released with Multi-Arch build support? Thanks!

rohanKanojia commented 2 years ago

@viragtripathi : You can build 0.40-SNAPSHOT version locally to try it out.

I'll try to release 0.40.0 this weekend.

viragtripathi commented 2 years ago

Thanks @rohanKanojia

rohanKanojia commented 2 years ago

0.40.0 is out. Please try it out and provide us feedback.

https://repo1.maven.org/maven2/io/fabric8/docker-maven-plugin/0.40.0/

viragtripathi commented 2 years ago

Thanks @rohanKanojia. I just tried the latest build and ran into issue with Dockerfile. I think others are encountering the same issue with Dockerfile.

[INFO] DOCKER> error: failed to solve: failed to read dockerfile: open /tmp/buildkit-mount1310305077/Dockerfile: no such file or directory

viragtripathi commented 2 years ago

Hi @rohanKanojia I see the fix for this issue has already been committed. When would you release the next build?

viragtripathi commented 2 years ago

Hi @rohanKanojia Thanks for the latest build with the fix. I tried it and the project builds fine now with buildx configuration. I provided linux/amd64,linux/arm64 under buildx platform and I can see that generated DOCKER command has both but when I look up the manifest, it only shows amd64 as the os architecture. Am I missing something here?

asad-awadia commented 2 years ago

@viragtripathi same happening to me

did you figure out the issue?

mdgomes commented 1 year ago

Hello, there are two problems:

This last one is neither a plugin issue nor a buildx issue (see: https://github.com/docker/buildx/issues/59#issuecomment-1168619521), but instead a limitation of docker which is being tracked by this upstream issue: https://github.com/docker/roadmap/issues/371

chonton commented 1 year ago

Unfortunately, the local docker cache can only hold one image per name. So it makes sense to only build into the local repository the native image. Now a remote registry can hold multi-architecture indices (multiple platforms sharing the same name), so the push goal can build and push non-native images.

Yes, this is unexpected. But, this is the way docker buildx works.

martyvona commented 1 year ago

I understand that due to current limitations in docker it's not possible to build and load a multiarch image locally. However, shouldn't it be possible to build and load a single-architecture but still non-native image? I have a use-case where that would be handy. I'm on an M1 mac but need to build and test an amd64 image, preferably before I push it to a remote repository.

chonton commented 1 year ago

Sure, your use is valid, but not the usual case. I would willing to review a Pull Request that adds a buildx option that will load a non-native image to the local cache.

martyvona commented 1 year ago

@chonton #1665

mcharboub commented 3 months ago

any news about this ticket ?

nns15899 commented 2 months ago

Hello @chonton @viragtripathi I was facing the same problem with building my docker images for maven project. I added this in my pom, 0.44.0 this version supports multi-architecture platform support After that it built successfully.

<profiles>
    <profile>
        <id>build-image</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>io.fabric8</groupId>
                    <artifactId>docker-maven-plugin</artifactId>
                    <version>0.44.0</version>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>