MCPcopy Create free account
hub / github.com/devspace-sh/devspace / ImageBuildCLI

Method ImageBuildCLI

pkg/devspace/docker/cli.go:17–59  ·  view source on GitHub ↗

ImageBuildCLI builds an image with the docker cli

(ctx context.Context, workingDir string, environ expand.Environ, useBuildKit bool, context io.Reader, writer io.Writer, additionalArgs []string, options build.ImageBuildOptions, log log.Logger)

Source from the content-addressed store, hash-verified

15
16// ImageBuildCLI builds an image with the docker cli
17func (c *client) ImageBuildCLI(ctx context.Context, workingDir string, environ expand.Environ, useBuildKit bool, context io.Reader, writer io.Writer, additionalArgs []string, options build.ImageBuildOptions, log log.Logger) error {
18 args := []string{"build"}
19 if options.BuildArgs != nil {
20 for k, v := range options.BuildArgs {
21 if v == nil {
22 continue
23 }
24
25 args = append(args, "--build-arg", k+"="+*v)
26 }
27 }
28 if options.NetworkMode != "" {
29 args = append(args, "--network", options.NetworkMode)
30 }
31 for _, tag := range options.Tags {
32 args = append(args, "--tag", tag)
33 }
34
35 if options.Dockerfile != "" {
36 args = append(args, "--file", options.Dockerfile)
37 }
38 if options.Target != "" {
39 args = append(args, "--target", options.Target)
40 }
41
42 args = append(args, additionalArgs...)
43 args = append(args, "-")
44
45 log.Infof("Execute docker cli command with: docker %s", strings.Join(args, " "))
46
47 extraEnv := map[string]string{}
48 if useBuildKit {
49 extraEnv["DOCKER_BUILDKIT"] = "1"
50 }
51 if c.minikubeEnv != nil {
52 for k, v := range c.minikubeEnv {
53 extraEnv[k] = v
54 }
55 }
56
57 environ = env.NewVariableEnvProvider(environ, extraEnv)
58 return command.Command(ctx, workingDir, environ, writer, writer, context, "docker", args...)
59}

Callers

nothing calls this directly

Calls 2

NewVariableEnvProviderFunction · 0.92
InfofMethod · 0.45

Tested by

no test coverage detected