compose-spec / compose-spec

The Compose specification
https://compose-spec.io
Apache License 2.0
2.25k stars 764 forks source link

And/or in `platform` field definition #197

Open ciaranmcnulty opened 3 years ago

ciaranmcnulty commented 3 years ago

The platform field definition contains the following

Compose implementation MUST use this attribute when declared to determine which version of the image will be pulled and/or on which platform the service’s build will be performed.

This use of and/or implies it's ok for a definition to use the platform for building only, or running only. I think this should be an and only

tonistiigi commented 3 years ago

I think this should be an and only

My recommendation is that if compose wants to define platform(s) to build it should add a new field under the build block and make it into an array. Runtime platform != build platform(s).

EricHripko commented 3 years ago

Thank you for sharing this feedback @ciaranmcnulty 👍 As @tonistiigi points out, runtime platform can be a subset of build platforms. For example, you may be building for arm and amd64 but only running only one of them at a time (arm locally and amd64 on Cloud).

That being said, it makes sense to me that the implementations would pick the runtime platform as the build platform if one is explicitly specified. Otherwise, platform attribute becomes severely lacking, as Compose implementations would build on native platform but attempt to run immediately after on the specified one.

What are your thoughts @ndeloof @hangyan @justincormack @ulyssessouza?

ndeloof commented 3 years ago

I agree build platform should be by default == runtime platform, but we should introduce a new platform attribute on build section to cover multi-platform builds, which would be very useful for build and push scenarios.

ciaranmcnulty commented 3 years ago

The linguistic thing is whether the current wording reflects the current intention.

I'd suggest changing it to AND if the intention was for the flag to be used for both build (in a build platform) and run (in a run platform).

My personal issue is that the build platform I'm using is bake but the runner is compose and the mis-match is confusing.

I'm fully behind a build.platforms key in future, reflecting how bake has implemented build.x-bake.platforms 👍

ndeloof commented 3 years ago

I didn't know about the x-bake extension(s). @tonistiigi could you please make a formal proposal for this on the spec? Extensions are a nice way to experiment things on compose-related tooling, but the final goal is to serve as "proof of concept" before those get adopted in the spec.

EricHripko commented 3 years ago

Seems like there's a broad agreement on this 🎉 For the short-term, it makes sense to me that we replace and/or with and in the spec for clarity.