Class DockerBuildImage
java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
com.bmuschko.gradle.docker.tasks.AbstractDockerRemoteApiTask
com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
- All Implemented Interfaces:
RegistryCredentialsAware
,Comparable<Task>
,org.gradle.api.internal.DynamicObjectAware
,org.gradle.api.internal.TaskInternal
,ExtensionAware
,Task
,Configurable<Task>
public class DockerBuildImage
extends AbstractDockerRemoteApiTask
implements RegistryCredentialsAware
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.gradle.api.Task
Task.Namer
-
Field Summary
Fields inherited from interface org.gradle.api.Task
TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal MapProperty<String,
String> Build-time variables to pass to the image build.final SetProperty<String>
Images to consider as cache sources.final RegularFileProperty
The Dockerfile to use to build the image.final SetProperty<String>
Build-time additional host list to pass to the image build in the formathost:ip
.The ID of the image built.final RegularFileProperty
Output file containing the image ID of the built image.final SetProperty<String>
The images including repository, image name and tag to be built e.g.final DirectoryProperty
Input directory containing the build context.Labels to attach as metadata for to the image.Memory allocated for build specified in bytes (no suffix is needed)Networking mode for the RUN instructions during build.Whentrue
, do not use docker cache when building the image.The target platform in the formatos[/arch[/variant]]
, for examplelinux/s390x
ordarwin
.getPull()
Whentrue
, always attempt to pull a newer version of the image.getQuiet()
Whentrue
, suppress the build output and print image ID on success.The target Docker registry credentials for usage with a task.Whentrue
, remove intermediate containers after a successful build.Size of/dev/shm
in bytes.With this parameter it is possible to build a special stage in a multi-stage Docker file.void
registryCredentials
(Action<? super DockerRegistryCredentials> action) Configures the target Docker registry credentials for use with a task.void
Methods inherited from class com.bmuschko.gradle.docker.tasks.AbstractDockerRemoteApiTask
getApiVersion, getCertPath, getDockerClient, getDockerClientService, getNextHandler, getRegistryAuthLocator, getUrl, onComplete, onError, onNext, start
Methods inherited from class org.gradle.api.DefaultTask
compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService
Methods inherited from class org.gradle.api.internal.AbstractTask
appendParallelSafeAction, doNotTrackState, getAsDynamicObject, getConvention, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, setImpliesSubProjects
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface org.gradle.api.plugins.ExtensionAware
getExtensions
Methods inherited from interface org.gradle.api.Task
configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, doNotTrackState, finalizedBy, getActions, getAnt, getConvention, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getFinalizedBy, getGroup, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getPath, getProject, getShouldRunAfter, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, notCompatibleWithConfigurationCache, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService
-
Constructor Details
-
DockerBuildImage
public DockerBuildImage()
-
-
Method Details
-
getInputDir
Input directory containing the build context. Defaults to "$buildDir/docker". -
getDockerFile
The Dockerfile to use to build the image. If null, will use 'Dockerfile' in the build context, i.e. "$inputDir/Dockerfile". -
getImages
The images including repository, image name and tag to be built e.g.vieux/apache:2.0
.- Since:
- 6.0.0
-
getNoCache
Whentrue
, do not use docker cache when building the image. -
getRemove
Whentrue
, remove intermediate containers after a successful build. -
getQuiet
Whentrue
, suppress the build output and print image ID on success. -
getPull
Whentrue
, always attempt to pull a newer version of the image. -
getLabels
Labels to attach as metadata for to the image.This property is not final to allow build authors to remove the labels from the up-to-date check by extending
DockerBuildImage
and annotating the overridedgetLabels()
method with@Internal
, example:import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage class CustomDockerBuildImage extends DockerBuildImage { @Override @Internal MapProperty<String, String> getLabels() { super.getLabels() } }
A use case for excluding the labels from the up-to-date check is if build author wants to set build information as labels (date, version-control-revision).
-
getNetwork
Networking mode for the RUN instructions during build. -
getBuildArgs
Build-time variables to pass to the image build. -
getCacheFrom
Images to consider as cache sources. -
getShmSize
Size of/dev/shm
in bytes. The size must be greater than 0. If omitted the system uses 64MB. -
getMemory
Memory allocated for build specified in bytes (no suffix is needed)- Since:
- 7.3.0
-
getTarget
With this parameter it is possible to build a special stage in a multi-stage Docker file.This feature is only available for use with Docker 17.05 and higher.
- Since:
- 4.10.0
-
getExtraHosts
Build-time additional host list to pass to the image build in the formathost:ip
.- Since:
- 6.2.0
-
getPlatform
The target platform in the formatos[/arch[/variant]]
, for examplelinux/s390x
ordarwin
.- Since:
- 7.1.0
-
getRegistryCredentials
The target Docker registry credentials for usage with a task.- Specified by:
getRegistryCredentials
in interfaceRegistryCredentialsAware
-
getImageIdFile
Output file containing the image ID of the built image. Defaults to "$buildDir/.docker/$taskpath-imageId.txt". If path contains ':' it will be replaced by '_'.- Since:
- 4.9.0
-
getImageId
The ID of the image built. The value of this property requires the task action to be executed. -
runRemoteCommand
- Specified by:
runRemoteCommand
in classAbstractDockerRemoteApiTask
- Throws:
Exception
-
registryCredentials
Configures the target Docker registry credentials for use with a task.- Specified by:
registryCredentials
in interfaceRegistryCredentialsAware
- Parameters:
action
- The action against the Docker registry credentials
-