# HG changeset patch # User cin # Date 2021-05-20 15:46:34 # Node ID aaf8250501fdef8b41070122c629b72d5483506c # Parent e3188a091ff454063725cf2fa8b066ae284e24c2 added description diff --git a/container/gradle.properties b/container/gradle.properties new file mode 100644 --- /dev/null +++ b/container/gradle.properties @@ -0,0 +1,2 @@ +group=org.implab.gradle +version=1.0 \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 --- /dev/null +++ b/readme.md @@ -0,0 +1,83 @@ +# Build and publish images with docker/podman + +## SYNOPSIS + +```gradle + +plugins { + id 'org.implab.gradle-container' +} + +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 where `docker build` command will run. + * `imageid` - the file storing the id of the image has been built. + * `image-name-1.2.3.tgz` - the exported image if `saveImage` has been executed. +* `src` + * `main` - 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. \ No newline at end of file