Package com.google.cloud.tools.jib.image
Class Image.Builder
- java.lang.Object
-
- com.google.cloud.tools.jib.image.Image.Builder
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Image.Builder
addEnvironment(java.util.Map<java.lang.String,java.lang.String> environment)
Adds a map of environment variables to the current map.Image.Builder
addEnvironmentVariable(java.lang.String name, java.lang.String value)
Adds an environment variable with a given name and value.Image.Builder
addExposedPorts(java.util.Set<com.google.cloud.tools.jib.api.buildplan.Port> exposedPorts)
Adds items to the "ExposedPorts" field in the container configuration.Image.Builder
addHistory(HistoryEntry history)
Adds a history element to the image.Image.Builder
addLabel(java.lang.String name, java.lang.String value)
Adds an item to the "Labels" field in the container configuration.Image.Builder
addLabels(java.util.Map<java.lang.String,java.lang.String> labels)
Adds items to the "Labels" field in the container configuration.Image.Builder
addLayer(Layer layer)
Adds a layer to the image.Image.Builder
addVolumes(java.util.Set<com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath> volumes)
Adds items to the "Volumes" field in the container configuration.Image
build()
Create anImage
instance.Image.Builder
setArchitecture(java.lang.String architecture)
Sets the image architecture.Image.Builder
setCreated(java.time.Instant created)
Sets the image creation time.Image.Builder
setEntrypoint(java.util.List<java.lang.String> entrypoint)
Sets the entrypoint of the image.Image.Builder
setHealthCheck(DockerHealthCheck healthCheck)
Sets the container's healthcheck configuration.Image.Builder
setOs(java.lang.String os)
Sets the image operating system.Image.Builder
setProgramArguments(java.util.List<java.lang.String> programArguments)
Sets the items in the "Cmd" field in the container configuration.Image.Builder
setUser(java.lang.String user)
Sets the user/group to run the container as.Image.Builder
setWorkingDirectory(java.lang.String workingDirectory)
Sets the item in the "WorkingDir" field in the container configuration.
-
-
-
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 variablevalue
- 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 labelvalue
- 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
-
addLayer
public Image.Builder addLayer(Layer layer) throws LayerPropertyNotFoundException
Adds a layer to the image.- Parameters:
layer
- the layer to add- Returns:
- this
- Throws:
LayerPropertyNotFoundException
- if adding the layer fails
-
addHistory
public Image.Builder addHistory(HistoryEntry history)
Adds a history element to the image.- Parameters:
history
- the history object to add- Returns:
- this
-
-