| Name | Size | Modified | Last Commit | Author |
|---|---|---|---|---|
| container | ||||
| gradle | ||||
| .hgignore | Loading ... | |||
| .hgtags | Loading ... | |||
| build.gradle | Loading ... | |||
| gradlew | Loading ... | |||
| gradlew.bat | Loading ... | |||
| readme.md | Loading ... | |||
| settings.gradle | Loading ... | |||
Build and publish images with docker/podman
SYNOPSIS
plugins { id 'org.implab.gradle-container' version '1.1' } container { // if you want to use podman cliCmd = "podman" } configurations { app } dependencies { // the application that needs to be built and packed app project(":server") } // add custom task to copy application files // to the docker build context. task copyApp(type: Copy) { processResources.dependsOn it into container.contextDirectory.dir("root/opt/myapp") from configurations.app } task printVersion { doLast { println "tag: ${buildImage.imageTag.get()}" println "archive: ${saveImage.archiveFileName.get()}" } }
Description
This plugin is a simple wrapper around docker CLI. All the image
building process is deligated to the Dockerfile which will run
in the prepeared build context.
Project structure
build/context/- the build context wheredocker buildcommand will run.imageid- the file storing the id of the image has been built.image-name-1.2.3.tgz- the exported image ifsaveImagehas been executed.
srcmain- the source files which will be copied to the build context.
Properties
imagesAuthority - the registry where the image should be published.
for example docker.io
imagesGroup - the path to the image in the repository.
Tasks
buildImage
The task builds the image. Wrapper around the docker build command.
saveImage
The task exports image as the .tar archive.
pushImage
The task pushes the image to the remote repository.
processResources
The copy task, it prepares the build context. Use it to customize the build context.
tagImage
since: 1.1
task tagLatest(type: TagImage) { srcImage = container.imageName destImage = container.imageName.map { it.tag("latest") } }
Changes
1.1
Warning! This version isn't fully backward compatible with 1.0 version.
- Added
TagImagetask type ImageTagclass is replaced withImageNameclassBuildImage,PushImagetasks are now accepting onlyimageNameproperty- Added
imageName,imageShortName,imageTagproperties tocontainerextension
1.0
Initial release. Default tasks to build and publish container images.
