@@ -32,10 +32,12 @@ import (
32
32
"os/exec"
33
33
"os/signal"
34
34
"path/filepath"
35
+ "runtime"
35
36
"strings"
36
37
"time"
37
38
"unicode"
38
39
40
+
39
41
"github.com/coreos/go-semver/semver"
40
42
"github.com/fatih/color"
41
43
"github.com/fnproject/cli/config"
@@ -67,6 +69,12 @@ var ShapeMap = map[string][]string{
67
69
modelsv2 .AppShapeGENERICX86ARM : {"linux/amd64" , "linux/arm64" },
68
70
}
69
71
72
+ var TargetPlatformMap = map [string ][] string {
73
+ modelsv2 .AppShapeGENERICX86 : {"amd64" },
74
+ modelsv2 .AppShapeGENERICARM : {"arm64" },
75
+ modelsv2 .AppShapeGENERICX86ARM : {"multiarch" },
76
+ }
77
+
70
78
func IsVerbose () bool {
71
79
return GlobalVerbose || CommandVerbose
72
80
}
@@ -513,6 +521,12 @@ func RunBuild(verbose bool, dir, imageName, dockerfile string, buildArgs []strin
513
521
var dockerBuildCmdArgs []string
514
522
// Depending whether architecture list is passed or not trigger docker buildx or docker build accordingly
515
523
var mappedArchitectures []string
524
+ var hostedPlatform = runtime .GOARCH
525
+ if targetPlatform , ok := TargetPlatformMap [shape ]; ok {
526
+ fmt .Printf ("hostedPlatform %v targetPlatform %v" , hostedPlatform , targetPlatform )
527
+ // compare target platform and hosted platform
528
+ // perform docker buildx if they don't match
529
+ }
516
530
if arch , ok := ShapeMap [shape ]; ok {
517
531
mappedArchitectures = append (mappedArchitectures , arch ... )
518
532
if containerEngineType == ContainerEngineType {
@@ -522,7 +536,6 @@ func RunBuild(verbose bool, dir, imageName, dockerfile string, buildArgs []strin
522
536
return
523
537
}
524
538
}
525
-
526
539
dockerBuildCmdArgs = buildXDockerCommand (imageName , dockerfile , buildArgs , noCache , mappedArchitectures )
527
540
// perform cleanup
528
541
defer cleanupContainerBuilder (containerEngineType )
0 commit comments