Skip to content

Commit a68b58d

Browse files
authored
[refactor][ci] Build the docker image with docker-maven-plugin (apache#17148)
1 parent c4bd7ae commit a68b58d

File tree

8 files changed

+155
-105
lines changed

8 files changed

+155
-105
lines changed

.github/actions/tune-runner-vm/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ runs:
7878
sudo systemctl stop walinuxagent.service || true
7979
8080
# enable docker experimental mode which is
81-
# required for using "docker build --squash" / "-Ddockerfile.build.squash=true"
81+
# required for using "docker build --squash" / "-Ddocker.squash=true"
8282
daemon_json="$(sudo cat /etc/docker/daemon.json | jq '.experimental = true')"
8383
echo "$daemon_json" | sudo tee /etc/docker/daemon.json
8484
# restart docker daemon

.github/workflows/pulsar-ci.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ jobs:
322322
run: |
323323
# build docker image
324324
mvn -B -am -pl tests/docker-images/java-test-image install -Pcore-modules,-main,integrationTests,docker \
325-
-Dmaven.test.skip=true -Ddockerfile.build.squash=true -DskipSourceReleaseAssembly=true \
325+
-Dmaven.test.skip=true -Ddocker.squash=true -DskipSourceReleaseAssembly=true \
326326
-Dspotbugs.skip=true -Dlicense.skip=true -Dcheckstyle.skip=true -Drat.skip=true
327327
328328
- name: save docker image apachepulsar/java-test-image:latest to Github artifact cache
@@ -576,7 +576,7 @@ jobs:
576576
# build docker image
577577
# include building of Pulsar SQL, Connectors, Offloaders and server distros
578578
mvn -B -am -pl pulsar-sql/presto-distribution,distribution/io,distribution/offloaders,distribution/server,tests/docker-images/latest-version-image install \
579-
-Pmain,docker -Dmaven.test.skip=true -Ddockerfile.build.squash=true \
579+
-Pmain,docker -Dmaven.test.skip=true -Ddocker.squash=true \
580580
-Dspotbugs.skip=true -Dlicense.skip=true -Dcheckstyle.skip=true -Drat.skip=true
581581
582582
- name: save docker image apachepulsar/pulsar-test-latest-version:latest to Github artifact cache

build/build_java_test_image.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ SQUASH_PARAM=""
2424
# check if docker experimental mode is enabled which is required for
2525
# using "docker build --squash" for squashing all intermediate layers of the build to a single layer
2626
if [[ "$(docker version -f '{{.Server.Experimental}}' 2>/dev/null)" == "true" ]]; then
27-
SQUASH_PARAM="-Ddockerfile.build.squash=true"
27+
SQUASH_PARAM="-Ddocker.squash=true"
2828
fi
2929
mvn -am -pl tests/docker-images/java-test-image -Pcore-modules,-main,integrationTests,docker \
3030
-Dmaven.test.skip=true -DskipSourceReleaseAssembly=true -Dspotbugs.skip=true -Dlicense.skip=true $SQUASH_PARAM \

docker/pulsar-all/pom.xml

+55-30
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,24 @@
6868
<profiles>
6969
<profile>
7070
<id>docker</id>
71+
<properties>
72+
<docker.buildArg.PULSAR_IO_DIR>target/apache-pulsar-io-connectors-${project.version}-bin</docker.buildArg.PULSAR_IO_DIR>
73+
<docker.buildArg.PULSAR_OFFLOADER_TARBALL>target/pulsar-offloader-distribution-${project.version}-bin.tar.gz</docker.buildArg.PULSAR_OFFLOADER_TARBALL>
74+
</properties>
7175
<!-- include the docker image only when docker profile is active -->
7276
<dependencies>
7377
<dependency>
7478
<groupId>${project.groupId}</groupId>
7579
<artifactId>pulsar-docker-image</artifactId>
7680
<version>${project.version}</version>
77-
<classifier>docker-info</classifier>
81+
<type>pom</type>
82+
<scope>provided</scope>
83+
<exclusions>
84+
<exclusion>
85+
<groupId>*</groupId>
86+
<artifactId>*</artifactId>
87+
</exclusion>
88+
</exclusions>
7889
</dependency>
7990
</dependencies>
8091
<build>
@@ -119,57 +130,71 @@
119130
</executions>
120131
</plugin>
121132
<plugin>
122-
<groupId>com.spotify</groupId>
123-
<artifactId>dockerfile-maven-plugin</artifactId>
124-
<version>${dockerfile-maven.version}</version>
133+
<groupId>io.fabric8</groupId>
134+
<artifactId>docker-maven-plugin</artifactId>
125135
<executions>
126136
<execution>
127137
<id>default</id>
138+
<phase>package</phase>
128139
<goals>
129140
<goal>build</goal>
130141
</goals>
131-
</execution>
132-
<execution>
133-
<id>add-no-repo-and-version</id>
134-
<goals>
135-
<goal>tag</goal>
136-
</goals>
137142
<configuration>
138-
<repository>pulsar-all</repository>
139-
<tag>${project.version}</tag>
143+
<images>
144+
<image>
145+
<name>${docker.organization}/pulsar-all</name>
146+
<build>
147+
<contextDir>${project.basedir}</contextDir>
148+
<tags>
149+
<tag>latest</tag>
150+
<tag>${project.version}</tag>
151+
</tags>
152+
</build>
153+
</image>
154+
</images>
140155
</configuration>
141156
</execution>
142157
<execution>
143-
<id>add-no-repo-and-latest</id>
158+
<id>push-latest</id>
144159
<goals>
145-
<goal>tag</goal>
160+
<goal>push</goal>
146161
</goals>
147162
<configuration>
148-
<repository>pulsar-all</repository>
149-
<tag>latest</tag>
163+
<images>
164+
<image>
165+
<name>${docker.organization}/pulsar-all</name>
166+
<build>
167+
<contextDir>${project.basedir}</contextDir>
168+
<tags>
169+
<tag>latest</tag>
170+
</tags>
171+
</build>
172+
</image>
173+
</images>
150174
</configuration>
151175
</execution>
152176
<execution>
153-
<id>tag-and-push-latest</id>
177+
<id>add-no-repo</id>
178+
<phase>package</phase>
154179
<goals>
155-
<goal>tag</goal>
156-
<goal>push</goal>
180+
<goal>build</goal>
157181
</goals>
158182
<configuration>
159-
<repository>${docker.organization}/pulsar-all</repository>
160-
<tag>latest</tag>
183+
<images>
184+
<image>
185+
<name>pulsar-all</name>
186+
<build>
187+
<contextDir>${project.basedir}</contextDir>
188+
<tags>
189+
<tag>latest</tag>
190+
<tag>${project.version}</tag>
191+
</tags>
192+
</build>
193+
</image>
194+
</images>
161195
</configuration>
162196
</execution>
163197
</executions>
164-
<configuration>
165-
<repository>${docker.organization}/pulsar-all</repository>
166-
<pullNewerImage>false</pullNewerImage>
167-
<tag>${project.version}</tag>
168-
<buildArgs>
169-
<PULSAR_IO_DIR>target/apache-pulsar-io-connectors-${project.version}-bin</PULSAR_IO_DIR>
170-
<PULSAR_OFFLOADER_TARBALL>target/pulsar-offloader-distribution-${project.version}-bin.tar.gz</PULSAR_OFFLOADER_TARBALL>
171-
</buildArgs>
172-
</configuration>
173198
</plugin>
174199
</plugins>
175200
</build>

docker/pulsar/pom.xml

+47-29
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
<profiles>
5656
<profile>
5757
<id>docker</id>
58+
<properties>
59+
<docker.buildArg.PULSAR_TARBALL>target/pulsar-server-distribution-${project.version}-bin.tar.gz</docker.buildArg.PULSAR_TARBALL>
60+
<docker.buildArg.UBUNTU_MIRROR>${env.UBUNTU_MIRROR}</docker.buildArg.UBUNTU_MIRROR>
61+
</properties>
5862
<build>
5963
<plugins>
6064
<!-- build Python client, copy the wheel file and then build docker image -->
@@ -103,57 +107,71 @@
103107
</executions>
104108
</plugin>
105109
<plugin>
106-
<groupId>com.spotify</groupId>
107-
<artifactId>dockerfile-maven-plugin</artifactId>
108-
<version>${dockerfile-maven.version}</version>
110+
<groupId>io.fabric8</groupId>
111+
<artifactId>docker-maven-plugin</artifactId>
109112
<executions>
110113
<execution>
111114
<id>default</id>
115+
<phase>package</phase>
112116
<goals>
113117
<goal>build</goal>
114118
</goals>
115-
</execution>
116-
<execution>
117-
<id>add-no-repo-and-version</id>
118-
<goals>
119-
<goal>tag</goal>
120-
</goals>
121119
<configuration>
122-
<repository>pulsar</repository>
123-
<tag>${project.version}</tag>
120+
<images>
121+
<image>
122+
<name>${docker.organization}/pulsar</name>
123+
<build>
124+
<contextDir>${project.basedir}</contextDir>
125+
<tags>
126+
<tag>latest</tag>
127+
<tag>${project.version}</tag>
128+
</tags>
129+
</build>
130+
</image>
131+
</images>
124132
</configuration>
125133
</execution>
126134
<execution>
127-
<id>add-no-repo-and-latest</id>
135+
<id>push-latest</id>
128136
<goals>
129-
<goal>tag</goal>
137+
<goal>push</goal>
130138
</goals>
131139
<configuration>
132-
<repository>pulsar</repository>
133-
<tag>latest</tag>
140+
<images>
141+
<image>
142+
<name>${docker.organization}/pulsar</name>
143+
<build>
144+
<contextDir>${project.basedir}</contextDir>
145+
<tags>
146+
<tag>latest</tag>
147+
</tags>
148+
</build>
149+
</image>
150+
</images>
134151
</configuration>
135152
</execution>
136153
<execution>
137-
<id>tag-and-push-latest</id>
154+
<id>add-no-repo</id>
155+
<phase>package</phase>
138156
<goals>
139-
<goal>tag</goal>
140-
<goal>push</goal>
157+
<goal>build</goal>
141158
</goals>
142159
<configuration>
143-
<repository>${docker.organization}/pulsar</repository>
144-
<tag>latest</tag>
160+
<images>
161+
<image>
162+
<name>pulsar</name>
163+
<build>
164+
<contextDir>${project.basedir}</contextDir>
165+
<tags>
166+
<tag>latest</tag>
167+
<tag>${project.version}</tag>
168+
</tags>
169+
</build>
170+
</image>
171+
</images>
145172
</configuration>
146173
</execution>
147174
</executions>
148-
<configuration>
149-
<repository>${docker.organization}/pulsar</repository>
150-
<pullNewerImage>false</pullNewerImage>
151-
<tag>${project.version}</tag>
152-
<buildArgs>
153-
<PULSAR_TARBALL>target/pulsar-server-distribution-${project.version}-bin.tar.gz</PULSAR_TARBALL>
154-
<UBUNTU_MIRROR>${env.UBUNTU_MIRROR}</UBUNTU_MIRROR>
155-
</buildArgs>
156-
</configuration>
157175
</plugin>
158176
<plugin>
159177
<groupId>org.apache.maven.plugins</groupId>

pom.xml

+7-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ flexible messaging model and an intuitive client API.</description>
140140
<reflections.version>0.9.11</reflections.version>
141141
<swagger.version>1.6.2</swagger.version>
142142
<puppycrawl.checkstyle.version>8.37</puppycrawl.checkstyle.version>
143-
<dockerfile-maven.version>1.4.13</dockerfile-maven.version>
143+
<docker-maven.version>0.40.2</docker-maven.version>
144+
<docker.verbose>true</docker.verbose>
144145
<typetools.version>0.5.0</typetools.version>
145146
<protobuf3.version>3.19.2</protobuf3.version>
146147
<protoc3.version>${protobuf3.version}</protoc3.version>
@@ -1892,6 +1893,11 @@ flexible messaging model and an intuitive client API.</description>
18921893
<artifactId>properties-maven-plugin</artifactId>
18931894
<version>${properties-maven-plugin.version}</version>
18941895
</plugin>
1896+
<plugin>
1897+
<groupId>io.fabric8</groupId>
1898+
<artifactId>docker-maven-plugin</artifactId>
1899+
<version>${docker-maven.version}</version>
1900+
</plugin>
18951901
</plugins>
18961902
</pluginManagement>
18971903
<extensions>

tests/docker-images/java-test-image/pom.xml

+19-22
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
<profiles>
3434
<profile>
3535
<id>docker</id>
36+
<properties>
37+
<docker.buildArg.PULSAR_TARBALL>target/pulsar-server-distribution-bin.tar.gz</docker.buildArg.PULSAR_TARBALL>
38+
<docker.buildArg.UBUNTU_MIRROR>${env.UBUNTU_MIRROR}</docker.buildArg.UBUNTU_MIRROR>
39+
</properties>
3640
<activation>
3741
<property>
3842
<name>integrationTests</name>
@@ -135,39 +139,32 @@
135139
</executions>
136140
</plugin>
137141
<plugin>
138-
<groupId>com.spotify</groupId>
139-
<artifactId>dockerfile-maven-plugin</artifactId>
140-
<version>${dockerfile-maven.version}</version>
142+
<groupId>io.fabric8</groupId>
143+
<artifactId>docker-maven-plugin</artifactId>
141144
<executions>
142145
<execution>
143146
<id>default</id>
144147
<phase>package</phase>
145148
<goals>
146149
<goal>build</goal>
147150
</goals>
148-
</execution>
149-
<execution>
150-
<id>add-latest-tag</id>
151-
<phase>package</phase>
152-
<goals>
153-
<goal>tag</goal>
154-
</goals>
155151
<configuration>
156-
<repository>${docker.organization}/java-test-image</repository>
157-
<tag>latest</tag>
152+
<images>
153+
<image>
154+
<name>${docker.organization}/java-test-image</name>
155+
<build>
156+
<contextDir>${project.basedir}</contextDir>
157+
<tags>
158+
<tag>latest</tag>
159+
<tag>${project.version}</tag>
160+
</tags>
161+
<noCache>true</noCache>
162+
</build>
163+
</image>
164+
</images>
158165
</configuration>
159166
</execution>
160167
</executions>
161-
<configuration>
162-
<repository>${docker.organization}/java-test-image</repository>
163-
<tag>${project.version}</tag>
164-
<pullNewerImage>false</pullNewerImage>
165-
<noCache>true</noCache>
166-
<buildArgs>
167-
<PULSAR_TARBALL>target/pulsar-server-distribution-bin.tar.gz</PULSAR_TARBALL>
168-
<UBUNTU_MIRROR>${env.UBUNTU_MIRROR}</UBUNTU_MIRROR>
169-
</buildArgs>
170-
</configuration>
171168
</plugin>
172169
</plugins>
173170
</build>

0 commit comments

Comments
 (0)