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