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
Constructors Constructor Description DockerBuildImage()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MapProperty<String,String>
getBuildArgs()
Build-time variables to pass to the image build.SetProperty<String>
getCacheFrom()
Images to consider as cache sources.RegularFileProperty
getDockerFile()
The Dockerfile to use to build the image.SetProperty<String>
getExtraHosts()
Build-time additional host list to pass to the image build in the formathost:ip
.Property<String>
getImageId()
The ID of the image built.RegularFileProperty
getImageIdFile()
Output file containing the image ID of the built image.SetProperty<String>
getImages()
The images including repository, image name and tag to be built e.g.DirectoryProperty
getInputDir()
Input directory containing the build context.MapProperty<String,String>
getLabels()
Labels to attach as metadata for to the image.Property<Long>
getMemory()
Memory allocated for build specified in bytes (no suffix is needed)Property<String>
getNetwork()
Networking mode for the RUN instructions during build.Property<Boolean>
getNoCache()
Whentrue
, do not use docker cache when building the image.Property<String>
getPlatform()
The target platform in the formatos[/arch[/variant]]
, for examplelinux/s390x
ordarwin
.Property<Boolean>
getPull()
Whentrue
, always attempt to pull a newer version of the image.Property<Boolean>
getQuiet()
Whentrue
, suppress the build output and print image ID on success.DockerRegistryCredentials
getRegistryCredentials()
The target Docker registry credentials for usage with a task.Property<Boolean>
getRemove()
Whentrue
, remove intermediate containers after a successful build.Property<Long>
getShmSize()
Size of/dev/shm
in bytes.Property<String>
getTarget()
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
runRemoteCommand()
-
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
-
-
-
-
Method Detail
-
getInputDir
@InputDirectory @PathSensitive(RELATIVE) public final DirectoryProperty getInputDir()
Input directory containing the build context. Defaults to "$buildDir/docker".
-
getDockerFile
@InputFile @PathSensitive(RELATIVE) @Optional public final RegularFileProperty getDockerFile()
The Dockerfile to use to build the image. If null, will use 'Dockerfile' in the build context, i.e. "$inputDir/Dockerfile".
-
getImages
@Input @Optional public final SetProperty<String> getImages()
The images including repository, image name and tag to be built e.g.vieux/apache:2.0
.- Since:
- 6.0.0
-
getNoCache
@Input @Optional public final Property<Boolean> getNoCache()
Whentrue
, do not use docker cache when building the image.
-
getRemove
@Input @Optional public final Property<Boolean> getRemove()
Whentrue
, remove intermediate containers after a successful build.
-
getQuiet
@Input @Optional public final Property<Boolean> getQuiet()
Whentrue
, suppress the build output and print image ID on success.
-
getPull
@Input @Optional public final Property<Boolean> getPull()
Whentrue
, always attempt to pull a newer version of the image.
-
getLabels
@Input @Optional public MapProperty<String,String> 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
@Input @Optional public final Property<String> getNetwork()
Networking mode for the RUN instructions during build.
-
getBuildArgs
@Input @Optional public final MapProperty<String,String> getBuildArgs()
Build-time variables to pass to the image build.
-
getCacheFrom
@Input @Optional public final SetProperty<String> getCacheFrom()
Images to consider as cache sources.
-
getShmSize
@Input @Optional public final Property<Long> getShmSize()
Size of/dev/shm
in bytes. The size must be greater than 0. If omitted the system uses 64MB.
-
getMemory
@Input @Optional public final Property<Long> getMemory()
Memory allocated for build specified in bytes (no suffix is needed)- Since:
- 7.3.0
-
getTarget
@Input @Optional public final Property<String> 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
@Input @Optional public final SetProperty<String> getExtraHosts()
Build-time additional host list to pass to the image build in the formathost:ip
.- Since:
- 6.2.0
-
getPlatform
@Input @Optional public final Property<String> getPlatform()
The target platform in the formatos[/arch[/variant]]
, for examplelinux/s390x
ordarwin
.- Since:
- 7.1.0
-
getRegistryCredentials
public final DockerRegistryCredentials getRegistryCredentials()
The target Docker registry credentials for usage with a task.- Specified by:
getRegistryCredentials
in interfaceRegistryCredentialsAware
-
getImageIdFile
@OutputFile public final RegularFileProperty 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
@Internal public final Property<String> getImageId()
The ID of the image built. The value of this property requires the task action to be executed.
-
runRemoteCommand
public void runRemoteCommand() throws Exception
- Specified by:
runRemoteCommand
in classAbstractDockerRemoteApiTask
- Throws:
Exception
-
registryCredentials
public void registryCredentials(Action<? super DockerRegistryCredentials> action)
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
-
-