Class ContainerConfiguration.Builder

    • Method Detail

      • setPlatforms

        public ContainerConfiguration.Builder setPlatforms​(java.util.Set<com.google.cloud.tools.jib.api.buildplan.Platform> platforms)
        Sets a desired platform (properties including OS and architecture) list. If the base image reference is a Docker manifest list or an OCI image index, an image builder may select the base images matching the given platforms. If the base image reference is an image manifest, an image builder may ignore the given platforms and use the platform of the base image or may decide to raise on error.

        Note that a new container configuration starts with "amd64/linux" as the default platform.

        Parameters:
        platforms - list of platforms to select base images in case of a manifest list
        Returns:
        this
      • addPlatform

        public ContainerConfiguration.Builder addPlatform​(java.lang.String architecture,
                                                          java.lang.String os)
        Adds a desired image platform (OS and architecture pair). If the base image reference is a Docker manifest list or an OCI image index, an image builder may select the base image matching the given platform. If the base image reference is an image manifest, an image builder may ignore the given platform and use the platform of the base image or may decide to raise on error.

        Note that a new container configuration starts with "amd64/linux" as the default platform. If you want to reset the default platform instead of adding a new one, use setPlatforms(Set).

        Parameters:
        architecture - architecture (for example, amd64) to select a base image in case of a manifest list
        os - OS (for example, linux) to select a base image in case of a manifest list
        Returns:
        this
      • setCreationTime

        public ContainerConfiguration.Builder setCreationTime​(java.time.Instant creationTime)
        Sets the image creation time.
        Parameters:
        creationTime - the creation time
        Returns:
        this
      • setProgramArguments

        public ContainerConfiguration.Builder setProgramArguments​(@Nullable
                                                                  java.util.List<java.lang.String> programArguments)
        Sets the commandline arguments for main.
        Parameters:
        programArguments - the list of arguments
        Returns:
        this
      • setEnvironment

        public ContainerConfiguration.Builder setEnvironment​(@Nullable
                                                             java.util.Map<java.lang.String,​java.lang.String> environmentMap)
        Sets the container's environment variables, mapping variable name to value.
        Parameters:
        environmentMap - the map
        Returns:
        this
      • addEnvironment

        public void addEnvironment​(java.lang.String name,
                                   java.lang.String value)
        Adds an environment entry to the container configuration.
        Parameters:
        name - the environment variable key
        value - the non-null value to associate with environment variable
      • setExposedPorts

        public ContainerConfiguration.Builder setExposedPorts​(@Nullable
                                                              java.util.Set<com.google.cloud.tools.jib.api.buildplan.Port> exposedPorts)
        Sets the container's exposed ports.
        Parameters:
        exposedPorts - the set of ports
        Returns:
        this
      • addExposedPort

        public void addExposedPort​(com.google.cloud.tools.jib.api.buildplan.Port port)
        Adds an exposed port entry to the container configuration.
        Parameters:
        port - the non-null port to add
      • setVolumes

        public ContainerConfiguration.Builder setVolumes​(@Nullable
                                                         java.util.Set<com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath> volumes)
        Sets the container's volumes.
        Parameters:
        volumes - the set of volumes
        Returns:
        this
      • addVolume

        public void addVolume​(com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath volume)
        Adds a volume entry to the container configuration.
        Parameters:
        volume - the absolute path to add as a volume entry
      • setLabels

        public ContainerConfiguration.Builder setLabels​(@Nullable
                                                        java.util.Map<java.lang.String,​java.lang.String> labels)
        Sets the container's labels.
        Parameters:
        labels - the map of labels
        Returns:
        this
      • addLabel

        public void addLabel​(java.lang.String key,
                             java.lang.String value)
        Add a label to the container configuration.
        Parameters:
        key - the label name to add
        value - the value to be associated with the label
      • setEntrypoint

        public ContainerConfiguration.Builder setEntrypoint​(@Nullable
                                                            java.util.List<java.lang.String> entrypoint)
        Sets the container entrypoint.
        Parameters:
        entrypoint - the tokenized command to run when the container starts
        Returns:
        this
      • setUser

        public ContainerConfiguration.Builder setUser​(@Nullable
                                                      java.lang.String user)
        Sets the user and group to run the container as. user can be a username or UID along with an optional groupname or GID. The following are all valid: user, uid, user:group, uid:gid, uid:group, user:gid.
        Parameters:
        user - the username/UID and optionally the groupname/GID
        Returns:
        this
      • setWorkingDirectory

        public ContainerConfiguration.Builder setWorkingDirectory​(@Nullable
                                                                  com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath workingDirectory)
        Sets the working directory in the container.
        Parameters:
        workingDirectory - the working directory
        Returns:
        this