@@ -0,0 +1,83 | |||||
|
1 | # Build and publish images with docker/podman | |||
|
2 | ||||
|
3 | ## SYNOPSIS | |||
|
4 | ||||
|
5 | ```gradle | |||
|
6 | ||||
|
7 | plugins { | |||
|
8 | id 'org.implab.gradle-container' | |||
|
9 | } | |||
|
10 | ||||
|
11 | container { | |||
|
12 | // if you want to use podman | |||
|
13 | cliCmd = "podman" | |||
|
14 | } | |||
|
15 | ||||
|
16 | configurations { | |||
|
17 | app | |||
|
18 | } | |||
|
19 | ||||
|
20 | dependencies { | |||
|
21 | // the application that needs to be built and packed | |||
|
22 | app project(":server") | |||
|
23 | } | |||
|
24 | ||||
|
25 | // add custom task to copy application files | |||
|
26 | // to the docker build context. | |||
|
27 | task copyApp(type: Copy) { | |||
|
28 | processResources.dependsOn it | |||
|
29 | ||||
|
30 | into container.contextDirectory.dir("root/opt/myapp") | |||
|
31 | from configurations.app | |||
|
32 | } | |||
|
33 | ||||
|
34 | task printVersion { | |||
|
35 | doLast { | |||
|
36 | println "tag: ${buildImage.imageTag.get()}" | |||
|
37 | println "archive: ${saveImage.archiveFileName.get()}" | |||
|
38 | } | |||
|
39 | } | |||
|
40 | ||||
|
41 | ||||
|
42 | ``` | |||
|
43 | ||||
|
44 | ## Description | |||
|
45 | ||||
|
46 | This plugin is a simple wrapper around docker CLI. All the image | |||
|
47 | building process is deligated to the `Dockerfile` which will run | |||
|
48 | in the prepeared build context. | |||
|
49 | ||||
|
50 | ### Project structure | |||
|
51 | ||||
|
52 | * `build/` | |||
|
53 | * `context/` - the build context where `docker build` command will run. | |||
|
54 | * `imageid` - the file storing the id of the image has been built. | |||
|
55 | * `image-name-1.2.3.tgz` - the exported image if `saveImage` has been executed. | |||
|
56 | * `src` | |||
|
57 | * `main` - the source files which will be copied to the build context. | |||
|
58 | ||||
|
59 | ## Properties | |||
|
60 | ||||
|
61 | `imagesAuthority` - the registry where the image should be published. | |||
|
62 | for example `docker.io` | |||
|
63 | ||||
|
64 | `imagesGroup` - the path to the image in the repository. | |||
|
65 | ||||
|
66 | ## Tasks | |||
|
67 | ||||
|
68 | ### buildImage | |||
|
69 | ||||
|
70 | The task builds the image. Wrapper around the `docker build` command. | |||
|
71 | ||||
|
72 | ### saveImage | |||
|
73 | ||||
|
74 | The task exports image as the .tar archive. | |||
|
75 | ||||
|
76 | ### pushImage | |||
|
77 | ||||
|
78 | The task pushes the image to the remote repository. | |||
|
79 | ||||
|
80 | ### processResources | |||
|
81 | ||||
|
82 | The copy task, it prepares the build context use it to customize | |||
|
83 | the build context. No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now