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