├── .github
└── stale.yml
├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── CODE_COVERAGE.md
├── COMPETITORS.md
├── CONTRIBUTING.md
├── DEBUG.md
├── README.md
├── USAGE.md
├── circle.yml
├── pom.xml
└── src
├── it
├── auth-config-it
│ ├── dockercfg
│ ├── pom.xml
│ ├── src
│ │ └── main
│ │ │ └── docker
│ │ │ ├── app
│ │ │ ├── Dockerfile
│ │ │ └── conf.yml
│ │ │ ├── nginx
│ │ │ ├── Dockerfile
│ │ │ ├── conf.yml
│ │ │ └── external
│ │ │ │ ├── cert.pem
│ │ │ │ ├── docker-registry.htpasswd
│ │ │ │ └── key.pem
│ │ │ └── registry
│ │ │ ├── Dockerfile
│ │ │ └── conf.yml
│ └── verify.groovy
├── build-test-it
│ ├── hello-world.yml
│ ├── pom.xml
│ ├── src
│ │ ├── main
│ │ │ ├── docker
│ │ │ │ ├── app
│ │ │ │ │ ├── Dockerfile
│ │ │ │ │ ├── conf.yml
│ │ │ │ │ └── run.sh
│ │ │ │ ├── mysql
│ │ │ │ │ ├── Dockerfile
│ │ │ │ │ └── conf.yml
│ │ │ │ └── rubbish
│ │ │ │ │ ├── Dockerfile
│ │ │ │ │ └── conf.yml
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── helloworld
│ │ │ │ │ ├── HelloWorldConfiguration.java
│ │ │ │ │ ├── HelloWorldResource.java
│ │ │ │ │ ├── HelloWorldService.java
│ │ │ │ │ ├── PeopleDAO.java
│ │ │ │ │ ├── Saying.java
│ │ │ │ │ ├── TemplateHealthCheck.java
│ │ │ │ │ └── model
│ │ │ │ │ └── Person.java
│ │ │ └── resources
│ │ │ │ └── migrations.xml
│ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── helloworld
│ │ │ └── HelloWorldServiceIT.java
│ ├── test.properties
│ └── verify.groovy
├── port-setup-it
│ ├── pom.xml
│ ├── src
│ │ └── main
│ │ │ └── docker
│ │ │ └── mysql
│ │ │ ├── Dockerfile
│ │ │ └── conf.yml
│ └── verify.groovy
└── settings.xml
├── main
├── java
│ └── com
│ │ └── alexecollins
│ │ └── docker
│ │ ├── mojo
│ │ ├── AbstractDockerMojo.java
│ │ ├── CleanMojo.java
│ │ ├── CopyMojo.java
│ │ ├── DeployMojo.java
│ │ ├── LoggingMojo.java
│ │ ├── PackageMojo.java
│ │ ├── SaveMojo.java
│ │ ├── StartMojo.java
│ │ ├── StopMojo.java
│ │ └── ValidateMojo.java
│ │ └── util
│ │ └── MavenLogAppender.java
└── resources
│ └── logback.xml
└── test
├── java
└── com
│ └── alexecollins
│ └── docker
│ ├── mojo
│ ├── AbstractDockerMojoTest.java
│ ├── CleanMojoTest.java
│ ├── CopyMojoTest.java
│ ├── DeployMojoTest.java
│ ├── MojoTestSupport.java
│ ├── PackageMojoTest.java
│ ├── SaveMojoTest.java
│ ├── StartMojoTest.java
│ ├── StopMojoTest.java
│ └── ValidateMojoTest.java
│ └── util
│ └── MavenLogAppenderTest.java
└── resources
└── logback.xml
/.github/stale.yml:
--------------------------------------------------------------------------------
1 | # Number of days of inactivity before an issue becomes stale
2 | daysUntilStale: 60
3 | # Number of days of inactivity before a stale issue is closed
4 | daysUntilClose: 7
5 | # Issues with these labels will never be considered stale
6 | exemptLabels:
7 | - pinned
8 | - security
9 | # Label to use when marking an issue as stale
10 | staleLabel: wontfix
11 | # Comment to post when marking an issue as stale. Set to `false` to disable
12 | markComment: >
13 | This issue has been automatically marked as stale because it has not had
14 | recent activity. It will be closed if no further activity occurs. Thank you
15 | for your contributions.
16 | # Comment to post when closing a stale issue. Set to `false` to disable
17 | closeComment: false
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | *.iml
3 | target
4 | /.settings
5 | /.classpath
6 | /.project
7 | pom.xml.versionsBackup
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 | script: mvn verify
3 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | ## [docker-maven-plugin-2.11.17](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.11.17) (2016-08-13)
4 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.11.16...docker-maven-plugin-2.11.17)
5 |
6 | ## [docker-maven-plugin-2.11.16](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.11.16) (2016-07-24)
7 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.11.15...docker-maven-plugin-2.11.16)
8 |
9 | **Closed issues:**
10 |
11 | - Cannot build after force-delete merged [\#104](https://github.com/alexec/docker-maven-plugin/issues/104)
12 |
13 | ## [docker-maven-plugin-2.11.15](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.11.15) (2016-07-03)
14 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.11.14...docker-maven-plugin-2.11.15)
15 |
16 | **Merged pull requests:**
17 |
18 | - Port to docker-java 3.0.0-SNAPSHOT [\#106](https://github.com/alexec/docker-maven-plugin/pull/106) ([marcust](https://github.com/marcust))
19 | - Clean flag \(fixees \#104\) [\#105](https://github.com/alexec/docker-maven-plugin/pull/105) ([marcust](https://github.com/marcust))
20 |
21 | ## [docker-maven-plugin-2.11.14](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.11.14) (2016-06-23)
22 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.11.13...docker-maven-plugin-2.11.14)
23 |
24 | **Fixed bugs:**
25 |
26 | - Deletion of Images with Multiple Tags Fails [\#96](https://github.com/alexec/docker-maven-plugin/issues/96)
27 |
28 | **Closed issues:**
29 |
30 | - small typo in your title... [\#102](https://github.com/alexec/docker-maven-plugin/issues/102)
31 |
32 | **Merged pull requests:**
33 |
34 | - Make force image delete optional [\#103](https://github.com/alexec/docker-maven-plugin/pull/103) ([marcust](https://github.com/marcust))
35 | - Update readme with notes regarding artifactory [\#99](https://github.com/alexec/docker-maven-plugin/pull/99) ([lorijoan](https://github.com/lorijoan))
36 |
37 | ## [docker-maven-plugin-2.11.13](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.11.13) (2016-05-24)
38 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.11.12...docker-maven-plugin-2.11.13)
39 |
40 | **Fixed bugs:**
41 |
42 | - Enforcing usage of http instead of http when pushing [\#93](https://github.com/alexec/docker-maven-plugin/issues/93)
43 | - validate goal does not support port type at expose [\#89](https://github.com/alexec/docker-maven-plugin/issues/89)
44 |
45 | ## [docker-maven-plugin-2.11.12](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.11.12) (2016-05-24)
46 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.11.11...docker-maven-plugin-2.11.12)
47 |
48 | **Closed issues:**
49 |
50 | - Question: Is running multiple containers from the same image supported? [\#97](https://github.com/alexec/docker-maven-plugin/issues/97)
51 |
52 | **Merged pull requests:**
53 |
54 | - Add logging mojo feature [\#98](https://github.com/alexec/docker-maven-plugin/pull/98) ([marcust](https://github.com/marcust))
55 |
56 | ## [docker-maven-plugin-2.11.11](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.11.11) (2016-04-24)
57 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.11.10...docker-maven-plugin-2.11.11)
58 |
59 | ## [docker-maven-plugin-2.11.10](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.11.10) (2016-03-05)
60 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.11.9...docker-maven-plugin-2.11.10)
61 |
62 | **Implemented enhancements:**
63 |
64 | - Delete stopped containers after maven completes [\#91](https://github.com/alexec/docker-maven-plugin/issues/91)
65 | - Goals not bound by default to lifecycle phases [\#66](https://github.com/alexec/docker-maven-plugin/issues/66)
66 | - Improvement : docker:tree [\#43](https://github.com/alexec/docker-maven-plugin/issues/43)
67 |
68 | **Fixed bugs:**
69 |
70 | - volumes does not seem to do anything [\#90](https://github.com/alexec/docker-maven-plugin/issues/90)
71 |
72 | **Merged pull requests:**
73 |
74 | - Unit tests to increase code coverage from 33% to 86% [\#95](https://github.com/alexec/docker-maven-plugin/pull/95) ([airleks](https://github.com/airleks))
75 | - Unit test samples [\#94](https://github.com/alexec/docker-maven-plugin/pull/94) ([airleks](https://github.com/airleks))
76 |
77 | ## [docker-maven-plugin-2.11.9](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.11.9) (2016-01-08)
78 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.11.7...docker-maven-plugin-2.11.9)
79 |
80 | **Merged pull requests:**
81 |
82 | - Support docker copy of resources [\#92](https://github.com/alexec/docker-maven-plugin/pull/92) ([andyp1per](https://github.com/andyp1per))
83 |
84 | ## [docker-maven-plugin-2.11.7](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.11.7) (2015-12-04)
85 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.11.6...docker-maven-plugin-2.11.7)
86 |
87 | ## [docker-maven-plugin-2.11.6](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.11.6) (2015-12-04)
88 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.11.5...docker-maven-plugin-2.11.6)
89 |
90 | ## [docker-maven-plugin-2.11.5](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.11.5) (2015-11-19)
91 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.11.4...docker-maven-plugin-2.11.5)
92 |
93 | **Merged pull requests:**
94 |
95 | - Introduce pull property to force pulling during builds [\#86](https://github.com/alexec/docker-maven-plugin/pull/86) ([marcust](https://github.com/marcust))
96 |
97 | ## [docker-maven-plugin-2.11.4](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.11.4) (2015-10-27)
98 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.11.3...docker-maven-plugin-2.11.4)
99 |
100 | **Fixed bugs:**
101 |
102 | - Deploy does not always throw on failure [\#78](https://github.com/alexec/docker-maven-plugin/issues/78)
103 |
104 | ## [docker-maven-plugin-2.11.3](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.11.3) (2015-10-12)
105 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.11.2...docker-maven-plugin-2.11.3)
106 |
107 | ## [docker-maven-plugin-2.11.2](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.11.2) (2015-10-09)
108 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.11.1...docker-maven-plugin-2.11.2)
109 |
110 | ## [docker-maven-plugin-2.11.1](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.11.1) (2015-10-08)
111 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.11.0...docker-maven-plugin-2.11.1)
112 |
113 | **Merged pull requests:**
114 |
115 | - Revert "Revert "Add capability to detect version"" [\#83](https://github.com/alexec/docker-maven-plugin/pull/83) ([alexec](https://github.com/alexec))
116 | - Revert "Add capability to detect version" [\#82](https://github.com/alexec/docker-maven-plugin/pull/82) ([alexec](https://github.com/alexec))
117 | - Add capability to detect version [\#81](https://github.com/alexec/docker-maven-plugin/pull/81) ([marcust](https://github.com/marcust))
118 |
119 | ## [docker-maven-plugin-2.11.0](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.11.0) (2015-10-04)
120 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.10.6...docker-maven-plugin-2.11.0)
121 |
122 | ## [docker-maven-plugin-2.10.6](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.10.6) (2015-10-03)
123 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.10.5...docker-maven-plugin-2.10.6)
124 |
125 | **Fixed bugs:**
126 |
127 | - Use a third-party image as a build dependency [\#80](https://github.com/alexec/docker-maven-plugin/issues/80)
128 | - Version number for WildFly is not compatible [\#75](https://github.com/alexec/docker-maven-plugin/issues/75)
129 |
130 | ## [docker-maven-plugin-2.10.5](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.10.5) (2015-09-26)
131 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.10.4...docker-maven-plugin-2.10.5)
132 |
133 | ## [docker-maven-plugin-2.10.4](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.10.4) (2015-08-25)
134 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.10.3...docker-maven-plugin-2.10.4)
135 |
136 | ## [docker-maven-plugin-2.10.3](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.10.3) (2015-08-14)
137 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.10.2...docker-maven-plugin-2.10.3)
138 |
139 | ## [docker-maven-plugin-2.10.2](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.10.2) (2015-08-13)
140 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.10.1...docker-maven-plugin-2.10.2)
141 |
142 | **Merged pull requests:**
143 |
144 | - Update volumes usage sample [\#74](https://github.com/alexec/docker-maven-plugin/pull/74) ([hypery2k](https://github.com/hypery2k))
145 |
146 | ## [docker-maven-plugin-2.10.1](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.10.1) (2015-08-03)
147 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.10.0...docker-maven-plugin-2.10.1)
148 |
149 | ## [docker-maven-plugin-2.10.0](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.10.0) (2015-08-02)
150 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.9.3...docker-maven-plugin-2.10.0)
151 |
152 | **Merged pull requests:**
153 |
154 | - Wait for line [\#73](https://github.com/alexec/docker-maven-plugin/pull/73) ([alexec](https://github.com/alexec))
155 | - Clean container only in clean configuration option [\#72](https://github.com/alexec/docker-maven-plugin/pull/72) ([marcust](https://github.com/marcust))
156 | - Fix broken links & update numbers in "Competitors" [\#71](https://github.com/alexec/docker-maven-plugin/pull/71) ([bentolor](https://github.com/bentolor))
157 |
158 | ## [docker-maven-plugin-2.9.3](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.9.3) (2015-07-07)
159 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.9.2...docker-maven-plugin-2.9.3)
160 |
161 | **Implemented enhancements:**
162 |
163 | - run container with --privileged=false - Give extended privileges to this container [\#67](https://github.com/alexec/docker-maven-plugin/issues/67)
164 |
165 | **Closed issues:**
166 |
167 | - NPE with Docker 1.6.2 on Circle CI [\#70](https://github.com/alexec/docker-maven-plugin/issues/70)
168 | - Release 2.9.1 is not available on Maven Central repos [\#69](https://github.com/alexec/docker-maven-plugin/issues/69)
169 |
170 | ## [docker-maven-plugin-2.9.2](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.9.2) (2015-06-12)
171 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.9.1...docker-maven-plugin-2.9.2)
172 |
173 | **Implemented enhancements:**
174 |
175 | - Setting up projects to build from both linux and boot2docker [\#68](https://github.com/alexec/docker-maven-plugin/issues/68)
176 |
177 | **Fixed bugs:**
178 |
179 | - user properties not filtered in conf.yml [\#62](https://github.com/alexec/docker-maven-plugin/issues/62)
180 | - Push broken [\#61](https://github.com/alexec/docker-maven-plugin/issues/61)
181 | - docker:start failure on windows [\#54](https://github.com/alexec/docker-maven-plugin/issues/54)
182 |
183 | **Closed issues:**
184 |
185 | - Unsupported major.minor version 51.0 [\#65](https://github.com/alexec/docker-maven-plugin/issues/65)
186 |
187 | ## [docker-maven-plugin-2.9.1](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.9.1) (2015-05-24)
188 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.9.0...docker-maven-plugin-2.9.1)
189 |
190 | ## [docker-maven-plugin-2.9.0](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.9.0) (2015-05-21)
191 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.8.4...docker-maven-plugin-2.9.0)
192 |
193 | **Implemented enhancements:**
194 |
195 | - The container name should be configurable [\#51](https://github.com/alexec/docker-maven-plugin/issues/51)
196 | - Image build order unknown [\#48](https://github.com/alexec/docker-maven-plugin/issues/48)
197 | - \* Added support for cfgPath [\#52](https://github.com/alexec/docker-maven-plugin/pull/52) ([eemmiirr](https://github.com/eemmiirr))
198 |
199 | **Fixed bugs:**
200 |
201 | - Exposed port via conf.yml is not mapping correctly [\#50](https://github.com/alexec/docker-maven-plugin/issues/50)
202 | - Excluded container is still trying to find by id [\#49](https://github.com/alexec/docker-maven-plugin/issues/49)
203 |
204 | **Closed issues:**
205 |
206 | - Port mapping problem [\#57](https://github.com/alexec/docker-maven-plugin/issues/57)
207 | - Fail to parse conf.yml when env is specified [\#55](https://github.com/alexec/docker-maven-plugin/issues/55)
208 |
209 | **Merged pull requests:**
210 |
211 | - \[cleanup\] documentation is out of sync with the default values [\#53](https://github.com/alexec/docker-maven-plugin/pull/53) ([dacrome](https://github.com/dacrome))
212 |
213 | ## [docker-maven-plugin-2.8.4](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.8.4) (2015-04-28)
214 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.8.3...docker-maven-plugin-2.8.4)
215 |
216 | ## [docker-maven-plugin-2.8.3](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.8.3) (2015-04-28)
217 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.8.2...docker-maven-plugin-2.8.3)
218 |
219 | ## [docker-maven-plugin-2.8.2](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.8.2) (2015-04-28)
220 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.8.1...docker-maven-plugin-2.8.2)
221 |
222 | ## [docker-maven-plugin-2.8.1](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.8.1) (2015-04-27)
223 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.7.0...docker-maven-plugin-2.8.1)
224 |
225 | ## [docker-maven-plugin-2.7.0](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.7.0) (2015-04-23)
226 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.6.0...docker-maven-plugin-2.7.0)
227 |
228 | ## [docker-maven-plugin-2.6.0](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.6.0) (2015-04-16)
229 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.5.0...docker-maven-plugin-2.6.0)
230 |
231 | **Closed issues:**
232 |
233 | - Bump docker-java to 1.2.0 [\#47](https://github.com/alexec/docker-maven-plugin/issues/47)
234 |
235 | ## [docker-maven-plugin-2.5.0](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.5.0) (2015-04-09)
236 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.4.0...docker-maven-plugin-2.5.0)
237 |
238 | **Implemented enhancements:**
239 |
240 | - Allow configurable file filter regex to control property replacements in staged files. [\#40](https://github.com/alexec/docker-maven-plugin/issues/40)
241 |
242 | **Closed issues:**
243 |
244 | - Goal "start" is rebuilding the image [\#45](https://github.com/alexec/docker-maven-plugin/issues/45)
245 | - Error on OS X with .DS\_Store [\#44](https://github.com/alexec/docker-maven-plugin/issues/44)
246 |
247 | **Merged pull requests:**
248 |
249 | - Using new version of docker-java-orchestration [\#46](https://github.com/alexec/docker-maven-plugin/pull/46) ([eemmiirr](https://github.com/eemmiirr))
250 |
251 | ## [docker-maven-plugin-2.4.0](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.4.0) (2015-01-29)
252 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.3.1...docker-maven-plugin-2.4.0)
253 |
254 | **Implemented enhancements:**
255 |
256 | - Running vanilla images & dynamic port mappings [\#25](https://github.com/alexec/docker-maven-plugin/issues/25)
257 |
258 | **Fixed bugs:**
259 |
260 | - Can not instantiate value of type \[simple type, class com.alexecollins.docker.orchestration.model.Packaging\] from String value \(''\); no single-String constructor/factory method [\#35](https://github.com/alexec/docker-maven-plugin/issues/35)
261 |
262 | **Merged pull requests:**
263 |
264 | - Allow Docker certificate path to be specified for remote Docker daemon running behind https [\#42](https://github.com/alexec/docker-maven-plugin/pull/42) ([Freaky-namuH](https://github.com/Freaky-namuH))
265 | - Add validate Dockerfile in the docker maven plugin [\#41](https://github.com/alexec/docker-maven-plugin/pull/41) ([Dufgui](https://github.com/Dufgui))
266 |
267 | ## [docker-maven-plugin-2.3.1](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.3.1) (2015-01-17)
268 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.3.0...docker-maven-plugin-2.3.1)
269 |
270 | ## [docker-maven-plugin-2.3.0](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.3.0) (2014-12-20)
271 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.2.0...docker-maven-plugin-2.3.0)
272 |
273 | **Implemented enhancements:**
274 |
275 | - Pushing to private registries? [\#28](https://github.com/alexec/docker-maven-plugin/issues/28)
276 |
277 | **Fixed bugs:**
278 |
279 | - Cannot assign configuration entry 'host' to 'class java.net.URI' [\#34](https://github.com/alexec/docker-maven-plugin/issues/34)
280 |
281 | **Closed issues:**
282 |
283 | - Expose container ip address as maven properties [\#37](https://github.com/alexec/docker-maven-plugin/issues/37)
284 | - Unfiltered file URI used when building image [\#33](https://github.com/alexec/docker-maven-plugin/issues/33)
285 |
286 | **Merged pull requests:**
287 |
288 | - expose ip address as maven properties [\#38](https://github.com/alexec/docker-maven-plugin/pull/38) ([changgengli](https://github.com/changgengli))
289 | - Update USAGE.md [\#36](https://github.com/alexec/docker-maven-plugin/pull/36) ([oadam](https://github.com/oadam))
290 |
291 | ## [docker-maven-plugin-2.2.0](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.2.0) (2014-11-16)
292 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.1.0...docker-maven-plugin-2.2.0)
293 |
294 | **Fixed bugs:**
295 |
296 | - Multipart upload for build is no longer supported [\#16](https://github.com/alexec/docker-maven-plugin/issues/16)
297 |
298 | **Closed issues:**
299 |
300 | - request: support use of $DOCKER\_HOST environment variable [\#31](https://github.com/alexec/docker-maven-plugin/issues/31)
301 | - client and server don't have same version \(client : 2.1, server: 1.14\) [\#29](https://github.com/alexec/docker-maven-plugin/issues/29)
302 |
303 | ## [docker-maven-plugin-2.1.0](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.1.0) (2014-10-14)
304 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.0.2...docker-maven-plugin-2.1.0)
305 |
306 | **Fixed bugs:**
307 |
308 | - docker:clean does not remove image [\#14](https://github.com/alexec/docker-maven-plugin/issues/14)
309 |
310 | **Closed issues:**
311 |
312 | - Alias not possible when linking container [\#26](https://github.com/alexec/docker-maven-plugin/issues/26)
313 | - Docker Image doesn't get tagged properly [\#23](https://github.com/alexec/docker-maven-plugin/issues/23)
314 |
315 | ## [docker-maven-plugin-2.0.2](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.0.2) (2014-10-13)
316 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.0.1...docker-maven-plugin-2.0.2)
317 |
318 | ## [docker-maven-plugin-2.0.1](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.0.1) (2014-10-13)
319 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-2.0.0...docker-maven-plugin-2.0.1)
320 |
321 | ## [docker-maven-plugin-2.0.0](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-2.0.0) (2014-09-20)
322 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-1.4.0...docker-maven-plugin-2.0.0)
323 |
324 | **Implemented enhancements:**
325 |
326 | - Support disabling of cache during build [\#15](https://github.com/alexec/docker-maven-plugin/issues/15)
327 |
328 | **Fixed bugs:**
329 |
330 | - Tagging problems [\#18](https://github.com/alexec/docker-maven-plugin/issues/18)
331 |
332 | **Closed issues:**
333 |
334 | - recommended to use docker-java [\#22](https://github.com/alexec/docker-maven-plugin/issues/22)
335 | - NPE when running 'mvn -Prun-its verify` [\#17](https://github.com/alexec/docker-maven-plugin/issues/17)
336 |
337 | **Merged pull requests:**
338 |
339 | - Fixed typos in README.md [\#20](https://github.com/alexec/docker-maven-plugin/pull/20) ([pnuz3n](https://github.com/pnuz3n))
340 |
341 | ## [docker-maven-plugin-1.4.0](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-1.4.0) (2014-08-02)
342 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-1.3.1...docker-maven-plugin-1.4.0)
343 |
344 | **Fixed bugs:**
345 |
346 | - Binary garbage on standard output of docker:install under Maven 3 [\#13](https://github.com/alexec/docker-maven-plugin/issues/13)
347 |
348 | ## [docker-maven-plugin-1.3.1](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-1.3.1) (2014-07-29)
349 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-1.3.0...docker-maven-plugin-1.3.1)
350 |
351 | **Closed issues:**
352 |
353 | - tagging images [\#10](https://github.com/alexec/docker-maven-plugin/issues/10)
354 | - Unrecognized field "Paused" [\#9](https://github.com/alexec/docker-maven-plugin/issues/9)
355 |
356 | ## [docker-maven-plugin-1.3.0](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-1.3.0) (2014-07-16)
357 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-1.1.0...docker-maven-plugin-1.3.0)
358 |
359 | **Implemented enhancements:**
360 |
361 | - Add parameter to control removal of intermediate containers when building an image [\#8](https://github.com/alexec/docker-maven-plugin/issues/8)
362 |
363 | **Fixed bugs:**
364 |
365 | - healthCheck --\> healthChecks and ping --\> pings [\#11](https://github.com/alexec/docker-maven-plugin/issues/11)
366 |
367 | **Closed issues:**
368 |
369 | - Include a "skip" config option [\#12](https://github.com/alexec/docker-maven-plugin/issues/12)
370 | - Logging output during build [\#6](https://github.com/alexec/docker-maven-plugin/issues/6)
371 |
372 | **Merged pull requests:**
373 |
374 | - File copy uses working directory [\#7](https://github.com/alexec/docker-maven-plugin/pull/7) ([oillio](https://github.com/oillio))
375 |
376 | ## [docker-maven-plugin-1.1.0](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-1.1.0) (2014-06-01)
377 | [Full Changelog](https://github.com/alexec/docker-maven-plugin/compare/docker-maven-plugin-1.0.0...docker-maven-plugin-1.1.0)
378 |
379 | **Closed issues:**
380 |
381 | - Deploy to Maven central [\#3](https://github.com/alexec/docker-maven-plugin/issues/3)
382 |
383 | ## [docker-maven-plugin-1.0.0](https://github.com/alexec/docker-maven-plugin/tree/docker-maven-plugin-1.0.0) (2014-05-24)
384 | **Merged pull requests:**
385 |
386 | - Fix up logging to prevent logging of binary files [\#5](https://github.com/alexec/docker-maven-plugin/pull/5) ([lhallowes](https://github.com/lhallowes))
387 | - Parameterise the source folder location [\#4](https://github.com/alexec/docker-maven-plugin/pull/4) ([vlfig](https://github.com/vlfig))
388 | - New copy directory to Directory logic + using Alexec's versions of docker-java [\#2](https://github.com/alexec/docker-maven-plugin/pull/2) ([djsly](https://github.com/djsly))
389 | - Minor typos and Trivial Example [\#1](https://github.com/alexec/docker-maven-plugin/pull/1) ([alrighttheresham](https://github.com/alrighttheresham))
390 |
391 |
392 |
393 | \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
--------------------------------------------------------------------------------
/CODE_COVERAGE.md:
--------------------------------------------------------------------------------
1 | # Code Coverage Report generation
2 |
3 | To generate the code coverage report, execute the following command:
4 | > mvn clean verify
5 |
6 | This will generate code coverage report. In order to view it, open the following file in your browser
7 | > target/site/cobertura/index.html
8 |
--------------------------------------------------------------------------------
/COMPETITORS.md:
--------------------------------------------------------------------------------
1 | Competitors
2 | ---
3 |
4 | Why should you use this one in preference to other plugins?
5 |
6 | * Avoids XML configuration, uses YAML similar to Fig (aka Docker Compose) so should be easier to learn.
7 | * Uses docker-java under the hood, so is up to date with latest Docker APIs.
8 | * Will support Gradle and Ant builds.
9 | * Focused on building and testing containers.
10 | * Automatically sets up Boot2Docker port forwarding.
11 |
12 | Plugin | Stars | Forks
13 | --------------------------------------------------------- | ----- | -----
14 | [https://github.com/spotify/docker-maven-plugin] | 448 | 141
15 | [https://github.com/fabric8io/docker-maven-plugin] | 345 | 143
16 | [https://github.com/alexec/docker-maven-plugin] | 84 | 39
17 | [https://github.com/wouterd/docker-maven-plugin] | 67 | 24
18 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Contributing
2 | ===
3 |
4 | Get the code:
5 |
6 | git clone https://github.com/alexec/docker.git
7 | cd docker
8 | git submodule update --checkout
9 |
10 | Now build:
11 |
12 | mvn install -Prun-its
13 |
14 |
--------------------------------------------------------------------------------
/DEBUG.md:
--------------------------------------------------------------------------------
1 | Debugging
2 | ===
3 | Docker caches images aggressively, but it can cache problematic images. Try to disable it, especially on your CI server (when run time might be less of an issue):
4 |
5 | false
6 |
7 | Or temporarily using:
8 |
9 | mvn -Ddocker.cache=false
10 |
11 | You can see detailed JSON output using -X
12 |
13 | mvn -X
14 |
15 | `docker:start` can be started manually like this:
16 |
17 | docker run -t -i -link example-project_mysql:db -P -p 8080:8080 $USER/example-project_app:1.0.0-SNAPSHOT
18 |
19 | You can see the requests made to Docker using Wireshark. However, if you're using boot2docker, it'll be on a local loop-back interface.
20 |
21 | It can be useful to see what's running, and `watch` will help you:
22 |
23 | watch docker ps
24 |
25 | You can tail the Docker logs, e.g.
26 |
27 | ```
28 | boot2docker ssh
29 | tail -f /var/log/docker.log
30 | ```
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/alexec/docker-maven-plugin)
2 | [](https://circleci.com/gh/alexec/docker-maven-plugin)
3 |
4 |
5 | **WARNING!!! This project is no longer actively maintained. Please see [this ticket](https://github.com/alexec/docker-maven-plugin/issues/118) for reasons and alternatives.**
6 |
7 |
8 | Docker Maven Plugin
9 | ===
10 |
11 | This project aims to make it it easy to build an app on a container, test it and push it to a Docker repository, even if it relies on other containers (e.g. a database).
12 | We tend to talk "Maven" rather than "Docker" (E.g. "package" rather than "build"). And we like to keep it simple.
13 |
14 | * Do you want to know how to [get started](USAGE.md)?
15 | * [Having problems](DEBUG.md)?
16 | * What to get [involved or add features](CONTRIBUTING.md)?
17 | * What to know what's [changed recently](CHANGELOG.md)?
18 |
19 | Using another tool? I have an [Ant version](https://github.com/alexec/docker-ant-tasks), and a [Gradle version](https://github.com/alexec/docker-gradle-plugin) (SBT coming soon...).
20 |
21 |
24 |
--------------------------------------------------------------------------------
/USAGE.md:
--------------------------------------------------------------------------------
1 | Usage
2 | ===
3 | Goals
4 | ---
5 | * `clean` - delete all containers and images for the project
6 | * `validate` - validate the format of Dockerfile
7 | * `package` - builds the containers based on YAML configuration
8 | * `start` - start the containers in order and ensures they are running
9 | * `stop` - stop all running containers for the project
10 | * `deploy` - push containers to Docker repository
11 | * `copy` - copy resources from a Docker container
12 | * `save` - save images to file, optionally deploy to Maven repository
13 | * `log` - save logs.
14 |
15 | Pre-requisites
16 | ---
17 | Docker installed and Docker daemon running, see the docker [getting started guide](https://www.docker.io/gettingstarted/) for e.g. on a mac follow these [instructions](http://docs.docker.io/en/latest/installation/mac/).
18 |
19 | Examples
20 | ---
21 |
22 | * [Selenium Visual Testing](https://github.com/alexec/selenium-visual-testing)
23 | * [Search In A Box](https://github.com/alexec/search-in-a-box)
24 |
25 | Usage
26 | ---
27 | The best example to look at is the [one from the tests](src/it/build-test-it) which creates a [Drop-Wizard](https://dropwizard.github.io/dropwizard/) app and builds three containers: __app__ (the dropwizard application) __data__ and __mysql__, and then runs an integration test against the deployed app. Et voila a packaged image!
28 |
29 | Typically, you build your app, run your standard unit tests and package it as usual. Then, you build a container with your app deployed onto it, and run integration tests against it. If they pass, deploy your jar into the Maven repository, and optionally, your image into a Docker repository.
30 |
31 | To use the plugin, you need to define a `docker/` directory in `${basedir}/src/main` which will include a subdirectory for each container that you wish to deploy.
32 |
33 | - `src/main/docker/` contains one folder per container for e.g. the mysql container would have a folder structure as follows:
34 | - mysql
35 | - `Dockerfile` a standard Docker file.
36 | - `conf.yml` configuration:
37 | - ...
38 | - `Dockerfile` a standard Docker file.
39 | - `conf.yml` configuration:
40 |
41 | ```yml
42 | # additional data require to create the Docker image
43 | packaging:
44 | # files to add to the build, usually used with ADD in the Dockerfile
45 | add:
46 | - target/example-${project.version}.jar
47 | # you can also disable filtering
48 | - path: hello-world.yml
49 | filter: false
50 | # optional list of port to expose on the host
51 | ports:
52 | - 8080
53 | # If you want a different host port used, where the former is the exposed port and the latter the container port.
54 | - 8001 1802
55 | # containers that this should be linked to, started before this one and stopped afterwards, optional alias after colon
56 | links:
57 | - mysql:db
58 | healthChecks:
59 | pings:
60 | # check this URL for 200 OK
61 | - https://localhost:8446/info
62 | # check another URL with non-default time out, with a pattern, and non checking SSL certificates
63 | - url: https://localhost:8446/info
64 | timeout: 60000
65 | pattern: pattern that must be in the body of the return value
66 | sslVerify: false
67 | logPatterns:
68 | - pattern that must be in log file
69 | - pattern: another pattern with non-default timeout
70 | timeout: 30000
71 | # how long in milliseconds to sleep after start-up (default 0), note health checks are usually faster and more reliable
72 | sleep: 1000
73 | # log failures (default true, 10)
74 | logOnFailure: true
75 | maxLogLines: 10
76 | # volumes to mount from other containers
77 | volumesFrom: busybox
78 | # volume to map
79 | volumes:
80 | # dir in image to host dir
81 | /mnt/target: target/docker
82 | # if this should be enabled (default true)
83 | enabled: true
84 | # expose the container's IP (see below)
85 | exposeContainerIp: true
86 | # tag to use for images
87 | tag: alex.e.c-app:${project.artifactId}-${project.version}
88 | # or multiple tags
89 | tags:
90 | - alex.e.c-app:${project.artifactId}-${project.version}
91 | # Run the container in privileged mode (default false)
92 | privileged: false
93 | container:
94 | # a name for the container (if omitted, we will create an artifical one)
95 | name: theName
96 | ```
97 |
98 | If you only want to use another image as a build dependency, you can provide a simple `Dockerfile` with just the image, e.g.
99 |
100 | ```
101 | FROM mysql
102 | ```
103 |
104 | Add the following to the `pom.xml` plugins section.
105 |
106 | ```xml
107 |
108 | com.alexecollins.docker
109 | docker-maven-plugin
110 |
111 |
112 |
113 | 1.13
114 |
115 | alexec
116 | password
117 | alex.e.c@gmail.com
118 | https://index.docker.io/v1/
119 |
120 | http://localhost:2375
121 |
122 | ${user.home}/.docker
123 |
124 | false
125 |
126 | true
127 |
128 | app,other
129 |
130 | true
131 |
132 | false
133 |
134 | target/docker
135 |
136 | false
137 |
138 | false
139 |
140 |
141 |
142 |
143 | com.alexecollins.docker
144 | docker-java-orchestration-plugin-boot2docker
145 | ???
146 |
147 |
148 |
149 | ```
150 |
151 | Note: we default to HTTPS. However, on Linux the default is un-secured HTTP. Try `http://localhost:2375`.
152 |
153 | There are other [configuration options](https://github.com/docker-java/docker-java#configuration), including via system environment here, which might be preferable if you have a number of builds using the plugin.
154 |
155 | Create your `${basedir}/src/main/docker` directory and create a subfolder for your application container
156 |
157 | mkdir -p src/main/docker/app
158 |
159 | Define your Dockerfile and conf.yml and place in ${basedir}/src/main/docker/app
160 |
161 | ```tree
162 | src/main/docker/app
163 | ├── Dockerfile
164 | └── conf.yml
165 | ```
166 |
167 | You can now invoke functionality from the plugin, information on the plugin can be found by running the following command
168 |
169 | mvn docker:help
170 |
171 | For e.g. to build containers from their `Dockerfile` and `conf.yml` files, run the following command
172 |
173 | mvn docker:package
174 |
175 | Expose container IP as maven properties
176 | ---
177 |
178 | By default, the container ip will be exposed as maven properties. This would be helpful for integration test as it doesn't require bind the exposed port of container to a well know port of the host.
179 |
180 | The property name is `docker.` + directory name of each Dockerfile + `.ipAddress`. For example, by configuring `maven-failsafe-plugin` in the following way:
181 |
182 | ```
183 |
184 | maven-failsafe-plugin
185 | 2.14.1
186 |
187 |
188 | ${docker.app.ipAddress}
189 |
190 |
191 |
192 |
193 |
194 | integration-test
195 | verify
196 |
197 |
198 |
199 |
200 | ```
201 |
202 | In the test, the ip address can be obtained by:
203 |
204 |
205 | ```
206 | String host = System.getProperty("example.app.ip");
207 | ```
208 |
209 | We can also use the container ip address for health check. This can be done by using `__CONTAINER.IP__` as a placeholder in the pings url. For example:
210 |
211 |
212 | ```yml
213 | healthChecks:
214 | pings:
215 | - url: http://__CONTAINER.IP__:8080/hello-world
216 | timeout: 60000
217 |
218 | ```
219 |
220 | This can be turned off by set `exposeContainerIp` to `false` in `conf.yml`
221 |
222 | Copy resources from a docker container
223 | ---
224 |
225 | The copy command allows you to extract resources from your docker container, allowing you to use docker as a build engine from within maven.
226 | The resources to copy are specified by `source` and the location to copy to by `dest`. If `source` is a directory then the directory
227 | contents will be copied. `dest` can be a file or directory, if a directory then the resource names will be preserved.
228 |
229 |
230 |
--------------------------------------------------------------------------------
/circle.yml:
--------------------------------------------------------------------------------
1 | machine:
2 | pre:
3 | - wget https://github.com/alexec/circleci/archive/1.0.6.tar.gz
4 | - tar -xvf 1.0.6.tar.gz
5 | - ./circleci-1.0.6/install.sh $CIRCLE_PROJECT_REPONAME
6 | - $CIRCLE_PROJECT_REPONAME/circle.sh pre_machine
7 | post:
8 | - $CIRCLE_PROJECT_REPONAME/circle.sh post_machine
9 | services:
10 | - docker
11 | environment:
12 | DOCKER_HOST: tcp://127.0.0.1:2376
13 | DOCKER_CERT_PATH: $HOME/.docker
14 | DOCKER_TLS_VERIFY: 1
15 | dependencies:
16 | override:
17 | - mvn dependency:resolve -s settings.xml
18 | test:
19 | override:
20 | - sudo service mysql stop
21 | - mvn deploy -Prun-its -s settings.xml
22 | - cat target/it/port-setup-it/docker.ps
23 | post:
24 | - mkdir -p $CIRCLE_TEST_REPORTS/junit/
25 | - find . -type f -regex ".*/target/.*-reports/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;
26 | deployment:
27 | staging:
28 | branch: master
29 | commands:
30 | - ./circle.sh start_build drop-wizard-in-a-box
31 | - ./circle.sh start_build search-in-a-box
32 | - ./circle.sh start_build selenium-visual-testing
33 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 |
5 | org.sonatype.oss
6 | oss-parent
7 | 7
8 |
9 |
10 | com.alexecollins.docker
11 | docker-maven-plugin
12 | 2.11.25-SNAPSHOT
13 | maven-plugin
14 |
15 | Docker Maven Plugin
16 |
17 | A plug-in for starting and stopping Docker containers.
18 |
19 | https://github.com/alexec/docker-maven-plugin
20 |
21 |
22 |
23 | The Apache Software License, Version 2.0
24 | http://www.apache.org/licenses/LICENSE-2.0.txt
25 | repo
26 |
27 |
28 |
29 |
30 |
31 | alex.collins
32 | Alex Collins
33 | alex.e.c@gmail.com
34 |
35 |
36 |
37 |
38 | scm:git:git@github.com:alexec/docker-maven-plugin.git
39 | scm:git:git@github.com:alexec/docker-maven-plugin.git
40 | git@github.com:alexec/docker-maven-plugin.git
41 | HEAD
42 |
43 |
44 |
45 | GitHub
46 | https://github.com/alexec/docker-maven-plugin/issues/
47 |
48 |
49 |
50 | travis
51 | https://travis-ci.org/alexec/docker-maven-plugin
52 |
53 |
54 |
55 | UTF-8
56 | 1.6.1
57 | 1.6.3
58 |
59 |
60 |
61 |
62 | org.slf4j
63 | slf4j-api
64 | ${slf4j.version}
65 |
66 |
67 | org.slf4j
68 | jul-to-slf4j
69 | ${slf4j.version}
70 |
71 |
72 | org.slf4j
73 | jcl-over-slf4j
74 | ${slf4j.version}
75 |
76 |
77 | org.slf4j
78 | log4j-over-slf4j
79 | ${slf4j.version}
80 |
81 |
82 | ch.qos.logback
83 | logback-classic
84 | 1.1.3
85 |
86 |
87 |
88 | com.alexecollins.docker
89 | docker-java-orchestration-core
90 | 2.11.30-SNAPSHOT
91 |
92 |
93 |
94 | org.apache.maven
95 | maven-plugin-api
96 | 3.3.1
97 |
98 |
99 | org.apache.maven
100 | maven-project
101 | 2.0.6
102 |
103 |
104 | log4j
105 | log4j
106 |
107 |
108 |
109 |
110 | org.apache.maven.plugin-tools
111 | maven-plugin-annotations
112 | 3.4
113 | provided
114 |
115 |
116 | org.codehaus.plexus
117 | plexus-utils
118 | 3.0.22
119 |
120 |
121 | junit
122 | junit
123 | 4.12
124 | test
125 |
126 |
127 | org.apache.maven
128 | maven-artifact
129 | 2.0.6
130 | provided
131 |
132 |
133 |
134 |
135 | org.powermock
136 | powermock-module-junit4
137 | ${powermock.version}
138 | test
139 |
140 |
141 | org.powermock
142 | powermock-api-mockito
143 | ${powermock.version}
144 | test
145 |
146 |
147 |
148 |
149 |
150 |
151 | org.codehaus.mojo
152 | cobertura-maven-plugin
153 | 2.7
154 |
155 |
156 | true
157 |
158 |
159 | html
160 |
161 | ${project.build.directory}/site/cobertura
162 |
163 | true
164 |
165 | **/HelpMojo.class
166 |
167 |
168 |
169 |
170 |
171 | package
172 |
173 | cobertura
174 |
175 |
176 |
177 |
178 |
179 | maven-enforcer-plugin
180 | 1.3.1
181 |
182 |
183 | enforce
184 |
185 | enforce
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 | commmons-logging:commons-logging
194 | org.testng:testng
195 | log4j:log4j
196 |
197 |
198 |
199 | 1.7.0
200 |
201 |
202 |
203 |
204 |
205 | maven-compiler-plugin
206 | 3.1
207 |
208 | 1.7
209 | 1.7
210 |
211 |
212 |
213 | maven-deploy-plugin
214 | 2.8.1
215 |
216 |
217 | org.apache.maven.plugins
218 | maven-plugin-plugin
219 | 3.2
220 |
221 | docker
222 | true
223 |
224 |
225 |
226 | mojo-descriptor
227 |
228 | descriptor
229 |
230 |
231 |
232 | help-goal
233 |
234 | helpmojo
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 | run-its
244 |
245 |
246 |
247 | org.apache.maven.plugins
248 | maven-invoker-plugin
249 | 1.7
250 |
251 | false
252 | true
253 | true
254 | ${project.build.directory}/it
255 |
256 | built-test-it/pom.xml
257 | port-setup-it/pom.xml
258 |
259 | verify
260 | ${project.build.directory}/local-repo
261 | src/it/settings.xml
262 |
263 | clean
264 | install
265 |
266 |
267 |
268 |
269 | integration-test
270 |
271 | integration-test
272 | verify
273 | install
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
--------------------------------------------------------------------------------
/src/it/auth-config-it/dockercfg:
--------------------------------------------------------------------------------
1 | {
2 | "localhost:5443": {
3 | "auth": "cmVnaXN0cnk6cmVnaXN0cnk=",
4 | "email": "nobody@nowhere.com"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/src/it/auth-config-it/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | auth-config-it
7 | auth-config-it
8 | 1.0-SNAPSHOT
9 |
10 |
11 | UTF-8
12 |
13 |
14 |
15 |
16 |
17 | @project.groupId@
18 | @project.artifactId@
19 | @project.version@
20 |
21 |
22 | true
23 |
24 |
25 |
26 | default-cli
27 |
28 | help
29 | clean
30 | start
31 | stop
32 | validate
33 | package
34 |
35 |
36 |
37 | push
38 | integration-test
39 |
40 | dockercfg
41 | nginx,registry
42 |
43 |
44 | true
45 |
46 |
47 | deploy
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/src/it/auth-config-it/src/main/docker/app/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM java:7
2 |
--------------------------------------------------------------------------------
/src/it/auth-config-it/src/main/docker/app/conf.yml:
--------------------------------------------------------------------------------
1 | tag: localhost:5443/registry/${project.artifactId}-app:${project.version}
2 |
--------------------------------------------------------------------------------
/src/it/auth-config-it/src/main/docker/nginx/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM marvambass/nginx-registry-proxy
2 |
3 | ADD external/ /etc/nginx/external/
4 |
5 | ENV DH_SIZE 128
6 |
--------------------------------------------------------------------------------
/src/it/auth-config-it/src/main/docker/nginx/conf.yml:
--------------------------------------------------------------------------------
1 | ports:
2 | - 5443 443
3 |
4 | links:
5 | - registry
6 | healthChecks:
7 | logPatterns:
8 | - "start worker processes"
--------------------------------------------------------------------------------
/src/it/auth-config-it/src/main/docker/nginx/external/cert.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIIFnDCCA4WgAwIBAgIJAPT1jI+yvThfMA0GCSqGSIb3DQEBCwUAMGYxCzAJBgNV
3 | BAYTAkRFMQ8wDQYDVQQIDAZCZXJsaW4xDzANBgNVBAcMBkJlcmxpbjEhMB8GA1UE
4 | CgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRIwEAYDVQQDDAlsb2NhbGhvc3Qw
5 | HhcNMTUwNTE5MTI1MjQ3WhcNMjUwNTE2MTI1MjQ3WjBmMQswCQYDVQQGEwJERTEP
6 | MA0GA1UECAwGQmVybGluMQ8wDQYDVQQHDAZCZXJsaW4xITAfBgNVBAoMGEludGVy
7 | bmV0IFdpZGdpdHMgUHR5IEx0ZDESMBAGA1UEAwwJbG9jYWxob3N0MIICIDANBgkq
8 | hkiG9w0BAQEFAAOCAg0AMIICCAKCAf8yDQ4NGfvs7YVJHcPWceVcCCe870uQH+Uz
9 | vgLjdpJIBdLJmaRGnQtXCQhrLb0yZR31Nxc4MgsPMJcxN7FxyZwPCcvNkuG8Hu7I
10 | pouzn6OHXhguVyciDjNOoHdNY+gA7CgC+n3PNMxZvzJcnKWVSdbr8ZxutssF4glk
11 | t+wOu4nyIXBlg8gK5HNiia31k5rA71jF3W6laKEElxRWoCv3LTAvFTdbcFrBQmMq
12 | DARf6pEqqoewmXgA0iMdWlJd0YV9DtCC294VXqq9oPxaIpRyUoq4orGXnsXh4DcG
13 | g/7lhH6AUTls0vDI827kxJI182Pwd0pBfFCFK6s1BV6ZeFFwnAxpWjMtowJ8O93f
14 | CONIt3DWycnX48jstF4ZowxnkpF3hBxFuPaL967aNDZzZSirnncuQsBm5TY5GMpO
15 | MPfR45x/Z0dAVM/jRlCy7/EitNncs0ADEC6CIzr/ZHxAwnE5h0NV6zXexX496oQ8
16 | 9oyUlNj0XS5XHGlyFtHnHUK++mN37FSTGuVnLOy7oPvV/t9rY1wjJqeCfry6fk3U
17 | 80InyZMxYmojII9cl7IyjhUkJ0xxlhwqu4ySQrdmIn/KX/tG5UXz8xefTpsEzPS/
18 | jDaiCW4l38BTDA7Ix45A6cMUSpHEeSC2xGpT5yGlxO1W5h9wkb7V7VTjhjOIV/va
19 | 5+3HP2wbAgMBAAGjUDBOMB0GA1UdDgQWBBR5wM4cgchr8xNhtUV871Ofy9ajzDAf
20 | BgNVHSMEGDAWgBR5wM4cgchr8xNhtUV871Ofy9ajzDAMBgNVHRMEBTADAQH/MA0G
21 | CSqGSIb3DQEBCwUAA4ICAAARFses6jr2LiCa5G7sauAeOWHQZCBzxhRA1R6rIH/E
22 | 2Mwbu5d/+TbvcKjBopBGwL/g00Ia64my6cXviMoeFEq5sAKr6FMlvdb3g3Y6FpV1
23 | +AGJnh+aC9mZL/jKOcEVOVfCBgHctAj7ps2Vz7TyifFESNCZyRSMSK9lvD81pRfV
24 | F7RIwulzlmy1qATJLd4N5xrePBywxjKQ21hPdJGDNgRWqRQdfOigqqwntFTqzsaH
25 | CyXbbUfiKhOOCGezRkqYGh9Hf+XcBkrXWuzTxZwPjp3WPW/6ejelnGQNN6/4zm+o
26 | ZrmUKbGXy5vqiUjx6YvBFSXaZGuhnQlR3RPf4Pq9a6Ct1EGOP9NycBW8G0cJcV3O
27 | BVHo5tobsdQdpnyWFf2Nsb2dTvJeLBc1Dm5kxFWGmVyh8J4bktcP6qTMK6sLn6iw
28 | gGWQ5LhZur5na9X4MzciF5dws9Xh8RIF4HKY4/hOZSt3c7B3mn9E7YKckX5x4JHE
29 | CVmgnDCijelVe9yg/6S+6PDKzmFW36VYAaGIREaUxO03Zd8QEEBngi0Y4/4bKgnP
30 | UZ3/z5oeMHbKo1mVSAuEWxZ2Y7aZlPixnctnneLonMu8wTCS3lVMvSGTZkyQHe0x
31 | 0t4tXqwcCs14wbk4LBljfrms9+hSv67dgN7BLYbUejr1tmdKNwthsWYtFnGtuUru
32 | -----END CERTIFICATE-----
33 |
--------------------------------------------------------------------------------
/src/it/auth-config-it/src/main/docker/nginx/external/docker-registry.htpasswd:
--------------------------------------------------------------------------------
1 | registry:$apr1$N/cMLJfc$483vq2tUXvf50xmUzkKrR0
2 |
--------------------------------------------------------------------------------
/src/it/auth-config-it/src/main/docker/nginx/external/key.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN PRIVATE KEY-----
2 | MIIJPAIBADANBgkqhkiG9w0BAQEFAASCCSYwggkiAgEAAoIB/zINDg0Z++zthUkd
3 | w9Zx5VwIJ7zvS5Af5TO+AuN2kkgF0smZpEadC1cJCGstvTJlHfU3FzgyCw8wlzE3
4 | sXHJnA8Jy82S4bwe7simi7Ofo4deGC5XJyIOM06gd01j6ADsKAL6fc80zFm/Mlyc
5 | pZVJ1uvxnG62ywXiCWS37A67ifIhcGWDyArkc2KJrfWTmsDvWMXdbqVooQSXFFag
6 | K/ctMC8VN1twWsFCYyoMBF/qkSqqh7CZeADSIx1aUl3RhX0O0ILb3hVeqr2g/Foi
7 | lHJSiriisZeexeHgNwaD/uWEfoBROWzS8MjzbuTEkjXzY/B3SkF8UIUrqzUFXpl4
8 | UXCcDGlaMy2jAnw73d8I40i3cNbJydfjyOy0XhmjDGeSkXeEHEW49ov3rto0NnNl
9 | KKuedy5CwGblNjkYyk4w99HjnH9nR0BUz+NGULLv8SK02dyzQAMQLoIjOv9kfEDC
10 | cTmHQ1XrNd7Ffj3qhDz2jJSU2PRdLlccaXIW0ecdQr76Y3fsVJMa5Wcs7Lug+9X+
11 | 32tjXCMmp4J+vLp+TdTzQifJkzFiaiMgj1yXsjKOFSQnTHGWHCq7jJJCt2Yif8pf
12 | +0blRfPzF59OmwTM9L+MNqIJbiXfwFMMDsjHjkDpwxRKkcR5ILbEalPnIaXE7Vbm
13 | H3CRvtXtVOOGM4hX+9rn7cc/bBsCAwEAAQKCAf8B4345PlbETP4vkSD3sZqPC3u8
14 | ZGc8jAeRGUVwoePJNfcLRnHtfDWWVi/sI3C1Ox2TSD3nD/Rc4V+DKu/WNF5gLuVy
15 | 320HNT+bcLVq1MZN8F4HOaCvZ0vGVsXJtNBnYIHuAtfGft6LMGzNE9gntv6WLqrR
16 | frJQiYQDOfF9aNQ+v8ZG/l8JEi/McxeOYcCAMUfvR3jKYxVYX/8Teb3O+PSNgkZx
17 | e97g1gl557QujmJl8sNmBZSCq2tJy0O6aJKZ8nopxfQuaEEXIMEFAbMKUVUMvI7p
18 | AsPCzzwkUczHimVfoDEDiz4sxwrTNRuzT3jg9Q9nQzKio9A1EvvL3L9t+WV59vin
19 | H3m1/g2MfBX9JDzL3DLq1m5llMQXGQzDH1IcTeBbWvYV6oOvyR9IM8lD285JqxPl
20 | X90scEXvNVm1uHMSWpD/5HavQyKs/J9s8O643Zu6fGg/GGG7wBG7rr2ejr1sp812
21 | ZVVofKbh6gtalW0FwVJVw3x8sGUFszkk3S981IoCTsHvMpFDQSl6Tv6olCSAuR2j
22 | se6vlizYSdXi7cn7DFJk2NNFYDM5K4zJVqaX3NCzwFSczgNWImka3DVT5UkxI7JS
23 | U5vaR7dq9JCsaYpMYenaXyZD6tcg1n9M8xFufxMBASVlHL15SU0xZZZWFk7Juoz+
24 | 3cROEpasgJQqYWjBAoIBAAfC/+e9iwX1JIcQVdMG/mI8LBFoLJoq3I78uRFoHaDW
25 | xM405zeg7e2S0CQKhMrS93u2w1hONDa758kVL4eIxMlRWhKAtiB06eS86S8utv2O
26 | 2n1WERGJdGZUHnwIiyUt54ShbGZ2KRtIGiGz5LUYP/R4ORUomMxCGETvnNT5IXaY
27 | lDjIFtpXQcmIo5UyysDIIxYfz6p9CC4/PW2qGcua1dF49lntu1u1enmr9Pi6JKPd
28 | gdluF2T0ZBG8h4rvgKaEYXgFTrtvcMDSi+7E2xS1wkHsCfYN2RCdeF9bhDr+lH0z
29 | 6HrW6FRQYnsy1jsB1jwVVE3pBTrutVVE/RPO1zdoOOECggEABnLNMczzOJqe/pG1
30 | zuX46kDuuP1LXrxDjGUfqcy+ng3bA6VzVyzetNqjWhzlIZcAArxF4widJsFCOWhK
31 | Z7zKyrkjRXx29KD2KkypLIZ7TAJHFAzag+S9lAMQ4VoChBx98AJzbQwrb6VGVYxv
32 | s4OtejeOWhcxNkA06eQQHVDTp0OEBIf9csy3smM3SSIbivNO6Da8BFtP+mdkNH3U
33 | iO+aZwX6PQMymRwgL29UJbAJAXAU7YIB2Au/sqA5vyXtNcuByZQxpd8lg+SzsWog
34 | V5Qxb8hq3n5nFy7XszflrG904wM6FtpQzPRer03Sgfu1aj+p++wDUpfJKcTDCddI
35 | +rcYewKCAQADoughujuX3vHuFUkgRPaJL4e14AiFce9DTkOmVBENeZFayo5JEaxm
36 | 0ZGSURtFqvEnlMiQZpMv0XkWTEaoSPtpFiQM5yBstFmgQKE+6bPxtyvF7LyyaqOO
37 | DXr6wUXvdUIycS5IErPPhEg54f4UmffcoTadIxfzGkQkh94CKXX0CifnMlcClD7O
38 | HKYHEHTNPPazNtQkG8/pWtd8uWS8bx4dtX41Q5uzq6JlvppWrV7dJrnfFCUBtz3q
39 | 0VjvTqYHXZ4MjPAGAH/i1sGYa8H4Qe9w0xUXogVAM4Zhpo6c1QjcX6VbZ7QRTFfX
40 | QEn9+y5Tl+qXVcSNh6iM+nVXAmDyJHIBAoIBAAIxW9HJjhP7kIGk7xxSW9jdB9Dk
41 | YZLvllDRuni1ZUS+FXIh+xzz5y+9AbuNA+XuQVSszV8s+LPLGEgJTPQF4TgayQHC
42 | F3mMmuk7dHPtr1PjmmQZEt2zFTyV5lGbmCtwvOq3CqVUdBjdLRO+U+XJq15aMhA0
43 | vsliABxhL5GogLDqZqRb0jYNo5IH5y75aEBSCM0yf7FDk+jk69Bl0bZXNDxAbh39
44 | TmF+jPtUclr2h7lzccpqYVIkfKWzkq+LqCSY9aOkv1VWkp1NUkXMfv8JJ96JWr4a
45 | YdgiV7tcEMAYjrj7ye8ngj6QAvq+Dg2hmMluqNFAKskVUJThkilwiiKnzK0CggEA
46 | AJ7Dk7IqKpTwAb4DiPm5qpQvNz5RGJ3G2e+m5uxBEg/yRE3UnkGtlwJYVbOozyc7
47 | 0ol0YwO/E6fYVsCX6C+5cSe/3HFEQhRDYeNCinTLH934JhZ5VTET6muisBK6pHHl
48 | ruaP3CoRedYIkK7RG9ZOrFrbrr+KAonbIaJgmqKtLFh/OKt+/087whva0oBH/tL/
49 | Ts2Jrv6XFnijPccwT/JzTvhg+WDJotovwa/92j87a8443slfYtP2j808cX+GfeF/
50 | u+oiSD4mx3jpHIRSTOu5XkUkgwxaUx0zY9W9ouKmC8oRGCzV6IVNfmDHS4Irsium
51 | D5yDaBrCxE/ndc/oDorwvQ==
52 | -----END PRIVATE KEY-----
53 |
--------------------------------------------------------------------------------
/src/it/auth-config-it/src/main/docker/registry/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM registry
2 |
3 | ENV SETTINGS_FLAVOR local
4 | ENV STORAGE_PATH /registry
5 |
--------------------------------------------------------------------------------
/src/it/auth-config-it/src/main/docker/registry/conf.yml:
--------------------------------------------------------------------------------
1 | healthChecks:
2 | logPatterns:
3 | - "Listening at"
--------------------------------------------------------------------------------
/src/it/auth-config-it/verify.groovy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexec/docker-maven-plugin/743fa720878eec9acee9b81e053801fbed2b33d7/src/it/auth-config-it/verify.groovy
--------------------------------------------------------------------------------
/src/it/build-test-it/hello-world.yml:
--------------------------------------------------------------------------------
1 | template: Hello, %s!
2 | defaultId: 1
3 | database:
4 | driverClass: com.mysql.jdbc.Driver
5 | user: test
6 | password: test
7 | url: jdbc:mysql://localhost:3306/test
8 | properties:
9 | charSet: UTF-8
10 | hibernate.dialect: org.hibernate.dialect.MySQLDialect
11 | validationQuery: SELECT 1
12 |
--------------------------------------------------------------------------------
/src/it/build-test-it/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | built-test-it
7 | built-test-it
8 | 1.0-SNAPSHOT
9 |
10 |
11 | UTF-8
12 | 0.6.2
13 | 3306
14 |
15 |
16 |
17 |
18 |
19 | org.apache.maven.plugins
20 | maven-jar-plugin
21 | 2.3.2
22 |
23 |
24 |
25 | true
26 |
27 |
28 |
29 |
30 |
31 | org.apache.maven.plugins
32 | maven-shade-plugin
33 | 1.6
34 |
35 | true
36 |
37 |
38 | *:*
39 |
40 | META-INF/*.SF
41 | META-INF/*.DSA
42 | META-INF/*.RSA
43 |
44 |
45 |
46 |
47 |
48 |
49 | package
50 |
51 | shade
52 |
53 |
54 |
55 |
57 |
59 | com.example.helloworld.HelloWorldService
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | @project.groupId@
68 | @project.artifactId@
69 | @project.version@
70 |
71 | registry
72 | registry
73 | nobody@nowhere.com
74 | https://locahost:5443/v1
75 | rubbish
76 |
77 | true
78 | true
79 | true
80 |
81 |
82 |
83 |
84 | default-cli
85 |
86 | help
87 | clean
88 | validate
89 | package
90 | start
91 | stop
92 | save
93 |
94 |
95 |
96 |
98 | push
99 | install
100 |
101 | save
102 |
105 |
106 |
107 |
108 |
109 |
110 | maven-failsafe-plugin
111 | 2.14.1
112 |
113 |
114 | ${docker.app.ipAddress}
115 |
116 |
117 |
118 |
119 |
120 | integration-test
121 | verify
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 | com.yammer.dropwizard
132 | dropwizard-core
133 | ${dropwizard.version}
134 |
135 |
136 | com.yammer.dropwizard
137 | dropwizard-hibernate
138 | ${dropwizard.version}
139 |
140 |
141 | com.yammer.dropwizard
142 | dropwizard-migrations
143 | ${dropwizard.version}
144 |
145 |
146 | mysql
147 | mysql-connector-java
148 | 5.1.35
149 |
150 |
151 |
152 | com.jayway.restassured
153 | rest-assured
154 | 2.4.1
155 | test
156 |
157 |
158 | junit
159 | junit
160 | 4.12
161 | test
162 |
163 |
164 |
165 |
--------------------------------------------------------------------------------
/src/it/build-test-it/src/main/docker/app/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM java:7
2 |
3 | WORKDIR /
4 |
5 | ADD ${project.build.finalName}.jar /
6 | ADD hello-world.yml /
7 | ADD run.sh /
8 |
9 | RUN chmod +x run.sh
10 |
11 | CMD ["./run.sh"]
12 |
13 | EXPOSE 8080
14 | EXPOSE 8081
15 |
--------------------------------------------------------------------------------
/src/it/build-test-it/src/main/docker/app/conf.yml:
--------------------------------------------------------------------------------
1 | # additional data require to create the Docker image
2 | packaging:
3 | # files to add to the build, usually used with ADD in the Dockerfile
4 | add:
5 | # the plugin always filters
6 | - target/${project.build.finalName}.jar
7 | - hello-world.yml
8 | # optional list of port to expose on the host
9 | ports:
10 | - 8080
11 | - 8081
12 | # containers that this should be linked to, started before this one and stopped afterwards
13 | links:
14 | - mysql:db
15 | healthChecks:
16 | pings:
17 | # I use localhost here as I'm using Boot2 Docker. If you use Linux is a multi-host set-up, then you can use
18 | # __CONTAINER.IP__
19 | - url: http://localhost:8080/hello-world
20 | timeout: 60000
21 | logPatterns:
22 | - "Successfully released change log lock"
23 | - pattern: "Started SocketConnector"
24 | timeout: 60000
25 | tag: registry/${project.artifactId}-app:${project.version}
26 |
--------------------------------------------------------------------------------
/src/it/build-test-it/src/main/docker/app/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -eux
3 |
4 | env
5 |
6 | # by default we use the long name of the project, but we can use an alias instead
7 | # sed -i "s/localhost:3306/$EXAMPLE_PROJECT_MYSQL_PORT_3306_TCP_ADDR:${mysql.port}/" hello-world.yml
8 | sed -i "s/localhost:3306/$DB_PORT_3306_TCP_ADDR:${mysql.port}/" hello-world.yml
9 |
10 | java -jar ${project.build.finalName}.jar db migrate hello-world.yml
11 | java -jar ${project.build.finalName}.jar server hello-world.yml
12 |
--------------------------------------------------------------------------------
/src/it/build-test-it/src/main/docker/mysql/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM mysql:5.6
2 |
3 | ENV MYSQL_ROOT_PASSWORD secret
4 | ENV MYSQL_USER test
5 | ENV MYSQL_PASSWORD test
6 | ENV MYSQL_DATABASE test
7 |
8 | EXPOSE ${mysql.port}
9 |
--------------------------------------------------------------------------------
/src/it/build-test-it/src/main/docker/mysql/conf.yml:
--------------------------------------------------------------------------------
1 | ports:
2 | - ${mysql.port}
3 | healthChecks:
4 | logPatterns:
5 | - "ready for connections"
--------------------------------------------------------------------------------
/src/it/build-test-it/src/main/docker/rubbish/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM java:7
2 |
--------------------------------------------------------------------------------
/src/it/build-test-it/src/main/docker/rubbish/conf.yml:
--------------------------------------------------------------------------------
1 | healthChecks:
2 | pings:
3 | - url: http://localhost:8080/
--------------------------------------------------------------------------------
/src/it/build-test-it/src/main/java/com/example/helloworld/HelloWorldConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.example.helloworld;
2 |
3 | import com.fasterxml.jackson.annotation.JsonProperty;
4 | import com.yammer.dropwizard.config.Configuration;
5 | import com.yammer.dropwizard.db.DatabaseConfiguration;
6 | import org.hibernate.validator.constraints.NotEmpty;
7 |
8 | import javax.validation.Valid;
9 | import javax.validation.constraints.NotNull;
10 |
11 | public class HelloWorldConfiguration extends Configuration {
12 | @NotEmpty
13 | @JsonProperty
14 | private String template;
15 |
16 | @JsonProperty
17 | private long defaultId = 1;
18 |
19 | @Valid
20 | @NotNull
21 | @JsonProperty("database")
22 | private DatabaseConfiguration database = new DatabaseConfiguration();
23 |
24 | public String getTemplate() {
25 | return template;
26 | }
27 |
28 | public long getDefaultId() {
29 | return defaultId;
30 | }
31 |
32 | public DatabaseConfiguration getDatabaseConfiguration() {
33 | return database;
34 | }
35 | }
--------------------------------------------------------------------------------
/src/it/build-test-it/src/main/java/com/example/helloworld/HelloWorldResource.java:
--------------------------------------------------------------------------------
1 | package com.example.helloworld;
2 |
3 | import com.example.helloworld.model.Person;
4 | import com.google.common.base.Optional;
5 | import com.yammer.dropwizard.hibernate.UnitOfWork;
6 | import com.yammer.metrics.annotation.Timed;
7 |
8 | import javax.ws.rs.GET;
9 | import javax.ws.rs.Path;
10 | import javax.ws.rs.Produces;
11 | import javax.ws.rs.QueryParam;
12 | import javax.ws.rs.core.MediaType;
13 |
14 | @Path("/hello-world")
15 | @Produces(MediaType.APPLICATION_JSON)
16 | public class HelloWorldResource {
17 | private final String template;
18 | private final long defaultId;
19 | private final PeopleDAO peopleDAO;
20 |
21 | public HelloWorldResource(String template, long defaultId, PeopleDAO peopleDAO) {
22 | this.template = template;
23 | this.defaultId = defaultId;
24 | this.peopleDAO = peopleDAO;
25 | }
26 |
27 | @GET
28 | @Timed
29 | @UnitOfWork
30 | public Saying sayHello(@QueryParam("id") Optional id) {
31 | final Person person = peopleDAO.findById(id.or(defaultId));
32 | return new Saying(person.id, String.format(template, person.name));
33 | }
34 | }
--------------------------------------------------------------------------------
/src/it/build-test-it/src/main/java/com/example/helloworld/HelloWorldService.java:
--------------------------------------------------------------------------------
1 | package com.example.helloworld;
2 |
3 | import com.example.helloworld.model.Person;
4 | import com.yammer.dropwizard.Service;
5 | import com.yammer.dropwizard.config.Bootstrap;
6 | import com.yammer.dropwizard.config.Environment;
7 | import com.yammer.dropwizard.db.DatabaseConfiguration;
8 | import com.yammer.dropwizard.hibernate.HibernateBundle;
9 | import com.yammer.dropwizard.migrations.MigrationsBundle;
10 |
11 | public class HelloWorldService extends Service {
12 | public static void main(String[] args) throws Exception {
13 | new HelloWorldService().run(args);
14 | }
15 |
16 | @Override
17 | public void initialize(Bootstrap bootstrap) {
18 | bootstrap.setName("hello-world");
19 | bootstrap.addBundle(new MigrationsBundle() {
20 |
21 | @Override
22 | public DatabaseConfiguration getDatabaseConfiguration(HelloWorldConfiguration configuration) {
23 | return configuration.getDatabaseConfiguration();
24 | }
25 | });
26 | bootstrap.addBundle(hibernate);
27 | }
28 |
29 | private final HibernateBundle hibernate = new HibernateBundle(Person.class) {
30 | @Override
31 | public DatabaseConfiguration getDatabaseConfiguration(HelloWorldConfiguration configuration) {
32 | return configuration.getDatabaseConfiguration();
33 | }
34 | };
35 |
36 | @Override
37 | public void run(HelloWorldConfiguration configuration, Environment environment) {
38 |
39 |
40 | final String template = configuration.getTemplate();
41 | environment.addResource(new HelloWorldResource(template, configuration.getDefaultId(), new PeopleDAO(hibernate.getSessionFactory())));
42 | environment.addHealthCheck(new TemplateHealthCheck(template));
43 | }
44 |
45 | }
--------------------------------------------------------------------------------
/src/it/build-test-it/src/main/java/com/example/helloworld/PeopleDAO.java:
--------------------------------------------------------------------------------
1 | package com.example.helloworld;
2 |
3 | import com.example.helloworld.model.Person;
4 | import com.yammer.dropwizard.hibernate.AbstractDAO;
5 | import org.hibernate.SessionFactory;
6 |
7 | /**
8 | */
9 | public class PeopleDAO extends AbstractDAO {
10 | public PeopleDAO(SessionFactory sessionFactory) {
11 | super(sessionFactory);
12 | }
13 |
14 | public Person findById(Long id) {
15 | return get(id);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/it/build-test-it/src/main/java/com/example/helloworld/Saying.java:
--------------------------------------------------------------------------------
1 | package com.example.helloworld;
2 |
3 | public class Saying {
4 | private final long id;
5 | private final String content;
6 |
7 | public Saying(long id, String content) {
8 | this.id = id;
9 | this.content = content;
10 | }
11 |
12 | public long getId() {
13 | return id;
14 | }
15 |
16 | public String getContent() {
17 | return content;
18 | }
19 | }
--------------------------------------------------------------------------------
/src/it/build-test-it/src/main/java/com/example/helloworld/TemplateHealthCheck.java:
--------------------------------------------------------------------------------
1 | package com.example.helloworld;
2 |
3 | import com.yammer.metrics.core.HealthCheck;
4 |
5 | public class TemplateHealthCheck extends HealthCheck {
6 | private final String template;
7 |
8 | public TemplateHealthCheck(String template) {
9 | super("template");
10 | this.template = template;
11 | }
12 |
13 | @Override
14 | protected Result check() throws Exception {
15 | final String saying = String.format(template, "TEST");
16 | if (!saying.contains("TEST")) {
17 | return Result.unhealthy("template doesn't include a name");
18 | }
19 | return Result.healthy();
20 | }
21 | }
--------------------------------------------------------------------------------
/src/it/build-test-it/src/main/java/com/example/helloworld/model/Person.java:
--------------------------------------------------------------------------------
1 | package com.example.helloworld.model;
2 |
3 | import javax.persistence.Entity;
4 | import javax.persistence.Id;
5 |
6 | @Entity(name = "people")
7 | public class Person {
8 | @Id
9 | public long id;
10 | public String name;
11 | }
12 |
--------------------------------------------------------------------------------
/src/it/build-test-it/src/main/resources/migrations.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/it/build-test-it/src/test/java/com/example/helloworld/HelloWorldServiceIT.java:
--------------------------------------------------------------------------------
1 | package com.example.helloworld;
2 |
3 |
4 | import org.junit.BeforeClass;
5 | import org.junit.Test;
6 |
7 | import static com.jayway.restassured.RestAssured.given;
8 | import static org.hamcrest.CoreMatchers.containsString;
9 |
10 | public class HelloWorldServiceIT {
11 |
12 | @Test
13 | public void test() throws Exception {
14 | given().
15 | log().all().
16 | expect().
17 | statusCode(200).
18 | body(containsString("Hello, Stranger!")).
19 | when().
20 | get("http://localhost:8080/hello-world");
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/it/build-test-it/test.properties:
--------------------------------------------------------------------------------
1 | mysql.port=3306
--------------------------------------------------------------------------------
/src/it/build-test-it/verify.groovy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexec/docker-maven-plugin/743fa720878eec9acee9b81e053801fbed2b33d7/src/it/build-test-it/verify.groovy
--------------------------------------------------------------------------------
/src/it/port-setup-it/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | port-setup-it
7 | port-setup-it
8 | 1.0-SNAPSHOT
9 |
10 |
11 | UTF-8
12 |
13 |
14 |
15 |
16 |
17 | @project.groupId@
18 | @project.artifactId@
19 | @project.version@
20 |
21 |
22 |
23 | clean
24 | package
25 | start
26 | stop
27 |
28 |
29 |
30 |
31 |
32 | maven-antrun-plugin
33 |
34 |
35 | integration-test
36 |
37 | run
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/src/it/port-setup-it/src/main/docker/mysql/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM mysql:5.6
2 |
3 | ENV MYSQL_ROOT_PASSWORD secret
4 | ENV MYSQL_USER test
5 | ENV MYSQL_PASSWORD test
6 | ENV MYSQL_DATABASE test
7 |
8 | EXPOSE 3306
9 |
--------------------------------------------------------------------------------
/src/it/port-setup-it/src/main/docker/mysql/conf.yml:
--------------------------------------------------------------------------------
1 | ports:
2 | - 8888 3306
3 | sleep: 5000
--------------------------------------------------------------------------------
/src/it/port-setup-it/verify.groovy:
--------------------------------------------------------------------------------
1 | def actualPs = new File(basedir, "docker.ps").text
2 | def expectedSubstring = "0.0.0.0:8888->3306/tcp"
3 |
4 | println actualPs
5 |
6 | assert actualPs.contains(expectedSubstring), "\"" + actualPs + "\" contains \"" + expectedSubstring + "\""
--------------------------------------------------------------------------------
/src/it/settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | it-repo
8 |
9 | true
10 |
11 |
12 |
13 | local.central
14 | @localRepositoryUrl@
15 |
16 | true
17 |
18 |
19 | true
20 |
21 |
22 |
23 |
24 |
25 | local.central
26 | @localRepositoryUrl@
27 |
28 | true
29 |
30 |
31 | true
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/main/java/com/alexecollins/docker/mojo/AbstractDockerMojo.java:
--------------------------------------------------------------------------------
1 | package com.alexecollins.docker.mojo;
2 |
3 | import com.alexecollins.docker.orchestration.DockerOrchestrator;
4 | import com.alexecollins.docker.orchestration.ExcludeFilter;
5 | import com.alexecollins.docker.orchestration.model.BuildFlag;
6 | import com.alexecollins.docker.util.MavenLogAppender;
7 | import com.github.dockerjava.api.DockerClient;
8 | import com.github.dockerjava.api.command.VersionCmd;
9 | import com.github.dockerjava.api.exception.DockerException;
10 | import com.github.dockerjava.api.model.Version;
11 | import com.github.dockerjava.core.DefaultDockerClientConfig;
12 | import com.github.dockerjava.core.DockerClientBuilder;
13 | import org.apache.commons.lang.StringUtils;
14 | import org.apache.maven.plugin.AbstractMojo;
15 | import org.apache.maven.plugin.MojoExecutionException;
16 | import org.apache.maven.plugin.MojoFailureException;
17 | import org.apache.maven.plugins.annotations.Component;
18 | import org.apache.maven.plugins.annotations.Parameter;
19 | import org.apache.maven.project.MavenProject;
20 |
21 | import java.io.File;
22 | import java.util.HashSet;
23 | import java.util.Properties;
24 | import java.util.Set;
25 |
26 | abstract class AbstractDockerMojo extends AbstractMojo {
27 |
28 | /**
29 | * The host, e.g. -Ddocker.host=http://127.0.0.1:2375
30 | */
31 | @Parameter(property = "docker.host")
32 | private String host;
33 |
34 | /**
35 | * A prefix to namespace scope machine. Important for isolating machines.
36 | */
37 | @Parameter(defaultValue = "${project.artifactId}", property = "docker.prefix")
38 | private String prefix;
39 |
40 | /**
41 | * Where to look for directories containing Dockerfile and conf.yml
42 | */
43 | @Parameter(defaultValue = "src/main/docker", property = "docker.src")
44 | private String src;
45 |
46 | /**
47 | * Installed Docker version.
48 | */
49 | @Parameter(property = "docker.version")
50 | private String version;
51 |
52 | /**
53 | * Docker username (for a remote registry).
54 | */
55 | @Parameter(property = "docker.username", defaultValue = "${user.name}")
56 | private String username;
57 |
58 | /**
59 | * Docker username (for a remote registry).
60 | */
61 | @Parameter(property = "docker.password")
62 | private String password;
63 |
64 | /**
65 | * Docker registry server (for deploy).
66 | */
67 | @Parameter(property = "docker.serverAddress")
68 | private String serverAddress;
69 |
70 | /**
71 | * Docker email (for deploy).
72 | */
73 | @Parameter(property = "docker.email")
74 | private String email;
75 |
76 | /**
77 | * Remove intermediate images during build.
78 | */
79 | @Parameter(defaultValue = "false", property = "docker.removeIntermediateImages")
80 | private boolean removeIntermediateImages;
81 |
82 | /**
83 | * Use cached images during build.
84 | */
85 | @Parameter(defaultValue = "true", property = "docker.cache")
86 | private boolean cache = true;
87 |
88 | /**
89 | * Don't output the docker api responses during builds.
90 | */
91 | @Parameter(defaultValue = "false", property = "docker.quiet")
92 | private boolean quiet;
93 |
94 | /**
95 | * Always pull FROM image when building.
96 | */
97 | @Parameter(defaultValue = "false", property = "docker.pull")
98 | private boolean pull;
99 |
100 | /**
101 | * Silently ignore permission errors. This is useful if your CI does not support removal of containers.
102 | */
103 | @Parameter(defaultValue = "false", property = "docker.permissionErrorTolerant")
104 | private boolean permissionErrorTolerant;
105 |
106 | /**
107 | * Skip execution.
108 | */
109 | @Parameter(defaultValue = "false", property = "docker.skip")
110 | private boolean skip;
111 |
112 | /**
113 | * Exclude certain definitions, e.g. to not start one container.
114 | *
115 | * Comma-separated.
116 | */
117 | @Parameter(defaultValue = "", property = "docker.exclude")
118 | private String exclude = "";
119 |
120 | /**
121 | * Specify docker certificate path. Defaults to not being set
122 | */
123 | @Parameter(property = "docker.certPath")
124 | private String certificatePath;
125 |
126 | /**
127 | * Specify the docker configuration path. By default it tries to find the config.json in $HOME/.docker.
128 | * If not existent it falls back to the legacy .dockercfg and tries to find it in the $HOME folder.
129 | *
130 | * Will look for a file called .dockercfg (legacy) or a file called config.json in the given path for
131 | * authentication.
132 | */
133 | @Parameter(property = "docker.cfgPath")
134 | private String cfgPath;
135 |
136 | /**
137 | * Do auto detection on the docker version.
138 | */
139 | @Parameter(defaultValue = "true", property = "docker.versionAutoDetect")
140 | private boolean versionAutoDetect;
141 |
142 | @Component
143 | private MavenProject project;
144 |
145 | public MavenProject getProject() {
146 | return project;
147 | }
148 |
149 | @Override
150 | public final void execute() throws MojoExecutionException, MojoFailureException {
151 |
152 | MavenLogAppender.setLog(getLog());
153 |
154 | if (skip) {
155 | getLog().info("skipped");
156 | return;
157 | }
158 |
159 | // not great eh
160 | final Properties properties = properties();
161 |
162 | getLog().debug("properties filtering supported for " + properties.keySet());
163 |
164 | try {
165 | final DockerClient docker = dockerClient();
166 | getLog().info("Docker version " + docker.versionCmd().exec().getVersion());
167 | doExecute(dockerOrchestrator(properties, docker));
168 | } catch (Exception e) {
169 | e.printStackTrace();
170 | throw new MojoExecutionException(e.getMessage(), e);
171 | }
172 | }
173 |
174 | private DockerOrchestrator dockerOrchestrator(Properties properties, DockerClient docker) {
175 | return DockerOrchestrator
176 | .builder()
177 | .docker(docker)
178 | .src(src())
179 | .workDir(workDir())
180 | .rootDir(projDir())
181 | .user(username)
182 | .project(prefix)
183 | .properties(properties)
184 | .buildFlags(buildFlags())
185 | .definitionFilter(new ExcludeFilter(exclude.split(",")))
186 | .permissionErrorTolerant(permissionErrorTolerant)
187 | .build();
188 | }
189 |
190 | private Set buildFlags() {
191 | final Set buildFlags = new HashSet<>();
192 | if (removeIntermediateImages) {
193 | buildFlags.add(BuildFlag.REMOVE_INTERMEDIATE_IMAGES);
194 | }
195 | if (!cache) {
196 | buildFlags.add(BuildFlag.NO_CACHE);
197 | }
198 | if (quiet) {
199 | buildFlags.add(BuildFlag.QUIET);
200 | }
201 | if (pull) {
202 | buildFlags.add(BuildFlag.PULL);
203 | }
204 | return buildFlags;
205 | }
206 |
207 | private DockerClient dockerClient() throws DockerException {
208 | final String currentUsersHomeDir = System.getProperty("user.home");
209 | DefaultDockerClientConfig.Builder builder = DefaultDockerClientConfig.createDefaultConfigBuilder();
210 | if (host != null) {
211 | builder = builder.withDockerHost(host);
212 | }
213 | if (version != null) {
214 | builder = builder.withApiVersion(version);
215 | }
216 | if (username != null) {
217 | builder = builder.withRegistryUsername(username);
218 | }
219 | if (password != null) {
220 | builder = builder.withRegistryPassword(password);
221 | }
222 | if (email != null) {
223 | builder = builder.withRegistryEmail(email);
224 | }
225 | if (serverAddress != null) {
226 | builder = builder.withRegistryUrl(serverAddress);
227 | }
228 | if (certificatePath != null) {
229 | builder = builder.withDockerCertPath(certificatePath);
230 | }
231 | if (cfgPath != null) {
232 | builder = builder.withDockerConfig(cfgPath);
233 | } else if (StringUtils.isNotBlank(currentUsersHomeDir)) {
234 | final File legacyCfgFile = new File(currentUsersHomeDir + "/.dockercfg");
235 | final File cfgFile = new File(currentUsersHomeDir + "/.docker/config.json");
236 |
237 | if (cfgFile.exists()) {
238 | getLog().info("Using configuration file: " + cfgFile.getAbsolutePath());
239 | builder = builder.withDockerConfig(currentUsersHomeDir + "/.docker");
240 | } else if (legacyCfgFile.exists()) {
241 | getLog().info("Using legacy configuration file: " + legacyCfgFile.getAbsolutePath());
242 | builder = builder.withDockerConfig(currentUsersHomeDir);
243 | }
244 | }
245 |
246 | if (versionAutoDetect) {
247 | final DockerClient initialClient = DockerClientBuilder.getInstance(builder.build()).build();
248 | final VersionCmd versionCmd = initialClient.versionCmd();
249 | final Version version = versionCmd.exec();
250 |
251 | builder = builder.withApiVersion(version.getApiVersion());
252 |
253 | return DockerClientBuilder.getInstance(builder.build()).build();
254 | } else {
255 | return DockerClientBuilder.getInstance(builder.build()).build();
256 | }
257 | }
258 |
259 |
260 | private Properties properties() {
261 | final Properties p = new Properties();
262 |
263 | p.putAll(System.getenv());
264 |
265 | final String[] x = new String[]{
266 | "project.groupId", project.getGroupId(),
267 | "project.artifactId", project.getArtifactId(),
268 | "project.version", project.getVersion(),
269 | "project.name", project.getName(),
270 | "project.description", project.getDescription(),
271 | "project.build.finalName", project.getBuild().getFinalName()
272 | };
273 |
274 | for (int i = 0; i < x.length; i += 2) {
275 | if (x[i + 1] != null) {
276 | p.setProperty(x[i], x[i + 1]);
277 | }
278 | }
279 |
280 | p.putAll(project.getProperties());
281 | p.putAll(System.getProperties());
282 |
283 | return p;
284 | }
285 |
286 | private File workDir() {
287 | return new File(project.getBuild().getDirectory(), "docker");
288 | }
289 |
290 | private File projDir() {
291 | return project.getBasedir();
292 | }
293 |
294 | private File src() {
295 | return new File(projDir(), src);
296 | }
297 |
298 | protected abstract void doExecute(DockerOrchestrator orchestrator) throws Exception;
299 |
300 |
301 | }
302 |
--------------------------------------------------------------------------------
/src/main/java/com/alexecollins/docker/mojo/CleanMojo.java:
--------------------------------------------------------------------------------
1 | package com.alexecollins.docker.mojo;
2 |
3 | import com.alexecollins.docker.orchestration.DockerOrchestrator;
4 | import org.apache.maven.plugins.annotations.LifecyclePhase;
5 | import org.apache.maven.plugins.annotations.Mojo;
6 | import org.apache.maven.plugins.annotations.Parameter;
7 |
8 |
9 | /**
10 | * Clean up containers, stopping them in necessary and there removing their images.
11 | */
12 | @Mojo(name = "clean", defaultPhase = LifecyclePhase.CLEAN)
13 | public class CleanMojo extends AbstractDockerMojo {
14 |
15 | /**
16 | * Clean container only in clean.
17 | */
18 | @Parameter(defaultValue = "false", property = "docker.cleanContainerOnly")
19 | private boolean cleanContainerOnly;
20 |
21 | /**
22 | * Clean with docker force flag
23 | */
24 | @Parameter(defaultValue = "false", property = "docker.forceClean")
25 | private boolean forceClean;
26 |
27 |
28 | @Override
29 | protected void doExecute(DockerOrchestrator orchestrator) {
30 | if (isCleanContainerOnly()) {
31 | orchestrator.cleanContainers(isForceClean());
32 | } else {
33 | orchestrator.clean(isForceClean());
34 | }
35 | }
36 |
37 | boolean isCleanContainerOnly() {
38 | return cleanContainerOnly;
39 | }
40 |
41 | void setCleanContainerOnly(boolean cleanContainerOnly) {
42 | this.cleanContainerOnly = cleanContainerOnly;
43 | }
44 |
45 | boolean isForceClean() {
46 | return forceClean;
47 | }
48 |
49 | void setForceClean(boolean forceClean) {
50 | this.forceClean = forceClean;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/com/alexecollins/docker/mojo/CopyMojo.java:
--------------------------------------------------------------------------------
1 | package com.alexecollins.docker.mojo;
2 |
3 | import com.alexecollins.docker.orchestration.DockerOrchestrator;
4 | import org.apache.maven.plugins.annotations.LifecyclePhase;
5 | import org.apache.maven.plugins.annotations.Mojo;
6 | import org.apache.maven.plugins.annotations.Parameter;
7 |
8 | /**
9 | * Copy resources from the containers.
10 | */
11 | @Mojo(name = "copy", defaultPhase = LifecyclePhase.PACKAGE)
12 | public class CopyMojo extends AbstractDockerMojo {
13 | /**
14 | * Resource to copy out of the docker container.
15 | */
16 | @Parameter(property = "docker.source")
17 | private String resource;
18 |
19 | /**
20 | * Resource to copy out of the docker container.
21 | */
22 | @Parameter(property = "docker.dest")
23 | private String dest;
24 |
25 | public String getSource() {
26 | return resource;
27 | }
28 |
29 | public String getDest() {
30 | return dest;
31 | }
32 |
33 | @Override
34 | protected void doExecute(DockerOrchestrator orchestrator) throws Exception {
35 | getLog().info("Copying " + getSource() + " to " + getDest());
36 | orchestrator.copy(getSource(), getDest());
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/com/alexecollins/docker/mojo/DeployMojo.java:
--------------------------------------------------------------------------------
1 | package com.alexecollins.docker.mojo;
2 |
3 | import com.alexecollins.docker.orchestration.DockerOrchestrator;
4 | import org.apache.maven.plugins.annotations.LifecyclePhase;
5 | import org.apache.maven.plugins.annotations.Mojo;
6 |
7 |
8 | /**
9 | * Deploy containers
10 | */
11 | @Mojo(name = "deploy", defaultPhase = LifecyclePhase.DEPLOY)
12 | public class DeployMojo extends AbstractDockerMojo {
13 |
14 | @Override
15 | protected void doExecute(DockerOrchestrator orchestrator) {
16 | orchestrator.push();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/com/alexecollins/docker/mojo/LoggingMojo.java:
--------------------------------------------------------------------------------
1 | package com.alexecollins.docker.mojo;
2 |
3 | import com.alexecollins.docker.orchestration.DockerOrchestrator;
4 | import org.apache.maven.plugins.annotations.LifecyclePhase;
5 | import org.apache.maven.plugins.annotations.Mojo;
6 | import org.apache.maven.plugins.annotations.Parameter;
7 |
8 | import java.io.File;
9 |
10 | /**
11 | * Save log output of containers to a file.
12 | */
13 | @Mojo(name = "save-logs", defaultPhase = LifecyclePhase.POST_INTEGRATION_TEST)
14 | public class LoggingMojo extends AbstractDockerMojo {
15 |
16 | /**
17 | * The directory to save logs to.
18 | */
19 | @Parameter(defaultValue = "${project.build.directory}/docker", property = "docker.saveDir")
20 | private File saveDir;
21 |
22 | @Override
23 | protected void doExecute(DockerOrchestrator orchestrator) throws Exception {
24 | orchestrator.saveLogs(saveDir);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/alexecollins/docker/mojo/PackageMojo.java:
--------------------------------------------------------------------------------
1 | package com.alexecollins.docker.mojo;
2 |
3 | import com.alexecollins.docker.orchestration.DockerOrchestrator;
4 | import org.apache.maven.plugins.annotations.LifecyclePhase;
5 | import org.apache.maven.plugins.annotations.Mojo;
6 |
7 |
8 | /**
9 | * Build containers from their {@code Dockerfile} and {@code conf.yml} files.
10 | */
11 | @Mojo(name = "package", defaultPhase = LifecyclePhase.PACKAGE)
12 | public class PackageMojo extends AbstractDockerMojo {
13 |
14 | @Override
15 | protected void doExecute(DockerOrchestrator orchestrator) {
16 | orchestrator.build();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/com/alexecollins/docker/mojo/SaveMojo.java:
--------------------------------------------------------------------------------
1 | package com.alexecollins.docker.mojo;
2 |
3 | import com.alexecollins.docker.orchestration.DockerOrchestrator;
4 | import com.alexecollins.docker.orchestration.model.Id;
5 | import org.apache.commons.io.FilenameUtils;
6 | import org.apache.maven.plugins.annotations.Component;
7 | import org.apache.maven.plugins.annotations.LifecyclePhase;
8 | import org.apache.maven.plugins.annotations.Mojo;
9 | import org.apache.maven.plugins.annotations.Parameter;
10 | import org.apache.maven.project.MavenProjectHelper;
11 |
12 | import java.io.File;
13 | import java.util.Map;
14 |
15 |
16 | /**
17 | * Save images to tar/tar.gz files.
18 | */
19 | @Mojo(name = "save", defaultPhase = LifecyclePhase.PACKAGE)
20 | public class SaveMojo extends AbstractDockerMojo {
21 | /**
22 | * The directory to save images to.
23 | */
24 | @Parameter(defaultValue = "${project.build.directory}/docker", property = "docker.saveDir")
25 | private File saveDir;
26 |
27 | /**
28 | * Gzip saved images.
29 | */
30 | @Parameter(defaultValue = "false", property = "docker.gzipSave")
31 | private boolean gzipSave;
32 |
33 | /**
34 | * Attach saved images to project for local install, or deployment to repository.
35 | */
36 | @Parameter(defaultValue = "false", property = "docker.attach")
37 | private boolean attach;
38 |
39 | @Component
40 | private MavenProjectHelper mavenProjectHelper;
41 |
42 | @Override
43 | protected void doExecute(DockerOrchestrator orchestrator) {
44 | Map saved = orchestrator.save(saveDir, gzipSave);
45 |
46 | if (attach) {
47 | attachSavedFiles(saved);
48 | }
49 | }
50 |
51 | private void attachSavedFiles(Map saved) {
52 | for (Map.Entry save : saved.entrySet()) {
53 | File file = save.getValue();
54 | String extension = FilenameUtils.getExtension(file.getName());
55 | mavenProjectHelper.attachArtifact(getProject(), extension, save.getKey().toString(), file);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/com/alexecollins/docker/mojo/StartMojo.java:
--------------------------------------------------------------------------------
1 | package com.alexecollins.docker.mojo;
2 |
3 | import com.alexecollins.docker.orchestration.DockerOrchestrator;
4 | import org.apache.maven.plugins.annotations.LifecyclePhase;
5 | import org.apache.maven.plugins.annotations.Mojo;
6 |
7 | import java.util.Map;
8 |
9 | /**
10 | * Start all the containers.
11 | */
12 | @Mojo(name = "start", defaultPhase = LifecyclePhase.PRE_INTEGRATION_TEST)
13 | public class StartMojo extends AbstractDockerMojo {
14 |
15 | @Override
16 | protected void doExecute(DockerOrchestrator orchestrator) {
17 | orchestrator.start();
18 | Map idAndIpMap = orchestrator.getIPAddresses();
19 | for (String id : idAndIpMap.keySet()) {
20 | getProject().getProperties().setProperty("docker." + id + ".ipAddress", idAndIpMap.get(id));
21 | }
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/com/alexecollins/docker/mojo/StopMojo.java:
--------------------------------------------------------------------------------
1 | package com.alexecollins.docker.mojo;
2 |
3 | import com.alexecollins.docker.orchestration.DockerOrchestrator;
4 | import org.apache.maven.plugins.annotations.LifecyclePhase;
5 | import org.apache.maven.plugins.annotations.Mojo;
6 |
7 | /**
8 | * Stop all the containers.
9 | */
10 | @Mojo(name = "stop", defaultPhase = LifecyclePhase.POST_INTEGRATION_TEST)
11 | public class StopMojo extends AbstractDockerMojo {
12 |
13 | @Override
14 | protected void doExecute(DockerOrchestrator orchestrator) throws Exception {
15 | orchestrator.stop();
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/com/alexecollins/docker/mojo/ValidateMojo.java:
--------------------------------------------------------------------------------
1 | package com.alexecollins.docker.mojo;
2 |
3 | import com.alexecollins.docker.orchestration.DockerOrchestrator;
4 | import org.apache.maven.plugins.annotations.LifecyclePhase;
5 | import org.apache.maven.plugins.annotations.Mojo;
6 |
7 | /**
8 | * Validate {@code Dockerfile} files.
9 | * Based on
10 | * @see Npm validate-dockerfile
11 | * and
12 | * @see Best Practice
13 | */
14 | @Mojo(name = "validate", defaultPhase = LifecyclePhase.VALIDATE)
15 | public class ValidateMojo extends AbstractDockerMojo {
16 |
17 | @Override
18 | protected void doExecute(DockerOrchestrator orchestrator) throws Exception {
19 | orchestrator.validate();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/com/alexecollins/docker/util/MavenLogAppender.java:
--------------------------------------------------------------------------------
1 | package com.alexecollins.docker.util;
2 |
3 | import ch.qos.logback.classic.spi.ILoggingEvent;
4 | import ch.qos.logback.core.AppenderBase;
5 | import org.apache.maven.plugin.logging.Log;
6 | import org.slf4j.bridge.SLF4JBridgeHandler;
7 |
8 | import java.util.logging.LogManager;
9 | import java.util.logging.Logger;
10 |
11 | import static ch.qos.logback.classic.Level.*;
12 |
13 | public class MavenLogAppender extends AppenderBase {
14 |
15 | @SuppressWarnings("FieldCanBeLocal")
16 | private static Log LOG;
17 |
18 | static {
19 | LogManager.getLogManager().reset();
20 | SLF4JBridgeHandler.install();
21 | Logger.getLogger("global").setLevel(java.util.logging.Level.FINEST);
22 | }
23 |
24 | public static void setLog(Log log) {
25 | MavenLogAppender.LOG = log;
26 | }
27 |
28 | @Override
29 | protected void append(ILoggingEvent eventObject) {
30 | if (eventObject.getLevel().isGreaterOrEqual(ERROR)) {
31 | LOG.error(eventObject.getMessage());
32 | } else if (eventObject.getLevel().isGreaterOrEqual(WARN)) {
33 | LOG.warn(eventObject.getMessage());
34 | } else if (eventObject.getLevel().isGreaterOrEqual(INFO)) {
35 | LOG.info(eventObject.getMessage());
36 | } else {
37 | LOG.debug(eventObject.getMessage());
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | %msg%n
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/test/java/com/alexecollins/docker/mojo/AbstractDockerMojoTest.java:
--------------------------------------------------------------------------------
1 | package com.alexecollins.docker.mojo;
2 |
3 | import com.alexecollins.docker.orchestration.DockerOrchestrator;
4 | import com.alexecollins.docker.orchestration.model.BuildFlag;
5 | import com.github.dockerjava.api.DockerClient;
6 | import org.apache.maven.plugin.MojoExecutionException;
7 | import org.junit.Before;
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 | import org.mockito.ArgumentCaptor;
11 | import org.powermock.api.mockito.PowerMockito;
12 | import org.powermock.core.classloader.annotations.PrepareForTest;
13 | import org.powermock.modules.junit4.PowerMockRunner;
14 | import org.powermock.reflect.Whitebox;
15 |
16 | import java.util.Set;
17 |
18 | import static org.junit.Assert.assertEquals;
19 | import static org.junit.Assert.assertFalse;
20 | import static org.junit.Assert.assertNotNull;
21 | import static org.junit.Assert.assertTrue;
22 | import static org.junit.Assert.fail;
23 | import static org.mockito.Matchers.any;
24 | import static org.mockito.Mockito.doThrow;
25 | import static org.mockito.Mockito.mock;
26 | import static org.mockito.Mockito.never;
27 | import static org.mockito.Mockito.verify;
28 |
29 | @RunWith(PowerMockRunner.class)
30 | @PrepareForTest(AbstractDockerMojo.class)
31 | public class AbstractDockerMojoTest extends MojoTestSupport {
32 |
33 | private AbstractDockerMojo dockerMojo;
34 |
35 | private DockerClient dockerClient;
36 |
37 | @Before
38 | public void setUp() throws Exception {
39 | dockerMojo = PowerMockito.spy(new AbstractDockerMojo() {
40 | @Override
41 | protected void doExecute(DockerOrchestrator orchestrator) throws Exception {
42 | // do nothing
43 | }
44 | });
45 | dockerClient = mock(DockerClient.class);
46 |
47 | prepareMojo(dockerMojo, dockerClient, null);
48 | }
49 |
50 | @Test
51 | public void testExecution() throws Exception {
52 | // given
53 | ArgumentCaptor captor = ArgumentCaptor.forClass(DockerOrchestrator.class);
54 |
55 | // when
56 | dockerMojo.execute();
57 |
58 | // then
59 | verify(dockerMojo).doExecute(captor.capture());
60 | DockerOrchestrator capturedOrchestrator = captor.getValue();
61 | assertNotNull(capturedOrchestrator);
62 |
63 | assertEquals(dockerClient, Whitebox.getInternalState(capturedOrchestrator, "docker"));
64 |
65 | Set buildFlags = Whitebox.getInternalState(capturedOrchestrator, "buildFlags");
66 | assertNotNull(buildFlags);
67 | assertFalse(buildFlags.contains(BuildFlag.REMOVE_INTERMEDIATE_IMAGES));
68 | assertFalse(buildFlags.contains(BuildFlag.NO_CACHE));
69 | assertFalse(buildFlags.contains(BuildFlag.PULL));
70 | assertFalse(buildFlags.contains(BuildFlag.QUIET));
71 | }
72 |
73 | @Test
74 | public void testExecutionWithFlags() throws Exception {
75 | // given
76 | Whitebox.setInternalState(dockerMojo, "removeIntermediateImages", true);
77 | Whitebox.setInternalState(dockerMojo, "cache", false);
78 | Whitebox.setInternalState(dockerMojo, "quiet", true);
79 | Whitebox.setInternalState(dockerMojo, "pull", true);
80 |
81 |
82 | ArgumentCaptor captor = ArgumentCaptor.forClass(DockerOrchestrator.class);
83 |
84 | // when
85 | dockerMojo.execute();
86 |
87 | // then
88 | verify(dockerMojo).doExecute(captor.capture());
89 | DockerOrchestrator capturedOrchestrator = captor.getValue();
90 | assertNotNull(capturedOrchestrator);
91 |
92 | assertEquals(dockerClient, Whitebox.getInternalState(capturedOrchestrator, "docker"));
93 |
94 | Set buildFlags = Whitebox.getInternalState(capturedOrchestrator, "buildFlags");
95 | assertNotNull(buildFlags);
96 | assertTrue(buildFlags.contains(BuildFlag.REMOVE_INTERMEDIATE_IMAGES));
97 | assertTrue(buildFlags.contains(BuildFlag.NO_CACHE));
98 | assertTrue(buildFlags.contains(BuildFlag.PULL));
99 | assertTrue(buildFlags.contains(BuildFlag.QUIET));
100 | }
101 |
102 | @Test
103 | public void testExecutionWithSkip() throws Exception {
104 | // given
105 | Whitebox.setInternalState(dockerMojo, "skip", true);
106 |
107 | // when
108 | dockerMojo.execute();
109 |
110 | // then
111 | verify(dockerMojo, never()).doExecute(any(DockerOrchestrator.class));
112 | }
113 |
114 | @Test(expected = MojoExecutionException.class)
115 | public void testExecutionThrowsException() throws Exception {
116 | // given
117 | doThrow(Exception.class).when(dockerMojo).doExecute(any(DockerOrchestrator.class));
118 |
119 | // when
120 | dockerMojo.execute();
121 |
122 | // then
123 | fail("AbstractDockerMojo should throw MojoExecutionException when execution fails");
124 | }
125 |
126 | }
127 |
--------------------------------------------------------------------------------
/src/test/java/com/alexecollins/docker/mojo/CleanMojoTest.java:
--------------------------------------------------------------------------------
1 | package com.alexecollins.docker.mojo;
2 |
3 | import com.alexecollins.docker.orchestration.DockerOrchestrator;
4 | import com.github.dockerjava.api.DockerClient;
5 | import org.apache.maven.plugin.MojoExecutionException;
6 | import org.apache.maven.plugin.MojoFailureException;
7 | import org.junit.Before;
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 | import org.powermock.api.mockito.PowerMockito;
11 | import org.powermock.core.classloader.annotations.PrepareForTest;
12 | import org.powermock.modules.junit4.PowerMockRunner;
13 | import org.powermock.reflect.Whitebox;
14 |
15 | import static org.mockito.Mockito.mock;
16 | import static org.mockito.Mockito.never;
17 | import static org.mockito.Mockito.verify;
18 | import static org.mockito.Mockito.when;
19 |
20 | @RunWith(PowerMockRunner.class)
21 | @PrepareForTest(CleanMojo.class)
22 | public class CleanMojoTest extends MojoTestSupport {
23 |
24 | private CleanMojo cleanMojo;
25 |
26 | private DockerOrchestrator mockDockerOrchestrator;
27 |
28 | @Before
29 | public void setUp() throws Exception {
30 |
31 | cleanMojo = PowerMockito.spy(new CleanMojo());
32 | DockerClient mockDockerClient = mock(DockerClient.class);
33 | mockDockerOrchestrator = mock(DockerOrchestrator.class);
34 |
35 | prepareMojo(cleanMojo, mockDockerClient, mockDockerOrchestrator);
36 | }
37 |
38 | @Test
39 | public void testCleanAll() throws Exception {
40 | // when
41 | cleanMojo.execute();
42 |
43 | // then
44 | verify(cleanMojo).doExecute(mockDockerOrchestrator);
45 | verify(mockDockerOrchestrator, never()).cleanContainers();
46 | verify(mockDockerOrchestrator).clean(false);
47 | }
48 |
49 | @Test
50 | public void testCleanForce() throws Exception {
51 | when(cleanMojo.isForceClean()).thenReturn(Boolean.TRUE);
52 |
53 | // when
54 | cleanMojo.execute();
55 |
56 | // then
57 | verify(cleanMojo).doExecute(mockDockerOrchestrator);
58 | verify(mockDockerOrchestrator, never()).cleanContainers();
59 | verify(mockDockerOrchestrator).clean(true);
60 | }
61 |
62 |
63 | @Test
64 | public void testCleanContainers() throws MojoFailureException, MojoExecutionException {
65 | // given
66 | Whitebox.setInternalState(cleanMojo, "cleanContainerOnly", true);
67 |
68 | // when
69 | cleanMojo.execute();
70 |
71 | // then
72 | verify(cleanMojo).doExecute(mockDockerOrchestrator);
73 | verify(mockDockerOrchestrator).cleanContainers(false);
74 | verify(mockDockerOrchestrator, never()).clean();
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/test/java/com/alexecollins/docker/mojo/CopyMojoTest.java:
--------------------------------------------------------------------------------
1 | package com.alexecollins.docker.mojo;
2 |
3 | import com.alexecollins.docker.orchestration.DockerOrchestrator;
4 | import com.github.dockerjava.api.DockerClient;
5 | import org.junit.Before;
6 | import org.junit.Test;
7 | import org.junit.runner.RunWith;
8 | import org.powermock.api.mockito.PowerMockito;
9 | import org.powermock.core.classloader.annotations.PrepareForTest;
10 | import org.powermock.modules.junit4.PowerMockRunner;
11 | import org.powermock.reflect.Whitebox;
12 |
13 | import static org.junit.Assert.assertEquals;
14 | import static org.mockito.Mockito.mock;
15 | import static org.mockito.Mockito.verify;
16 |
17 | @RunWith(PowerMockRunner.class)
18 | @PrepareForTest(CopyMojo.class)
19 | public class CopyMojoTest extends MojoTestSupport {
20 |
21 | private static final String SOURCE = "source";
22 |
23 | private static final String DEST = "dest";
24 |
25 | private CopyMojo copyMojo;
26 |
27 | private DockerOrchestrator mockDockerOrchestrator;
28 |
29 | @Before
30 | public void setUp() throws Exception {
31 |
32 | copyMojo = PowerMockito.spy(new CopyMojo());
33 | DockerClient mockDockerClient = mock(DockerClient.class);
34 | mockDockerOrchestrator = mock(DockerOrchestrator.class);
35 |
36 | prepareMojo(copyMojo, mockDockerClient, mockDockerOrchestrator);
37 | Whitebox.setInternalState(copyMojo, "resource", SOURCE);
38 | Whitebox.setInternalState(copyMojo, "dest", DEST);
39 | }
40 |
41 | @Test
42 | public void testCopy() throws Exception {
43 | // when
44 | copyMojo.execute();
45 |
46 | // then
47 | verify(copyMojo).doExecute(mockDockerOrchestrator);
48 | verify(mockDockerOrchestrator).copy(SOURCE, DEST);
49 | }
50 |
51 | @Test
52 | public void testGetters() {
53 | assertEquals(SOURCE, copyMojo.getSource());
54 | assertEquals(DEST, copyMojo.getDest());
55 | }
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/src/test/java/com/alexecollins/docker/mojo/DeployMojoTest.java:
--------------------------------------------------------------------------------
1 | package com.alexecollins.docker.mojo;
2 |
3 | import com.alexecollins.docker.orchestration.DockerOrchestrator;
4 | import com.github.dockerjava.api.DockerClient;
5 | import org.junit.Before;
6 | import org.junit.Test;
7 | import org.junit.runner.RunWith;
8 | import org.powermock.api.mockito.PowerMockito;
9 | import org.powermock.core.classloader.annotations.PrepareForTest;
10 | import org.powermock.modules.junit4.PowerMockRunner;
11 |
12 | import static org.mockito.Mockito.mock;
13 | import static org.mockito.Mockito.verify;
14 |
15 | @RunWith(PowerMockRunner.class)
16 | @PrepareForTest(DeployMojo.class)
17 | public class DeployMojoTest extends MojoTestSupport {
18 |
19 | private DeployMojo deployMojo;
20 |
21 | private DockerOrchestrator mockDockerOrchestrator;
22 |
23 | @Before
24 | public void setUp() throws Exception {
25 |
26 | deployMojo = PowerMockito.spy(new DeployMojo());
27 | DockerClient mockDockerClient = mock(DockerClient.class);
28 | mockDockerOrchestrator = mock(DockerOrchestrator.class);
29 |
30 | prepareMojo(deployMojo, mockDockerClient, mockDockerOrchestrator);
31 | }
32 |
33 | @Test
34 | public void testDeploy() throws Exception {
35 | // when
36 | deployMojo.execute();
37 |
38 | // then
39 | verify(deployMojo).doExecute(mockDockerOrchestrator);
40 | verify(mockDockerOrchestrator).push();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/java/com/alexecollins/docker/mojo/MojoTestSupport.java:
--------------------------------------------------------------------------------
1 | package com.alexecollins.docker.mojo;
2 |
3 | import com.alexecollins.docker.orchestration.DockerOrchestrator;
4 | import com.github.dockerjava.api.DockerClient;
5 | import com.github.dockerjava.api.command.VersionCmd;
6 | import com.github.dockerjava.api.model.Version;
7 | import com.github.dockerjava.core.DockerClientBuilder;
8 | import com.github.dockerjava.core.DockerClientConfig;
9 | import org.apache.maven.model.Build;
10 | import org.apache.maven.project.MavenProject;
11 | import org.powermock.api.mockito.PowerMockito;
12 | import org.powermock.core.classloader.annotations.PrepareForTest;
13 | import org.powermock.reflect.Whitebox;
14 |
15 | import java.io.File;
16 | import java.util.Properties;
17 |
18 | import static org.mockito.Matchers.any;
19 | import static org.mockito.Mockito.mock;
20 | import static org.mockito.Mockito.when;
21 | import static org.powermock.api.mockito.PowerMockito.mockStatic;
22 |
23 | @PrepareForTest(DockerClientBuilder.class)
24 | public class MojoTestSupport {
25 |
26 | protected static final String PROJECT_GROUP_ID = "id.group";
27 |
28 | protected static final String PROJECT_ARTIFACT_ID = "artifact-id";
29 |
30 | protected static final String PROJECT_VERSION = "1.2.3-SNAPSHOT";
31 |
32 | protected static final String PROJECT_NAME = "project-name";
33 |
34 | protected static final String PROJECT_DESCRIPTION = "Project Description";
35 |
36 | protected static final String BUILD_DIR = "/build/dir";
37 |
38 | protected static final String BUILD_FINAL_NAME = "buildFinalName";
39 |
40 | protected static final String BASE_DIR = "src";
41 |
42 | protected static final String SRC = "main";
43 |
44 | protected static final String PREFIX = "prefix";
45 |
46 | protected static final String USERNAME = "username";
47 |
48 |
49 | protected void prepareMojo(
50 | AbstractDockerMojo dockerMojo,
51 | DockerClient mockDockerClient,
52 | DockerOrchestrator mockDockerOrchestrator) throws Exception {
53 |
54 | MavenProject mavenProject = createMavenProject();
55 | Whitebox.setInternalState(dockerMojo, "project", mavenProject);
56 | Whitebox.setInternalState(dockerMojo, "prefix", PREFIX);
57 | Whitebox.setInternalState(dockerMojo, "src", SRC);
58 | Whitebox.setInternalState(dockerMojo, "username", USERNAME);
59 |
60 | // prepare docker client
61 | if (mockDockerClient != null) {
62 | VersionCmd mockVersionCmd = mock(VersionCmd.class);
63 | Version mockVersion = mock(Version.class);
64 |
65 | DockerClientBuilder mockDockerClientBuilder = mock(DockerClientBuilder.class);
66 | when(mockDockerClientBuilder.build()).thenReturn(mockDockerClient);
67 |
68 | mockStatic(DockerClientBuilder.class);
69 | when(DockerClientBuilder.getInstance(any(DockerClientConfig.class))).thenReturn(mockDockerClientBuilder);
70 |
71 | when(mockDockerClient.versionCmd()).thenReturn(mockVersionCmd);
72 | when(mockVersionCmd.exec()).thenReturn(mockVersion);
73 | when(mockVersion.getVersion()).thenReturn("1.0");
74 | }
75 |
76 | // prepare docker orchestrator
77 | if (mockDockerOrchestrator != null) {
78 | PowerMockito.doReturn(mockDockerOrchestrator)
79 | .when(dockerMojo, "dockerOrchestrator",
80 | any(Properties.class),
81 | any(DockerClient.class)
82 | );
83 | }
84 | }
85 |
86 | protected MavenProject createMavenProject() {
87 |
88 | MavenProject mavenProject = new MavenProject();
89 | mavenProject.setGroupId(PROJECT_GROUP_ID);
90 | mavenProject.setArtifactId(PROJECT_ARTIFACT_ID);
91 | mavenProject.setVersion(PROJECT_VERSION);
92 | mavenProject.setName(PROJECT_NAME);
93 | mavenProject.setDescription(PROJECT_DESCRIPTION);
94 | mavenProject.setBuild(createBuild());
95 |
96 | mavenProject.setFile(new File(new File(BASE_DIR), "file"));
97 |
98 | return mavenProject;
99 | }
100 |
101 | protected Build createBuild() {
102 |
103 | Build build = new Build();
104 |
105 | build.setDirectory(BUILD_DIR);
106 | build.setFinalName(BUILD_FINAL_NAME);
107 |
108 | return build;
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/src/test/java/com/alexecollins/docker/mojo/PackageMojoTest.java:
--------------------------------------------------------------------------------
1 | package com.alexecollins.docker.mojo;
2 |
3 | import com.alexecollins.docker.orchestration.DockerOrchestrator;
4 | import com.github.dockerjava.api.DockerClient;
5 | import org.junit.Before;
6 | import org.junit.Test;
7 | import org.junit.runner.RunWith;
8 | import org.powermock.api.mockito.PowerMockito;
9 | import org.powermock.core.classloader.annotations.PrepareForTest;
10 | import org.powermock.modules.junit4.PowerMockRunner;
11 |
12 | import static org.mockito.Mockito.mock;
13 | import static org.mockito.Mockito.verify;
14 |
15 | @RunWith(PowerMockRunner.class)
16 | @PrepareForTest(PackageMojo.class)
17 | public class PackageMojoTest extends MojoTestSupport {
18 |
19 | private PackageMojo packageMojo;
20 |
21 | private DockerOrchestrator mockDockerOrchestrator;
22 |
23 | @Before
24 | public void setUp() throws Exception {
25 |
26 | packageMojo = PowerMockito.spy(new PackageMojo());
27 | DockerClient mockDockerClient = mock(DockerClient.class);
28 | mockDockerOrchestrator = mock(DockerOrchestrator.class);
29 |
30 | prepareMojo(packageMojo, mockDockerClient, mockDockerOrchestrator);
31 | }
32 |
33 | @Test
34 | public void testPackage() throws Exception {
35 | // when
36 | packageMojo.execute();
37 |
38 | // then
39 | verify(packageMojo).doExecute(mockDockerOrchestrator);
40 | verify(mockDockerOrchestrator).build();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/java/com/alexecollins/docker/mojo/SaveMojoTest.java:
--------------------------------------------------------------------------------
1 | package com.alexecollins.docker.mojo;
2 |
3 | import com.alexecollins.docker.orchestration.DockerOrchestrator;
4 | import com.alexecollins.docker.orchestration.model.Id;
5 | import com.github.dockerjava.api.DockerClient;
6 | import org.apache.commons.io.FilenameUtils;
7 | import org.apache.maven.project.MavenProject;
8 | import org.apache.maven.project.MavenProjectHelper;
9 | import org.junit.Before;
10 | import org.junit.BeforeClass;
11 | import org.junit.Test;
12 | import org.junit.runner.RunWith;
13 | import org.powermock.api.mockito.PowerMockito;
14 | import org.powermock.core.classloader.annotations.PrepareForTest;
15 | import org.powermock.modules.junit4.PowerMockRunner;
16 | import org.powermock.reflect.Whitebox;
17 |
18 | import java.io.File;
19 | import java.util.Collections;
20 | import java.util.HashMap;
21 | import java.util.Map;
22 |
23 | import static org.mockito.Matchers.any;
24 | import static org.mockito.Matchers.anyString;
25 | import static org.mockito.Mockito.doReturn;
26 | import static org.mockito.Mockito.mock;
27 | import static org.mockito.Mockito.never;
28 | import static org.mockito.Mockito.verify;
29 | import static org.mockito.Mockito.when;
30 | import static org.powermock.api.mockito.PowerMockito.mockStatic;
31 |
32 | @RunWith(PowerMockRunner.class)
33 | @PrepareForTest({SaveMojo.class, FilenameUtils.class})
34 | public class SaveMojoTest extends MojoTestSupport {
35 |
36 | private static final String SAVE_DIR = "/save/dir";
37 |
38 | private static final String EXTENSION = "ext";
39 |
40 | private static Map SAVED_FILES;
41 |
42 | private SaveMojo saveMojo;
43 |
44 | private DockerOrchestrator mockDockerOrchestrator;
45 |
46 | private File saveDir;
47 |
48 | private MavenProjectHelper mavenProjectHelper;
49 |
50 | @BeforeClass
51 | public static void init() {
52 | SAVED_FILES = new HashMap<>();
53 |
54 | SAVED_FILES.put(new Id("id1"), new File("/saved/file1.ext"));
55 | SAVED_FILES.put(new Id("id2"), new File("/saved/file2.ext"));
56 | SAVED_FILES.put(new Id("id3"), new File("/saved/file3.ext"));
57 |
58 | SAVED_FILES = Collections.unmodifiableMap(SAVED_FILES);
59 | }
60 |
61 | @Before
62 | public void setUp() throws Exception {
63 |
64 | saveMojo = PowerMockito.spy(new SaveMojo());
65 |
66 | saveDir = new File(SAVE_DIR);
67 |
68 | DockerClient mockDockerClient = mock(DockerClient.class);
69 |
70 | mockDockerOrchestrator = mock(DockerOrchestrator.class);
71 | when(mockDockerOrchestrator.save(saveDir, true)).thenReturn(SAVED_FILES);
72 |
73 | prepareMojo(saveMojo, mockDockerClient, mockDockerOrchestrator);
74 |
75 | Whitebox.setInternalState(saveMojo, "saveDir", saveDir);
76 | Whitebox.setInternalState(saveMojo, "gzipSave", true);
77 |
78 | mavenProjectHelper = mock(MavenProjectHelper.class);
79 | Whitebox.setInternalState(saveMojo, "mavenProjectHelper", mavenProjectHelper);
80 | }
81 |
82 | @Test
83 | public void testSaveWithAttach() throws Exception {
84 | // given
85 | Whitebox.setInternalState(saveMojo, "attach", true);
86 | PowerMockito.mockStatic(FilenameUtils.class);
87 | PowerMockito.when(FilenameUtils.getExtension(anyString())).thenReturn(EXTENSION);
88 |
89 | // when
90 | saveMojo.execute();
91 |
92 | // then
93 | verify(saveMojo).doExecute(mockDockerOrchestrator);
94 | verify(mockDockerOrchestrator).save(saveDir, true);
95 |
96 | for (Id id : SAVED_FILES.keySet()) {
97 | verify(mavenProjectHelper).attachArtifact(
98 | saveMojo.getProject(), EXTENSION, id.toString(), SAVED_FILES.get(id)
99 | );
100 | }
101 | }
102 |
103 | @Test
104 | public void testSaveWithoutAttach() throws Exception {
105 | // when
106 | saveMojo.execute();
107 |
108 | // then
109 | verify(saveMojo).doExecute(mockDockerOrchestrator);
110 | verify(mockDockerOrchestrator).save(saveDir, true);
111 | verify(mavenProjectHelper, never()).attachArtifact(
112 | any(MavenProject.class), anyString(), anyString(), any(File.class)
113 | );
114 | }
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/src/test/java/com/alexecollins/docker/mojo/StartMojoTest.java:
--------------------------------------------------------------------------------
1 | package com.alexecollins.docker.mojo;
2 |
3 | import com.alexecollins.docker.orchestration.DockerOrchestrator;
4 | import com.github.dockerjava.api.DockerClient;
5 | import org.junit.Before;
6 | import org.junit.BeforeClass;
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 | import org.powermock.api.mockito.PowerMockito;
10 | import org.powermock.core.classloader.annotations.PrepareForTest;
11 | import org.powermock.modules.junit4.PowerMockRunner;
12 |
13 | import java.util.Collections;
14 | import java.util.HashMap;
15 | import java.util.Map;
16 | import java.util.Properties;
17 |
18 | import static org.junit.Assert.assertEquals;
19 | import static org.mockito.Mockito.doReturn;
20 | import static org.mockito.Mockito.mock;
21 | import static org.mockito.Mockito.verify;
22 |
23 | @RunWith(PowerMockRunner.class)
24 | @PrepareForTest(StartMojo.class)
25 | public class StartMojoTest extends MojoTestSupport {
26 |
27 | private static Map IP_ADDRESSES;
28 |
29 | private StartMojo startMojo;
30 |
31 | private DockerOrchestrator mockDockerOrchestrator;
32 |
33 | @BeforeClass
34 | public static void init() {
35 |
36 | IP_ADDRESSES = new HashMap<>();
37 |
38 | IP_ADDRESSES.put("ip1", "10.10.0.1");
39 | IP_ADDRESSES.put("ip2", "10.10.0.2");
40 | IP_ADDRESSES.put("ip3", "10.10.0.3");
41 | IP_ADDRESSES.put("ip4", "10.10.0.4");
42 |
43 | IP_ADDRESSES = Collections.unmodifiableMap(IP_ADDRESSES);
44 | }
45 |
46 | @Before
47 | public void setUp() throws Exception {
48 |
49 | startMojo = PowerMockito.spy(new StartMojo());
50 | DockerClient mockDockerClient = mock(DockerClient.class);
51 |
52 | mockDockerOrchestrator = mock(DockerOrchestrator.class);
53 | doReturn(IP_ADDRESSES).when(mockDockerOrchestrator).getIPAddresses();
54 |
55 | prepareMojo(startMojo, mockDockerClient, mockDockerOrchestrator);
56 | }
57 |
58 | @Test
59 | public void testStart() throws Exception {
60 | // when
61 | startMojo.execute();
62 |
63 | // then
64 | verify(startMojo).doExecute(mockDockerOrchestrator);
65 | verify(mockDockerOrchestrator).start();
66 |
67 | Properties projectProperties = startMojo.getProject().getProperties();
68 |
69 | assertEquals(IP_ADDRESSES.size(), projectProperties.size());
70 |
71 | for (String key : IP_ADDRESSES.keySet()) {
72 | assertEquals(IP_ADDRESSES.get(key), projectProperties.getProperty("docker." + key + ".ipAddress"));
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/test/java/com/alexecollins/docker/mojo/StopMojoTest.java:
--------------------------------------------------------------------------------
1 | package com.alexecollins.docker.mojo;
2 |
3 | import com.alexecollins.docker.orchestration.DockerOrchestrator;
4 | import com.github.dockerjava.api.DockerClient;
5 | import org.junit.Before;
6 | import org.junit.Test;
7 | import org.junit.runner.RunWith;
8 | import org.powermock.api.mockito.PowerMockito;
9 | import org.powermock.core.classloader.annotations.PrepareForTest;
10 | import org.powermock.modules.junit4.PowerMockRunner;
11 |
12 | import static org.mockito.Mockito.mock;
13 | import static org.mockito.Mockito.verify;
14 |
15 | @RunWith(PowerMockRunner.class)
16 | @PrepareForTest(StopMojo.class)
17 | public class StopMojoTest extends MojoTestSupport {
18 |
19 | private StopMojo stopMojo;
20 |
21 | private DockerOrchestrator mockDockerOrchestrator;
22 |
23 | @Before
24 | public void setUp() throws Exception {
25 |
26 | stopMojo = PowerMockito.spy(new StopMojo());
27 | DockerClient mockDockerClient = mock(DockerClient.class);
28 | mockDockerOrchestrator = mock(DockerOrchestrator.class);
29 |
30 | prepareMojo(stopMojo, mockDockerClient, mockDockerOrchestrator);
31 | }
32 |
33 | @Test
34 | public void testStop() throws Exception {
35 | // when
36 | stopMojo.execute();
37 |
38 | // then
39 | verify(stopMojo).doExecute(mockDockerOrchestrator);
40 | verify(mockDockerOrchestrator).stop();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/java/com/alexecollins/docker/mojo/ValidateMojoTest.java:
--------------------------------------------------------------------------------
1 | package com.alexecollins.docker.mojo;
2 |
3 | import com.alexecollins.docker.orchestration.DockerOrchestrator;
4 | import com.github.dockerjava.api.DockerClient;
5 | import org.junit.Before;
6 | import org.junit.Test;
7 | import org.junit.runner.RunWith;
8 | import org.powermock.api.mockito.PowerMockito;
9 | import org.powermock.core.classloader.annotations.PrepareForTest;
10 | import org.powermock.modules.junit4.PowerMockRunner;
11 |
12 | import static org.mockito.Mockito.mock;
13 | import static org.mockito.Mockito.verify;
14 |
15 | @RunWith(PowerMockRunner.class)
16 | @PrepareForTest(ValidateMojo.class)
17 | public class ValidateMojoTest extends MojoTestSupport {
18 |
19 | private ValidateMojo validateMojo;
20 |
21 | private DockerOrchestrator mockDockerOrchestrator;
22 |
23 | @Before
24 | public void setUp() throws Exception {
25 |
26 | validateMojo = PowerMockito.spy(new ValidateMojo());
27 | DockerClient mockDockerClient = mock(DockerClient.class);
28 | mockDockerOrchestrator = mock(DockerOrchestrator.class);
29 |
30 | prepareMojo(validateMojo, mockDockerClient, mockDockerOrchestrator);
31 | }
32 |
33 | @Test
34 | public void testValidate() throws Exception {
35 | // when
36 | validateMojo.execute();
37 |
38 | // then
39 | verify(validateMojo).doExecute(mockDockerOrchestrator);
40 | verify(mockDockerOrchestrator).validate();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/java/com/alexecollins/docker/util/MavenLogAppenderTest.java:
--------------------------------------------------------------------------------
1 | package com.alexecollins.docker.util;
2 |
3 |
4 | import ch.qos.logback.classic.Level;
5 | import ch.qos.logback.classic.spi.ILoggingEvent;
6 | import ch.qos.logback.classic.spi.LoggingEvent;
7 | import org.apache.maven.plugin.logging.Log;
8 | import org.junit.Before;
9 | import org.junit.Test;
10 | import org.junit.runner.RunWith;
11 | import org.powermock.modules.junit4.PowerMockRunner;
12 |
13 | import static org.mockito.Matchers.anyString;
14 | import static org.mockito.Matchers.eq;
15 | import static org.mockito.Mockito.doReturn;
16 | import static org.mockito.Mockito.mock;
17 | import static org.mockito.Mockito.never;
18 | import static org.mockito.Mockito.verify;
19 |
20 | @RunWith(PowerMockRunner.class)
21 | public class MavenLogAppenderTest {
22 |
23 | private static final String ERROR_MESAGE = "error message";
24 |
25 | private static final String WARN_MESAGE = "warn message";
26 |
27 | private static final String INFO_MESAGE = "info message";
28 |
29 | private static final String DEBUG_MESAGE = "debug message";
30 |
31 | private static final String TRACE_MESSAGE = "trace message";
32 |
33 | private static final String ALL_MESSAGE = "all message";
34 |
35 |
36 | private static Log log;
37 |
38 | private MavenLogAppender mavenLogAppender;
39 |
40 | @Before
41 | public void setUp() {
42 | log = mock(Log.class);
43 | MavenLogAppender.setLog(log);
44 |
45 | mavenLogAppender = new MavenLogAppender();
46 | }
47 |
48 | @Test
49 | public void testErrorLogLevel() {
50 | // given
51 | ILoggingEvent event = createLoggingEvent(Level.ERROR, ERROR_MESAGE);
52 |
53 | // when
54 | mavenLogAppender.append(event);
55 |
56 | // then
57 | verify(log).error(ERROR_MESAGE);
58 | verify(log, never()).warn(anyString());
59 | verify(log, never()).info(anyString());
60 | verify(log, never()).debug(anyString());
61 | }
62 |
63 | @Test
64 | public void testWarnLogLevel() {
65 | // given
66 | ILoggingEvent event = createLoggingEvent(Level.WARN, WARN_MESAGE);
67 |
68 | // when
69 | mavenLogAppender.append(event);
70 |
71 | // then
72 | verify(log, never()).error(anyString());
73 | verify(log).warn(WARN_MESAGE);
74 | verify(log, never()).info(anyString());
75 | verify(log, never()).debug(anyString());
76 | }
77 |
78 | @Test
79 | public void testInfoLogLevel() {
80 | // given
81 | ILoggingEvent event = createLoggingEvent(Level.INFO, INFO_MESAGE);
82 |
83 | // when
84 | mavenLogAppender.append(event);
85 |
86 | // then
87 | verify(log, never()).error(anyString());
88 | verify(log, never()).warn(anyString());
89 | verify(log).info(INFO_MESAGE);
90 | verify(log, never()).debug(anyString());
91 | }
92 |
93 | @Test
94 | public void testDebugLogLevel() {
95 | // given
96 | ILoggingEvent event = createLoggingEvent(Level.DEBUG, DEBUG_MESAGE);
97 |
98 | // when
99 | mavenLogAppender.append(event);
100 |
101 | // then
102 | verify(log, never()).error(anyString());
103 | verify(log, never()).warn(anyString());
104 | verify(log, never()).info(anyString());
105 | verify(log).debug(eq(DEBUG_MESAGE));
106 | }
107 |
108 | @Test
109 | public void testTraceLogLevel() {
110 | // given
111 | ILoggingEvent event = createLoggingEvent(Level.TRACE, TRACE_MESSAGE);
112 |
113 | // when
114 | mavenLogAppender.append(event);
115 |
116 | // then
117 | verify(log, never()).error(anyString());
118 | verify(log, never()).warn(anyString());
119 | verify(log, never()).info(anyString());
120 | verify(log).debug(TRACE_MESSAGE);
121 | }
122 |
123 | @Test
124 | public void testAllLogLevel() {
125 | // given
126 | ILoggingEvent event = createLoggingEvent(Level.ALL, ALL_MESSAGE);
127 |
128 | // when
129 | mavenLogAppender.append(event);
130 |
131 | // then
132 | verify(log, never()).error(anyString());
133 | verify(log, never()).warn(anyString());
134 | verify(log, never()).info(anyString());
135 | verify(log).debug(ALL_MESSAGE);
136 | }
137 |
138 | private ILoggingEvent createLoggingEvent(Level level, String message) {
139 | ILoggingEvent event = mock(LoggingEvent.class);
140 |
141 | doReturn(level).when(event).getLevel();
142 | doReturn(message).when(event).getMessage();
143 |
144 | return event;
145 | }
146 | }
147 |
--------------------------------------------------------------------------------
/src/test/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | %msg%n
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------