Class Containerizer


  • public class Containerizer
    extends java.lang.Object
    Configures how to containerize.
    • Field Detail

      • DEFAULT_BASE_CACHE_DIRECTORY

        public static final java.nio.file.Path DEFAULT_BASE_CACHE_DIRECTORY
        The default directory for caching the base image layers, in [user cache home]/google-cloud-tools-java/jib.
      • DEFAULT_APPLICATION_CACHE_DIRECTORY_NAME

        public static final java.lang.String DEFAULT_APPLICATION_CACHE_DIRECTORY_NAME
        See Also:
        Constant Field Values
    • Method Detail

      • withAdditionalTag

        public Containerizer withAdditionalTag​(java.lang.String tag)
        Adds an additional tag to tag the target image with. For example, the following would containerize to both gcr.io/my-project/my-image:tag and gcr.io/my-project/my-image:tag2:
        
         Containerizer.to(RegistryImage.named("gcr.io/my-project/my-image:tag")).withAdditionalTag("tag2");
         
        Parameters:
        tag - the additional tag to push to
        Returns:
        this
      • setExecutorService

        public Containerizer setExecutorService​(@Nullable
                                                java.util.concurrent.ExecutorService executorService)
        Sets the ExecutorService Jib executes on. Jib, by default, uses Executors.newCachedThreadPool().
        Parameters:
        executorService - the ExecutorService
        Returns:
        this
      • setBaseImageLayersCache

        public Containerizer setBaseImageLayersCache​(java.nio.file.Path cacheDirectory)
        Sets the directory to use for caching base image layers. This cache can (and should) be shared between multiple images. The default base image layers cache directory is [user cache home]/google-cloud-tools-java/jib (DEFAULT_BASE_CACHE_DIRECTORY. This directory can be the same directory used for setApplicationLayersCache(java.nio.file.Path).
        Parameters:
        cacheDirectory - the cache directory
        Returns:
        this
      • setApplicationLayersCache

        public Containerizer setApplicationLayersCache​(java.nio.file.Path cacheDirectory)
        Sets the directory to use for caching application layers. This cache can be shared between multiple images. If not set, a temporary directory will be used as the application layers cache. This directory can be the same directory used for setBaseImageLayersCache(java.nio.file.Path).
        Parameters:
        cacheDirectory - the cache directory
        Returns:
        this
      • addEventHandler

        public <E extends JibEventContainerizer addEventHandler​(java.lang.Class<E> eventType,
                                                                  java.util.function.Consumer<? super E> eventConsumer)
        Adds the eventConsumer to handle the JibEvent with class eventType. The order in which handlers are added is the order in which they are called when the event is dispatched.

        Note: Implementations of eventConsumer must be thread-safe.

        Type Parameters:
        E - the type of eventType
        Parameters:
        eventType - the event type that eventConsumer should handle
        eventConsumer - the event handler
        Returns:
        this
      • setAllowInsecureRegistries

        public Containerizer setAllowInsecureRegistries​(boolean allowInsecureRegistries)
        Sets whether or not to allow communication over HTTP/insecure HTTPS.
        Parameters:
        allowInsecureRegistries - if true, insecure connections will be allowed
        Returns:
        this
      • setOfflineMode

        public Containerizer setOfflineMode​(boolean offline)
        Sets whether or not to run the build in offline mode. In offline mode, the base image is retrieved from the cache instead of pulled from a registry, and the build will fail if the base image is not in the cache or if the target is an image registry.
        Parameters:
        offline - if true, the build will run in offline mode
        Returns:
        this
      • setToolName

        public Containerizer setToolName​(java.lang.String toolName)
        Sets the name of the tool that is using Jib Core. The tool name is sent as part of the User-Agent in registry requests and set as the created_by in the container layer history. Defaults to jib-core.
        Parameters:
        toolName - the name of the tool using this library
        Returns:
        this
      • setToolVersion

        public Containerizer setToolVersion​(@Nullable
                                            java.lang.String toolVersion)
        Sets the version of the tool that is using Jib Core. The tool version is sent as part of the User-Agent in registry requests and set as the created_by in the container layer history. Defaults to the current version of jib-core.
        Parameters:
        toolVersion - the name of the tool using this library
        Returns:
        this
      • setAlwaysCacheBaseImage

        public Containerizer 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 - if true, base image layers are always pulled and cached. If false, base image layers will not be pulled/cached if they already exist on the target registry.
        Returns:
        this
      • addRegistryMirrors

        public Containerizer addRegistryMirrors​(java.lang.String registry,
                                                java.util.List<java.lang.String> mirrors)
        Adds mirrors for a base image registry. Jib will try its mirrors in the given order before finally trying the registry.
        Parameters:
        registry - base image registry for which mirrors are configured
        mirrors - a list of mirrors, where each element is in the form of host[:port]
        Returns:
        this