Class BuildContext.Builder
- java.lang.Object
-
- com.google.cloud.tools.jib.configuration.BuildContext.Builder
-
- Enclosing class:
- BuildContext
public static class BuildContext.Builder extends java.lang.Object
Builds an immutableBuildContext
. Instantiate withBuildContext.builder()
.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BuildContext
build()
Builds a newBuildContext
using the parameters passed into the builder.BuildContext.Builder
setAdditionalTargetImageTags(java.util.Set<java.lang.String> tags)
Sets the tags to tag the target image with (in addition to the tag in the target image configuration image reference set viasetTargetImageConfiguration(com.google.cloud.tools.jib.configuration.ImageConfiguration)
).BuildContext.Builder
setAllowInsecureRegistries(boolean allowInsecureRegistries)
Sets whether or not to allow communication over HTTP (as opposed to HTTPS).BuildContext.Builder
setAlwaysCacheBaseImage(boolean alwaysCacheBaseImage)
Controls the optimization which skips downloading base image layers that exist in a target registry.BuildContext.Builder
setApplicationLayersCacheDirectory(java.nio.file.Path applicationLayersCacheDirectory)
Sets the location of the cache for storing application layers.BuildContext.Builder
setBaseImageConfiguration(ImageConfiguration imageConfiguration)
Sets the base image configuration.BuildContext.Builder
setBaseImageLayersCacheDirectory(java.nio.file.Path baseImageLayersCacheDirectory)
Sets the location of the cache for storing base image layers.BuildContext.Builder
setContainerConfiguration(ContainerConfiguration containerConfiguration)
Sets configuration parameters for the container.BuildContext.Builder
setEnablePlatformTags(boolean enablePlatformTags)
Sets whether to automatically add architecture suffix to tags for platform-specific images when building multi-platform images.BuildContext.Builder
setEventHandlers(EventHandlers eventHandlers)
Sets theEventHandlers
to dispatch events with.BuildContext.Builder
setExecutorService(java.util.concurrent.ExecutorService executorService)
Sets theExecutorService
Jib executes on.BuildContext.Builder
setLayerConfigurations(java.util.List<com.google.cloud.tools.jib.api.buildplan.FileEntriesLayer> layerConfigurations)
Sets the layers to build.BuildContext.Builder
setOffline(boolean offline)
Sets whether or not to perform the build in offline mode.BuildContext.Builder
setRegistryMirrors(com.google.common.collect.ListMultimap<java.lang.String,java.lang.String> registryMirrors)
Sets the registry mirrors.BuildContext.Builder
setTargetFormat(com.google.cloud.tools.jib.api.buildplan.ImageFormat targetFormat)
Sets the target format of the container image.BuildContext.Builder
setTargetImageConfiguration(ImageConfiguration imageConfiguration)
Sets the target image configuration.BuildContext.Builder
setToolName(java.lang.String toolName)
Sets the name of the tool that is executing the build.BuildContext.Builder
setToolVersion(java.lang.String toolVersion)
Sets the version of the tool that is executing the build.
-
-
-
Method Detail
-
setBaseImageConfiguration
public BuildContext.Builder setBaseImageConfiguration(ImageConfiguration imageConfiguration)
Sets the base image configuration.- Parameters:
imageConfiguration
- theImageConfiguration
describing the base image- Returns:
- this
-
setTargetImageConfiguration
public BuildContext.Builder setTargetImageConfiguration(ImageConfiguration imageConfiguration)
Sets the target image configuration.- Parameters:
imageConfiguration
- theImageConfiguration
describing the target image- Returns:
- this
-
setAdditionalTargetImageTags
public BuildContext.Builder setAdditionalTargetImageTags(java.util.Set<java.lang.String> tags)
Sets the tags to tag the target image with (in addition to the tag in the target image configuration image reference set viasetTargetImageConfiguration(com.google.cloud.tools.jib.configuration.ImageConfiguration)
).- Parameters:
tags
- a set of tags- Returns:
- this
-
setEnablePlatformTags
public BuildContext.Builder setEnablePlatformTags(boolean enablePlatformTags)
Sets whether to automatically add architecture suffix to tags for platform-specific images when building multi-platform images. For example, when building amd64 and arm64 images for a given tag, the final tags will be<tag>-amd64
and<tag>-arm64
.- Parameters:
enablePlatformTags
- whether to append architecture suffix to tags- Returns:
- this
-
setContainerConfiguration
public BuildContext.Builder setContainerConfiguration(ContainerConfiguration containerConfiguration)
Sets configuration parameters for the container.- Parameters:
containerConfiguration
- theContainerConfiguration
- Returns:
- this
-
setApplicationLayersCacheDirectory
public BuildContext.Builder setApplicationLayersCacheDirectory(java.nio.file.Path applicationLayersCacheDirectory)
Sets the location of the cache for storing application layers.- Parameters:
applicationLayersCacheDirectory
- the application layers cache directory- Returns:
- this
-
setBaseImageLayersCacheDirectory
public BuildContext.Builder setBaseImageLayersCacheDirectory(java.nio.file.Path baseImageLayersCacheDirectory)
Sets the location of the cache for storing base image layers.- Parameters:
baseImageLayersCacheDirectory
- the base image layers cache directory- Returns:
- this
-
setTargetFormat
public BuildContext.Builder setTargetFormat(com.google.cloud.tools.jib.api.buildplan.ImageFormat targetFormat)
Sets the target format of the container image.- Parameters:
targetFormat
- the target format- Returns:
- this
-
setAllowInsecureRegistries
public BuildContext.Builder setAllowInsecureRegistries(boolean allowInsecureRegistries)
Sets whether or not to allow communication over HTTP (as opposed to HTTPS).- Parameters:
allowInsecureRegistries
- iftrue
, insecure connections will be allowed- Returns:
- this
-
setOffline
public BuildContext.Builder setOffline(boolean offline)
Sets whether or not to perform the build in offline mode.- Parameters:
offline
- iftrue
, the build will run in offline mode- Returns:
- this
-
setAlwaysCacheBaseImage
public BuildContext.Builder setAlwaysCacheBaseImage(boolean alwaysCacheBaseImage)
Controls the optimization which skips downloading base image layers that exist in a target registry. If the user does not set this property then read as false.- Parameters:
alwaysCacheBaseImage
- iftrue
, base image layers are always pulled and cached. Iffalse
, base image layers will not be pulled/cached if they already exist on the target registry.- Returns:
- this
-
setLayerConfigurations
public BuildContext.Builder setLayerConfigurations(java.util.List<com.google.cloud.tools.jib.api.buildplan.FileEntriesLayer> layerConfigurations)
Sets the layers to build.- Parameters:
layerConfigurations
- the configurations for the layers- Returns:
- this
-
setToolName
public BuildContext.Builder setToolName(java.lang.String toolName)
Sets the name of the tool that is executing the build.- Parameters:
toolName
- the tool name- Returns:
- this
-
setToolVersion
public BuildContext.Builder setToolVersion(@Nullable java.lang.String toolVersion)
Sets the version of the tool that is executing the build.- Parameters:
toolVersion
- the tool version- Returns:
- this
-
setEventHandlers
public BuildContext.Builder setEventHandlers(EventHandlers eventHandlers)
Sets theEventHandlers
to dispatch events with.- Parameters:
eventHandlers
- theEventHandlers
- Returns:
- this
-
setExecutorService
public BuildContext.Builder setExecutorService(@Nullable java.util.concurrent.ExecutorService executorService)
Sets theExecutorService
Jib executes on. By default, Jib usesExecutors.newCachedThreadPool()
.- Parameters:
executorService
- theExecutorService
- Returns:
- this
-
setRegistryMirrors
public BuildContext.Builder setRegistryMirrors(com.google.common.collect.ListMultimap<java.lang.String,java.lang.String> registryMirrors)
Sets the registry mirrors.- Parameters:
registryMirrors
- registry mirrors- Returns:
- this
-
build
public BuildContext build() throws CacheDirectoryCreationException
Builds a newBuildContext
using the parameters passed into the builder.- Returns:
- the corresponding build context
- Throws:
CacheDirectoryCreationException
- if I/O exception occurs when creating cache directory
-
-