Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: allow setting buildkit outputs #1766

Merged
merged 1 commit into from
Mar 21, 2019
Merged

Conversation

tonistiigi
Copy link
Member

Introduce -o/--output to docker build allowing configuration of how the build output should be handled on buildkit mode.

Currently only supports local exporter.

-o type=local,dest=outpath
-o ./path/to/out - non csv value defaults to output path

Would be good to add tarball exporter as well before we ship this because local exporter can not preserve file uid/gid. Other exporters that are supported by buildkit need to wait for the containerd support to land in moby first.

@tiborvass @AkihiroSuda

Signed-off-by: Tonis Tiigi [email protected]

@codecov-io
Copy link

codecov-io commented Mar 21, 2019

Codecov Report

Merging #1766 into master will decrease coverage by 0.11%.
The diff coverage is 6.25%.

@@            Coverage Diff             @@
##           master    #1766      +/-   ##
==========================================
- Coverage   56.32%   56.21%   -0.12%     
==========================================
  Files         307      307              
  Lines       21177    21225      +48     
==========================================
+ Hits        11928    11931       +3     
- Misses       8382     8427      +45     
  Partials      867      867

if len(parts) != 2 {
return nil, errors.Errorf("invalid value %s", field)
}
key := strings.ToLower(parts[0])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thaJeztah doesn't like ToLower. He wants it strict.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too bad for @thaJeztah then

key := strings.ToLower(parts[0])

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, ToNIs, noT reAlLy a FaN of toLOWER heRE

Better keep it strict, and we can loosen up if we really would see a need

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I referred above is that everything else already is case insensitive. This includes csv for build secrets, swarm secrets, swarm config, mounts, network and ports. CSV in Dockerfile flags in daemon side is also case insensitive.

Btw, I'm not in favor of documenting it.

}
if len(fields) == 1 && fields[0] == s {
outs = append(outs, types.ImageBuildOutput{
Type: "local",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

off-topic: do we want to port over this default convention to buildctl?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildctl doesn't necessarily need to be the most user-friendly but expose all API capabilities. If this becomes common I see no reason not to do it. But I wouldn't want to go over the other flags(eg. cache import/export) of buildctl trying to find similar patterns atm.

if len(parts) != 2 {
return nil, errors.Errorf("invalid value %s", field)
}
key := strings.ToLower(parts[0])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, ToNIs, noT reAlLy a FaN of toLOWER heRE

Better keep it strict, and we can loosen up if we really would see a need

for _, field := range fields {
parts := strings.SplitN(field, "=", 2)
if len(parts) != 2 {
return nil, errors.Errorf("invalid value %s", field)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have (or will have) options that don't require a value? Otherwise we may defer this to the daemon, and use

cli/opts/parse.go

Lines 40 to 53 in 9e71207

// ConvertKVStringsToMap converts ["key=value"] to {"key":"value"}
func ConvertKVStringsToMap(values []string) map[string]string {
result := make(map[string]string, len(values))
for _, value := range values {
kv := strings.SplitN(value, "=", 2)
if len(kv) == 1 {
result[kv[0]] = ""
} else {
result[kv[0]] = kv[1]
}
}
return result
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API already accepts these values in a structured form and correctly formatted. We also need to parse out the values that are handled on the client side.

cli/command/image/build_buildkit.go Show resolved Hide resolved
@@ -176,6 +178,11 @@ func NewBuildCommand(dockerCli command.Cli) *cobra.Command {
flags.StringArrayVar(&options.ssh, "ssh", []string{}, "SSH agent socket or keys to expose to the build (only if BuildKit enabled) (format: default|<id>[=<socket>|<key>[,<key>]])")
flags.SetAnnotation("ssh", "version", []string{"1.39"})
flags.SetAnnotation("ssh", "buildkit", nil)

flags.StringArrayVarP(&options.outputs, "output", "o", []string{}, "Output destination (format: type=local,dest=path)")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did we decide on the shorthand -o option? (just to be sure; I'm cautious adding shorthands if other options may be added that also start with the same letter)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-o is a common convention in many other build tools for output. I think it would be weird to ever use it for anything else in docker build

@thaJeztah
Copy link
Member

@vdemeester @silvin-lubecki ptal

Copy link
Collaborator

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants