palantir / gradle-docker

a Gradle plugin for orchestrating docker builds and pushes.
Apache License 2.0
747 stars 158 forks source link

docker platform variable does not accept an array of String #747

Open peterzxu-crm opened 4 months ago

peterzxu-crm commented 4 months ago

What happened?

I want to use buildx to build cross platforms. I am seeing that there is a platform variable to specify. However, it does not work for me. If I specify

docker { platform ['linux/amd64'] }

The debug shows that it does not add --platform parameter at all.

But if I specify

docker { platform 'linux/amd64' }

it complains about

`

No signature of method: static com.google.common.collect.ImmutableSet.copyOf() is applicable for argument types: ([Ljava.lang.String;) values: [[linux/amd64]] Possible solutions: copyOf(java.lang.Iterable), of(), of([Ljava.lang.Object;), of(java.lang.Object), count(java.lang.Object), count(groovy.lang.Closure) `

What did you want to happen?

I expect that if I specify platform ['linux/amd64'], it should add to command line --platform linux/amd64

spatcho commented 3 weeks ago

Had same issue and did dig into plugin code. There is an undocumented param 'buildx' that need to be true for param like 'platform' to be considered. Then you could write like this :

docker { ... buildx true platform 'linux/amd64' ... }

A list of strings is supported, i.e. { platform 'linux/amd64','linux/arm64' }, but then :

ERROR: Multi-platform build is not supported for the docker driver. Switch to a different driver, or turn on the containerd image store, and try again. Learn more at https://docs.docker.com/go/build-multi-platform/

But that is docker related, not an issue with this plugin