Class ContainerConfiguration.Builder
- java.lang.Object
-
- com.google.cloud.tools.jib.configuration.ContainerConfiguration.Builder
-
- Enclosing class:
- ContainerConfiguration
public static class ContainerConfiguration.Builder extends java.lang.Object
Builder for instantiating aContainerConfiguration
.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEnvironment(java.lang.String name, java.lang.String value)
Adds an environment entry to the container configuration.void
addExposedPort(com.google.cloud.tools.jib.api.buildplan.Port port)
Adds an exposed port entry to the container configuration.void
addLabel(java.lang.String key, java.lang.String value)
Add a label to the container configuration.ContainerConfiguration.Builder
addPlatform(java.lang.String architecture, java.lang.String os)
Adds a desired image platform (OS and architecture pair).void
addVolume(com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath volume)
Adds a volume entry to the container configuration.ContainerConfiguration
build()
Builds theContainerConfiguration
.ContainerConfiguration.Builder
setCreationTime(java.time.Instant creationTime)
Sets the image creation time.ContainerConfiguration.Builder
setEntrypoint(java.util.List<java.lang.String> entrypoint)
Sets the container entrypoint.ContainerConfiguration.Builder
setEnvironment(java.util.Map<java.lang.String,java.lang.String> environmentMap)
Sets the container's environment variables, mapping variable name to value.ContainerConfiguration.Builder
setExposedPorts(java.util.Set<com.google.cloud.tools.jib.api.buildplan.Port> exposedPorts)
Sets the container's exposed ports.ContainerConfiguration.Builder
setLabels(java.util.Map<java.lang.String,java.lang.String> labels)
Sets the container's labels.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.ContainerConfiguration.Builder
setProgramArguments(java.util.List<java.lang.String> programArguments)
Sets the commandline arguments for main.ContainerConfiguration.Builder
setUser(java.lang.String user)
Sets the user and group to run the container as.ContainerConfiguration.Builder
setVolumes(java.util.Set<com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath> volumes)
Sets the container's volumes.ContainerConfiguration.Builder
setWorkingDirectory(com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath workingDirectory)
Sets the working directory in the container.
-
-
-
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 listos
- 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 keyvalue
- 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 addvalue
- 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
-
build
public ContainerConfiguration build()
Builds theContainerConfiguration
.- Returns:
- the corresponding
ContainerConfiguration
-
-