Skip to content
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

Add support for CPU variants #1676

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Expand Up @@ -588,7 +588,12 @@ and you want to build one of its subfolders instead of the root folder.
#### --customPlatform

Allows to build with another default platform than the host, similarly to docker build --platform xxx
the value has to be on the form `--customPlatform=linux/arm` , with acceptable values listed here: [GOOS/GOARCH](https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63)
the value has to be on the form `--customPlatform=linux/arm`, with acceptable values listed here: [GOOS/GOARCH](https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63).

It's also possible specifying CPU variants adding it as a third parameter (like `--customPlatform=linux/arm/v5`).
Currently CPU variants are only known to be used for the ARM architecture as listed here: [GOARM](https://github.com/golang/go/wiki/GoArm#supported-architectures)

_The resulting images cannot provide any metadata about CPU variant due to a limitation of the OCI-image specification._

_This is not virtualization and cannot help to build an architecture not natively supported by the build host. This is used to build i386 on an amd64 Host for example, or arm32 on an arm64 host._

Expand Down
12 changes: 9 additions & 3 deletions pkg/image/remote/remote.go
Expand Up @@ -138,10 +138,16 @@ func remoteOptions(registryName string, opts config.RegistryOptions, customPlatf
// CurrentPlatform returns the v1.Platform on which the code runs
func currentPlatform(customPlatform string) v1.Platform {
if customPlatform != "" {
return v1.Platform{
OS: strings.Split(customPlatform, "/")[0],
Architecture: strings.Split(customPlatform, "/")[1],
customPlatformArray := strings.Split(customPlatform, "/")
imagePlatform := v1.Platform{}
imagePlatform.OS = customPlatformArray[0]
if len(customPlatformArray) > 1 {
imagePlatform.Architecture = customPlatformArray[1]
if len(customPlatformArray) > 2 {
imagePlatform.Variant = customPlatformArray[2]
}
}
return imagePlatform
}
return v1.Platform{
OS: runtime.GOOS,
Expand Down