Skip to content

Commit 7df69df

Browse files
committed
Streamline Docker image build process
* Don't run unnecessary build steps when building the Docker image * Always build JAR with dependencies when building the CLI module (refs OpenAPITools#114)
1 parent 9ec0290 commit 7df69df

File tree

3 files changed

+76
-61
lines changed

3 files changed

+76
-61
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
FROM openjdk:8-jdk-alpine AS build
22
WORKDIR /build
33
COPY ./ /build
4-
RUN ./mvnw -V -B -ff -P cli package -q
4+
RUN ./mvnw -V -B -ff -P docker package -q
55

66
FROM openjdk:8-jre-alpine
77
WORKDIR /app
8-
COPY --from=build /build/cli/target/cli-jar-with-dependencies.jar /app/openapi-diff.jar
8+
COPY --from=build /build/cli/target/openapi-diff-jar-with-dependencies.jar /app/openapi-diff.jar
99
ENTRYPOINT ["java", "-jar", "/app/openapi-diff.jar"]
1010
CMD ["--help"]

cli/pom.xml

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -37,57 +37,31 @@
3737
<artifactId>slf4j-log4j12</artifactId>
3838
</dependency>
3939
</dependencies>
40-
41-
<profiles>
42-
<profile>
43-
<id>cli</id>
44-
<properties>
45-
<maven.javadoc.skip>true</maven.javadoc.skip>
46-
<maven.source.skip>true</maven.source.skip>
47-
</properties>
48-
<build>
49-
<plugins>
50-
<plugin>
51-
<groupId>org.apache.maven.plugins</groupId>
52-
<artifactId>maven-assembly-plugin</artifactId>
53-
<version>3.3.0</version>
54-
<configuration>
55-
<descriptorRefs>
56-
<descriptorRef>jar-with-dependencies</descriptorRef>
57-
</descriptorRefs>
58-
<archive>
59-
<manifest>
60-
<mainClass>com.qdesrame.openapi.diff.cli.Main</mainClass>
61-
</manifest>
62-
</archive>
63-
<finalName>${project.artifactId}</finalName>
64-
</configuration>
65-
<executions>
66-
<execution>
67-
<id>make-assembly</id>
68-
<phase>package</phase>
69-
<goals>
70-
<goal>single</goal>
71-
</goals>
72-
</execution>
73-
</executions>
74-
</plugin>
75-
</plugins>
76-
</build>
77-
</profile>
78-
</profiles>
7940
<build>
8041
<plugins>
8142
<plugin>
8243
<groupId>org.apache.maven.plugins</groupId>
8344
<artifactId>maven-assembly-plugin</artifactId>
8445
<configuration>
46+
<descriptorRefs>
47+
<descriptorRef>jar-with-dependencies</descriptorRef>
48+
</descriptorRefs>
8549
<archive>
8650
<manifest>
8751
<mainClass>com.qdesrame.openapi.diff.cli.Main</mainClass>
8852
</manifest>
8953
</archive>
54+
<finalName>openapi-diff</finalName>
9055
</configuration>
56+
<executions>
57+
<execution>
58+
<id>make-assembly</id>
59+
<phase>package</phase>
60+
<goals>
61+
<goal>single</goal>
62+
</goals>
63+
</execution>
64+
</executions>
9165
</plugin>
9266
</plugins>
9367
</build>

pom.xml

Lines changed: 61 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,18 @@
147147
</dependencyManagement>
148148

149149
<profiles>
150+
<profile>
151+
<!-- Don't run unnecessary steps when building Docker container -->
152+
<id>docker</id>
153+
<properties>
154+
<maven.test.skip>true</maven.test.skip>
155+
<maven.javadoc.skip>true</maven.javadoc.skip>
156+
<maven.source.skip>true</maven.source.skip>
157+
<maven.install.skip>true</maven.install.skip>
158+
<maven.deploy.skip>true</maven.deploy.skip>
159+
<fmt.skip>true</fmt.skip>
160+
</properties>
161+
</profile>
150162
<profile>
151163
<id>release-sign-artifacts</id>
152164
<activation>
@@ -160,7 +172,6 @@
160172
<plugin>
161173
<groupId>org.apache.maven.plugins</groupId>
162174
<artifactId>maven-gpg-plugin</artifactId>
163-
<version>1.6</version>
164175
<configuration>
165176
<gpgArguments>
166177
<arg>--pinentry-mode</arg>
@@ -182,16 +193,63 @@
182193
</profile>
183194
</profiles>
184195
<build>
196+
<pluginManagement>
197+
<plugins>
198+
<plugin>
199+
<groupId>org.apache.maven.plugins</groupId>
200+
<artifactId>maven-compiler-plugin</artifactId>
201+
<version>3.8.1</version>
202+
</plugin>
203+
<plugin>
204+
<groupId>org.apache.maven.plugins</groupId>
205+
<artifactId>maven-source-plugin</artifactId>
206+
<version>3.2.1</version>
207+
</plugin>
208+
<plugin>
209+
<groupId>org.apache.maven.plugins</groupId>
210+
<artifactId>maven-release-plugin</artifactId>
211+
<version>2.5.3</version>
212+
</plugin>
213+
<plugin>
214+
<groupId>org.apache.maven.plugins</groupId>
215+
<artifactId>maven-javadoc-plugin</artifactId>
216+
<version>3.2.0</version>
217+
</plugin>
218+
<plugin>
219+
<groupId>org.apache.maven.plugins</groupId>
220+
<artifactId>maven-assembly-plugin</artifactId>
221+
<version>3.3.0</version>
222+
</plugin>
223+
<plugin>
224+
<groupId>org.apache.maven.plugins</groupId>
225+
<artifactId>maven-surefire-plugin</artifactId>
226+
<version>2.22.2</version>
227+
</plugin>
228+
<plugin>
229+
<groupId>com.coveo</groupId>
230+
<artifactId>fmt-maven-plugin</artifactId>
231+
<version>2.9.1</version>
232+
</plugin>
233+
<plugin>
234+
<groupId>io.github.phillipuniverse</groupId>
235+
<artifactId>githook-maven-plugin</artifactId>
236+
<version>1.0.5</version>
237+
</plugin>
238+
<plugin>
239+
<groupId>org.apache.maven.plugins</groupId>
240+
<artifactId>maven-gpg-plugin</artifactId>
241+
<version>1.6</version>
242+
</plugin>
243+
</plugins>
244+
</pluginManagement>
185245
<plugins>
186246
<plugin>
187247
<groupId>org.apache.maven.plugins</groupId>
188248
<artifactId>maven-compiler-plugin</artifactId>
189-
<version>3.8.1</version>
190249
</plugin>
191250
<plugin>
192251
<groupId>org.apache.maven.plugins</groupId>
193252
<artifactId>maven-source-plugin</artifactId>
194-
<version>3.2.1</version>
195253
<executions>
196254
<execution>
197255
<phase>package</phase>
@@ -204,18 +262,15 @@
204262
<plugin>
205263
<groupId>org.apache.maven.plugins</groupId>
206264
<artifactId>maven-release-plugin</artifactId>
207-
<version>2.5.3</version>
208265
<configuration>
209266
<tagNameFormat>@{project.version}</tagNameFormat>
210267
<autoVersionSubmodules>true</autoVersionSubmodules>
211268
<releaseProfiles>releases</releaseProfiles>
212269
</configuration>
213270
</plugin>
214-
<!-- Javadoc -->
215271
<plugin>
216272
<groupId>org.apache.maven.plugins</groupId>
217273
<artifactId>maven-javadoc-plugin</artifactId>
218-
<version>3.2.0</version>
219274
<configuration>
220275
<quiet>true</quiet>
221276
<nonavbar>true</nonavbar>
@@ -232,26 +287,13 @@
232287
</execution>
233288
</executions>
234289
</plugin>
235-
<plugin>
236-
<groupId>org.apache.maven.plugins</groupId>
237-
<artifactId>maven-assembly-plugin</artifactId>
238-
<configuration>
239-
<archive>
240-
<manifest>
241-
<mainClass>com.qdesrame.openapi.diff.cli.Main</mainClass>
242-
</manifest>
243-
</archive>
244-
</configuration>
245-
</plugin>
246290
<plugin>
247291
<groupId>org.apache.maven.plugins</groupId>
248292
<artifactId>maven-surefire-plugin</artifactId>
249-
<version>2.22.2</version>
250293
</plugin>
251294
<plugin>
252295
<groupId>com.coveo</groupId>
253296
<artifactId>fmt-maven-plugin</artifactId>
254-
<version>2.9.1</version>
255297
<executions>
256298
<execution>
257299
<goals>
@@ -263,7 +305,6 @@
263305
<plugin>
264306
<groupId>io.github.phillipuniverse</groupId>
265307
<artifactId>githook-maven-plugin</artifactId>
266-
<version>1.0.5</version>
267308
<executions>
268309
<execution>
269310
<goals>

0 commit comments

Comments
 (0)