readme.md
82 lines
| 1.7 KiB
| text/x-minidsrc
|
MarkdownLexer
cin
|
r1 | # 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. |