mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-10-31 08:03:43 +08:00 
			
		
		
		
	| @@ -37,6 +37,7 @@ type Options struct { | |||||||
| 	Pull        bool | 	Pull        bool | ||||||
| 	ImageIDFile string | 	ImageIDFile string | ||||||
| 	ExtraHosts  []string | 	ExtraHosts  []string | ||||||
|  | 	NetworkMode string | ||||||
|  |  | ||||||
| 	NoCache   bool | 	NoCache   bool | ||||||
| 	Target    string | 	Target    string | ||||||
| @@ -228,6 +229,14 @@ func Build(ctx context.Context, drivers []DriverInfo, opt map[string]Options, pw | |||||||
| 			so.FrontendAttrs["platform"] = strings.Join(pp, ",") | 			so.FrontendAttrs["platform"] = strings.Join(pp, ",") | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		switch opt.NetworkMode { | ||||||
|  | 		case "host", "none": | ||||||
|  | 			so.FrontendAttrs["force-network-mode"] = opt.NetworkMode | ||||||
|  | 		case "", "default": | ||||||
|  | 		default: | ||||||
|  | 			return nil, errors.Errorf("network mode %q not supported by buildkit", opt.NetworkMode) | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		extraHosts, err := toBuildkitExtraHosts(opt.ExtraHosts) | 		extraHosts, err := toBuildkitExtraHosts(opt.ExtraHosts) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return nil, err | 			return nil, err | ||||||
|   | |||||||
| @@ -32,11 +32,11 @@ type buildOptions struct { | |||||||
| 	outputs     []string | 	outputs     []string | ||||||
| 	imageIDFile string | 	imageIDFile string | ||||||
| 	extraHosts  []string | 	extraHosts  []string | ||||||
|  | 	networkMode string | ||||||
|  |  | ||||||
| 	// unimplemented | 	// unimplemented | ||||||
| 	squash bool | 	squash bool | ||||||
| 	quiet  bool | 	quiet  bool | ||||||
| 	networkMode string |  | ||||||
|  |  | ||||||
| 	// hidden | 	// hidden | ||||||
| 	// untrusted   bool | 	// untrusted   bool | ||||||
| @@ -68,9 +68,6 @@ func runBuild(dockerCli command.Cli, in buildOptions) error { | |||||||
| 	if in.quiet { | 	if in.quiet { | ||||||
| 		return errors.Errorf("quiet currently not implemented") | 		return errors.Errorf("quiet currently not implemented") | ||||||
| 	} | 	} | ||||||
| 	if in.networkMode != "default" { |  | ||||||
| 		return errors.Errorf("network currently not implemented") |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	ctx := appcontext.Context() | 	ctx := appcontext.Context() | ||||||
|  |  | ||||||
| @@ -88,6 +85,7 @@ func runBuild(dockerCli command.Cli, in buildOptions) error { | |||||||
| 		Target:      in.target, | 		Target:      in.target, | ||||||
| 		ImageIDFile: in.imageIDFile, | 		ImageIDFile: in.imageIDFile, | ||||||
| 		ExtraHosts:  in.extraHosts, | 		ExtraHosts:  in.extraHosts, | ||||||
|  | 		NetworkMode: in.networkMode, | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	platforms, err := build.ParsePlatformSpecs(in.platforms) | 	platforms, err := build.ParsePlatformSpecs(in.platforms) | ||||||
| @@ -166,7 +164,6 @@ func buildCmd(dockerCli command.Cli) *cobra.Command { | |||||||
| 	flags.StringVar(&options.imageIDFile, "iidfile", "", "Write the image ID to the file") | 	flags.StringVar(&options.imageIDFile, "iidfile", "", "Write the image ID to the file") | ||||||
| 	flags.BoolVar(&options.squash, "squash", false, "Squash newly built layers into a single new layer") | 	flags.BoolVar(&options.squash, "squash", false, "Squash newly built layers into a single new layer") | ||||||
| 	flags.MarkHidden("quiet") | 	flags.MarkHidden("quiet") | ||||||
| 	flags.MarkHidden("network") |  | ||||||
| 	flags.MarkHidden("squash") | 	flags.MarkHidden("squash") | ||||||
|  |  | ||||||
| 	// hidden flags | 	// hidden flags | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Tibor Vass
					Tibor Vass