Class Image.Builder

  • Enclosing class:
    Image

    public static class Image.Builder
    extends java.lang.Object
    Builds the immutable Image.
    • Method Detail

      • setCreated

        public Image.Builder setCreated​(java.time.Instant created)
        Sets the image creation time.
        Parameters:
        created - the creation time
        Returns:
        this
      • setArchitecture

        public Image.Builder setArchitecture​(java.lang.String architecture)
        Sets the image architecture.
        Parameters:
        architecture - the architecture
        Returns:
        this
      • setOs

        public Image.Builder setOs​(java.lang.String os)
        Sets the image operating system.
        Parameters:
        os - the operating system
        Returns:
        this
      • addEnvironment

        public Image.Builder addEnvironment​(@Nullable
                                            java.util.Map<java.lang.String,​java.lang.String> environment)
        Adds a map of environment variables to the current map.
        Parameters:
        environment - the map of environment variables
        Returns:
        this
      • addEnvironmentVariable

        public Image.Builder addEnvironmentVariable​(java.lang.String name,
                                                    java.lang.String value)
        Adds an environment variable with a given name and value.
        Parameters:
        name - the name of the variable
        value - the value to set it to
        Returns:
        this
      • setEntrypoint

        public Image.Builder setEntrypoint​(@Nullable
                                           java.util.List<java.lang.String> entrypoint)
        Sets the entrypoint of the image.
        Parameters:
        entrypoint - the list of entrypoint tokens
        Returns:
        this
      • setUser

        public Image.Builder setUser​(@Nullable
                                     java.lang.String user)
        Sets the user/group to run the container as.
        Parameters:
        user - the username/UID and optionally the groupname/GID
        Returns:
        this
      • setProgramArguments

        public Image.Builder setProgramArguments​(@Nullable
                                                 java.util.List<java.lang.String> programArguments)
        Sets the items in the "Cmd" field in the container configuration.
        Parameters:
        programArguments - the list of arguments to append to the image entrypoint
        Returns:
        this
      • setHealthCheck

        public Image.Builder setHealthCheck​(@Nullable
                                            DockerHealthCheck healthCheck)
        Sets the container's healthcheck configuration.
        Parameters:
        healthCheck - the healthcheck configuration
        Returns:
        this
      • addExposedPorts

        public Image.Builder addExposedPorts​(@Nullable
                                             java.util.Set<com.google.cloud.tools.jib.api.buildplan.Port> exposedPorts)
        Adds items to the "ExposedPorts" field in the container configuration.
        Parameters:
        exposedPorts - the exposed ports to add
        Returns:
        this
      • addVolumes

        public Image.Builder addVolumes​(@Nullable
                                        java.util.Set<com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath> volumes)
        Adds items to the "Volumes" field in the container configuration.
        Parameters:
        volumes - the directories to create volumes
        Returns:
        this
      • addLabels

        public Image.Builder addLabels​(@Nullable
                                       java.util.Map<java.lang.String,​java.lang.String> labels)
        Adds items to the "Labels" field in the container configuration.
        Parameters:
        labels - the map of labels to add
        Returns:
        this
      • addLabel

        public Image.Builder addLabel​(java.lang.String name,
                                      java.lang.String value)
        Adds an item to the "Labels" field in the container configuration.
        Parameters:
        name - the name of the label
        value - the value of the label
        Returns:
        this
      • setWorkingDirectory

        public Image.Builder setWorkingDirectory​(@Nullable
                                                 java.lang.String workingDirectory)
        Sets the item in the "WorkingDir" field in the container configuration.
        Parameters:
        workingDirectory - the working directory
        Returns:
        this
      • addHistory

        public Image.Builder addHistory​(HistoryEntry history)
        Adds a history element to the image.
        Parameters:
        history - the history object to add
        Returns:
        this
      • build

        public Image build()
        Create an Image instance.
        Returns:
        a new Image instance