Add image optimization policy API to builds
Allows users to opt into faster builds.
@@ -481,6 +481,27 @@ type CustomBuildStrategy struct {
BuildAPIVersion string `json:"buildAPIVersion,omitempty" protobuf:"bytes,7,opt,name=buildAPIVersion"`
}
+// ImageOptimizationPolicy describes what optimizations the builder can perform when building images.
+type ImageOptimizationPolicy string
+
+const (
+ // ImageOptimizationNone will generate a canonical Docker image as produced by the
+ // `docker build` command.
+ ImageOptimizationNone ImageOptimizationPolicy = "None"
+
+ // ImageOptimizationSkipLayers is an experimental policy and will avoid creating
+ // unique layers for each dockerfile line, resulting in smaller images and saving time
+ // during creation. Some Dockerfile syntax is not fully supported - content added to
+ // a VOLUME by an earlier layer may have incorrect uid, gid, and filesystem permissions.
+ // If an unsupported setting is detected, the build will fail.
+ ImageOptimizationSkipLayers ImageOptimizationPolicy = "SkipLayers"
+
+ // ImageOptimizationSkipLayersAndWarn is the same as SkipLayers, but will only
+ // warn to the build output instead of failing when unsupported syntax is detected. This
+ // policy is experimental.
+ ImageOptimizationSkipLayersAndWarn ImageOptimizationPolicy = "SkipLayersAndWarn"
+)
+
// DockerBuildStrategy defines input parameters specific to Docker build.
type DockerBuildStrategy struct {
// from is reference to an DockerImage, ImageStreamTag, or ImageStreamImage from which
@@ -508,9 +529,18 @@ type DockerBuildStrategy struct {
// relative to the root of the context (contextDir).
DockerfilePath string `json:"dockerfilePath,omitempty" protobuf:"bytes,6,opt,name=dockerfilePath"`
- // Args contains any build arguments that are to be passed to Docker. See
- // https://docs.docker.com/engine/reference/builder/#/arg for more details
+ // buildArgs contains build arguments that will be resolved in the Dockerfile. See
+ // https://docs.docker.com/engine/reference/builder/#/arg for more details.
BuildArgs []kapi.EnvVar `json:"buildArgs,omitempty" protobuf:"bytes,7,rep,name=buildArgs"`
+
+ // imageOptimizationPolicy describes what optimizations the system can use when building images
+ // to reduce the final size or time spent building the image. The default policy is 'None' which
+ // means the final build image will be equivalent to an image created by the Docker build API.
+ // The experimental policy 'SkipLayers' will avoid commiting new layers in between each
+ // image step, and will fail if the Dockerfile cannot provide compatibility with the 'None'
+ // policy. An additional experimental policy 'SkipLayersAndWarn' is the same as
+ // 'SkipLayers' but simply warns if compatibility cannot be preserved.
+ ImageOptimizationPolicy *ImageOptimizationPolicy `json:"imageOptimizationPolicy,omitempty" protobuf:"bytes,8,opt,name=imageOptimizationPolicy,casttype=ImageOptimizationPolicy"`
}
// SourceBuildStrategy defines input parameters specific to an Source build.
