()
| 40 | const buildUsageLongHelp = `Build an image from a Dockerfile` |
| 41 | |
| 42 | func newBuildCommand() *cobra.Command { |
| 43 | |
| 44 | build := &buildCommand{ |
| 45 | tags: newListValue().WithValidator(validateTag), |
| 46 | buildArgs: newListValue(), |
| 47 | labels: newListValue(), |
| 48 | platforms: newListValue(), |
| 49 | cacheFrom: newListValue(), |
| 50 | cacheTo: newListValue(), |
| 51 | } |
| 52 | |
| 53 | cmd := &cobra.Command{ |
| 54 | Use: "build [OPTIONS] PATH", |
| 55 | DisableFlagsInUseLine: true, |
| 56 | SilenceUsage: true, |
| 57 | Short: buildUsageShortHelp, |
| 58 | Long: buildUsageLongHelp, |
| 59 | Args: build.ValidateArgs, |
| 60 | RunE: func(cmd *cobra.Command, args []string) error { |
| 61 | return build.Run(args) |
| 62 | }, |
| 63 | } |
| 64 | |
| 65 | fs := cmd.Flags() |
| 66 | |
| 67 | fs.StringVarP(&build.dockerfilePath, "file", "f", "", "Name of the Dockerfile (Default is 'PATH/Dockerfile')") |
| 68 | fs.VarP(build.tags, "tag", "t", "Name and optionally a tag in the 'name:tag' format") |
| 69 | fs.StringVar(&build.target, "target", "", "Set the target build stage to build") |
| 70 | fs.Var(build.platforms, "platform", "Set platforms for which the image should be built") |
| 71 | fs.Var(build.buildArgs, "build-arg", "Set build-time variables") |
| 72 | fs.Var(build.labels, "label", "Set metadata for an image") |
| 73 | fs.BoolVar(&build.noConsole, "no-console", false, "Use non-console progress UI") |
| 74 | fs.BoolVar(&build.noCache, "no-cache", false, "Do not use cache when building the image") |
| 75 | fs.StringVarP(&build.output, "output", "o", "", "BuildKit output specification (e.g. type=tar,dest=build.tar)") |
| 76 | fs.Var(build.cacheFrom, "cache-from", "Buildkit import-cache or Buildx cache-from specification") |
| 77 | fs.Var(build.cacheTo, "cache-to", "Buildx cache-to specification") |
| 78 | return cmd |
| 79 | } |
| 80 | |
| 81 | type buildCommand struct { |
| 82 | buildArgs *listValue |
no test coverage detected
searching dependent graphs…