Add experimental way to set a target platform when building
Add an --experimental-platform flag to the do command to allow overriding the default auto-detected build platform until we find the time to think about the definitive multi-platform builds UX Signed-off-by: Marcos Lilljedahl <marcosnils@gmail.com>
This commit is contained in:
@@ -6,7 +6,9 @@ import (
|
||||
"strings"
|
||||
|
||||
"cuelang.org/go/cue"
|
||||
"github.com/containerd/containerd/platforms"
|
||||
"github.com/docker/buildx/util/buildflags"
|
||||
specs "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/viper"
|
||||
"go.dagger.io/dagger/client"
|
||||
@@ -95,10 +97,21 @@ func NewClient(ctx context.Context) *client.Client {
|
||||
lg.Fatal().Err(err).Msg("unable to parse --cache-from options")
|
||||
}
|
||||
|
||||
ep := viper.GetString("experimental-platform")
|
||||
var p *specs.Platform
|
||||
if len(ep) > 0 {
|
||||
pp, err := platforms.Parse(ep)
|
||||
if err != nil {
|
||||
lg.Fatal().Err(err).Msg("invalid value for --experimental-platform")
|
||||
}
|
||||
p = &pp
|
||||
}
|
||||
|
||||
cl, err := client.New(ctx, "", client.Config{
|
||||
CacheExports: cacheExports,
|
||||
CacheImports: cacheImports,
|
||||
NoCache: viper.GetBool("no-cache"),
|
||||
CacheExports: cacheExports,
|
||||
CacheImports: cacheImports,
|
||||
NoCache: viper.GetBool("no-cache"),
|
||||
TargetPlatform: p,
|
||||
})
|
||||
if err != nil {
|
||||
lg.Fatal().Err(err).Msg("unable to create client")
|
||||
|
@@ -157,6 +157,7 @@ func init() {
|
||||
doCmd.Flags().StringArrayP("with", "w", []string{}, "")
|
||||
doCmd.Flags().StringP("plan", "p", ".", "Path to plan (defaults to current directory)")
|
||||
doCmd.Flags().Bool("no-cache", false, "Disable caching")
|
||||
doCmd.Flags().String("experimental-platform", "", "Set target build platform (experimental)")
|
||||
doCmd.Flags().StringArray("cache-to", []string{},
|
||||
"Cache export destinations (eg. user/app:cache, type=local,dest=path/to/dir)")
|
||||
doCmd.Flags().StringArray("cache-from", []string{},
|
||||
|
Reference in New Issue
Block a user