readme.md
110 lines
| 2.3 KiB
| text/x-minidsrc
|
MarkdownLexer
cin
|
r1 | # Build and publish images with docker/podman | ||
## SYNOPSIS | ||||
```gradle | ||||
plugins { | ||||
cin
|
r4 | id 'org.implab.gradle-container' version '1.1' | ||
cin
|
r1 | } | ||
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/` | ||||
cin
|
r2 | * `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. | ||||
cin
|
r1 | * `src` | ||
cin
|
r2 | * `main` - the source files which will be copied to the build context. | ||
cin
|
r1 | |||
## 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 | ||||
cin
|
r2 | The copy task, it prepares the build context. Use it to customize | ||
the build context. | ||||
cin
|
r4 | |||
### tagImage | ||||
since: 1.1 | ||||
```gradle | ||||
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 `TagImage` task type | ||||
* `ImageTag` class is replaced with `ImageName` class | ||||
* `BuildImage`, `PushImage` tasks are now accepting only `imageName` property | ||||
* Added `imageName`, `imageShortName`, `imageTag` properties to `container` extension | ||||
### 1.0 | ||||
Initial release. Default tasks to build and publish container images. | ||||