Skip to content

Commit

Permalink
[refactor][ci] Build the docker image with docker-maven-plugin (apach…
Browse files Browse the repository at this point in the history
…e#17148)

(cherry picked from commit a68b58d)
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
  • Loading branch information
tisonkun authored and nodece committed Apr 28, 2024
1 parent 961e8e5 commit 90e1e70
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 102 deletions.
8 changes: 8 additions & 0 deletions .github/actions/tune-runner-vm/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ runs:
# stop Azure Linux agent to save RAM
sudo systemctl stop walinuxagent.service || true
# enable docker experimental mode which is
# required for using "docker build --squash" / "-Ddocker.squash=true"
daemon_json="$(sudo cat /etc/docker/daemon.json | jq '.experimental = true')"
echo "$daemon_json" | sudo tee /etc/docker/daemon.json
# restart docker daemon
sudo systemctl restart docker
echo '::endgroup::'
# show memory
free -m
Expand Down
2 changes: 1 addition & 1 deletion build/build_java_test_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SQUASH_PARAM=""
# check if docker experimental mode is enabled which is required for
# using "docker build --squash" for squashing all intermediate layers of the build to a single layer
if [[ "$(docker version -f '{{.Server.Experimental}}' 2>/dev/null)" == "true" ]]; then
SQUASH_PARAM="-Ddockerfile.build.squash=true"
SQUASH_PARAM="-Ddocker.squash=true"
fi
mvn -am -pl tests/docker-images/java-test-image -Pcore-modules,-main,integrationTests,docker \
-Dmaven.test.skip=true -DskipSourceReleaseAssembly=true -Dspotbugs.skip=true -Dlicense.skip=true $SQUASH_PARAM \
Expand Down
85 changes: 55 additions & 30 deletions docker/pulsar-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,24 @@
<profiles>
<profile>
<id>docker</id>
<properties>
<docker.buildArg.PULSAR_IO_DIR>target/apache-pulsar-io-connectors-${project.version}-bin</docker.buildArg.PULSAR_IO_DIR>
<docker.buildArg.PULSAR_OFFLOADER_TARBALL>target/pulsar-offloader-distribution-${project.version}-bin.tar.gz</docker.buildArg.PULSAR_OFFLOADER_TARBALL>
</properties>
<!-- include the docker image only when docker profile is active -->
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>pulsar-docker-image</artifactId>
<version>${project.version}</version>
<classifier>docker-info</classifier>
<type>pom</type>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
Expand Down Expand Up @@ -119,57 +130,71 @@
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>${dockerfile-maven.version}</version>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<executions>
<execution>
<id>default</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
<execution>
<id>add-no-repo-and-version</id>
<goals>
<goal>tag</goal>
</goals>
<configuration>
<repository>pulsar-all</repository>
<tag>${project.version}</tag>
<images>
<image>
<name>${docker.organization}/pulsar-all</name>
<build>
<contextDir>${project.basedir}</contextDir>
<tags>
<tag>latest</tag>
<tag>${project.version}</tag>
</tags>
</build>
</image>
</images>
</configuration>
</execution>
<execution>
<id>add-no-repo-and-latest</id>
<id>push-latest</id>
<goals>
<goal>tag</goal>
<goal>push</goal>
</goals>
<configuration>
<repository>pulsar-all</repository>
<tag>latest</tag>
<images>
<image>
<name>${docker.organization}/pulsar-all</name>
<build>
<contextDir>${project.basedir}</contextDir>
<tags>
<tag>latest</tag>
</tags>
</build>
</image>
</images>
</configuration>
</execution>
<execution>
<id>tag-and-push-latest</id>
<id>add-no-repo</id>
<phase>package</phase>
<goals>
<goal>tag</goal>
<goal>push</goal>
<goal>build</goal>
</goals>
<configuration>
<repository>${docker.organization}/pulsar-all</repository>
<tag>latest</tag>
<images>
<image>
<name>pulsar-all</name>
<build>
<contextDir>${project.basedir}</contextDir>
<tags>
<tag>latest</tag>
<tag>${project.version}</tag>
</tags>
</build>
</image>
</images>
</configuration>
</execution>
</executions>
<configuration>
<repository>${docker.organization}/pulsar-all</repository>
<pullNewerImage>false</pullNewerImage>
<tag>${project.version}</tag>
<buildArgs>
<PULSAR_IO_DIR>target/apache-pulsar-io-connectors-${project.version}-bin</PULSAR_IO_DIR>
<PULSAR_OFFLOADER_TARBALL>target/pulsar-offloader-distribution-${project.version}-bin.tar.gz</PULSAR_OFFLOADER_TARBALL>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
76 changes: 47 additions & 29 deletions docker/pulsar/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
<profiles>
<profile>
<id>docker</id>
<properties>
<docker.buildArg.PULSAR_TARBALL>target/pulsar-server-distribution-${project.version}-bin.tar.gz</docker.buildArg.PULSAR_TARBALL>
<docker.buildArg.UBUNTU_MIRROR>${env.UBUNTU_MIRROR}</docker.buildArg.UBUNTU_MIRROR>
</properties>
<build>
<plugins>
<!-- build Python client, copy the wheel file and then build docker image -->
Expand Down Expand Up @@ -103,57 +107,71 @@
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>${dockerfile-maven.version}</version>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<executions>
<execution>
<id>default</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
<execution>
<id>add-no-repo-and-version</id>
<goals>
<goal>tag</goal>
</goals>
<configuration>
<repository>pulsar</repository>
<tag>${project.version}</tag>
<images>
<image>
<name>${docker.organization}/pulsar</name>
<build>
<contextDir>${project.basedir}</contextDir>
<tags>
<tag>latest</tag>
<tag>${project.version}</tag>
</tags>
</build>
</image>
</images>
</configuration>
</execution>
<execution>
<id>add-no-repo-and-latest</id>
<id>push-latest</id>
<goals>
<goal>tag</goal>
<goal>push</goal>
</goals>
<configuration>
<repository>pulsar</repository>
<tag>latest</tag>
<images>
<image>
<name>${docker.organization}/pulsar</name>
<build>
<contextDir>${project.basedir}</contextDir>
<tags>
<tag>latest</tag>
</tags>
</build>
</image>
</images>
</configuration>
</execution>
<execution>
<id>tag-and-push-latest</id>
<id>add-no-repo</id>
<phase>package</phase>
<goals>
<goal>tag</goal>
<goal>push</goal>
<goal>build</goal>
</goals>
<configuration>
<repository>${docker.organization}/pulsar</repository>
<tag>latest</tag>
<images>
<image>
<name>pulsar</name>
<build>
<contextDir>${project.basedir}</contextDir>
<tags>
<tag>latest</tag>
<tag>${project.version}</tag>
</tags>
</build>
</image>
</images>
</configuration>
</execution>
</executions>
<configuration>
<repository>${docker.organization}/pulsar</repository>
<pullNewerImage>false</pullNewerImage>
<tag>${project.version}</tag>
<buildArgs>
<PULSAR_TARBALL>target/pulsar-server-distribution-${project.version}-bin.tar.gz</PULSAR_TARBALL>
<UBUNTU_MIRROR>${env.UBUNTU_MIRROR}</UBUNTU_MIRROR>
</buildArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ flexible messaging model and an intuitive client API.</description>
<reflections.version>0.9.11</reflections.version>
<swagger.version>1.6.10</swagger.version>
<puppycrawl.checkstyle.version>8.37</puppycrawl.checkstyle.version>
<dockerfile-maven.version>1.4.13</dockerfile-maven.version>
<docker-maven.version>0.40.2</docker-maven.version>
<docker.verbose>true</docker.verbose>
<typetools.version>0.5.0</typetools.version>
<byte-buddy.version>1.14.12</byte-buddy.version>
<zt-zip.version>1.17</zt-zip.version>
Expand Down Expand Up @@ -1910,6 +1911,11 @@ flexible messaging model and an intuitive client API.</description>
<artifactId>properties-maven-plugin</artifactId>
<version>${properties-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker-maven.version}</version>
</plugin>
</plugins>
</pluginManagement>
<extensions>
Expand Down
41 changes: 19 additions & 22 deletions tests/docker-images/java-test-image/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
<profiles>
<profile>
<id>docker</id>
<properties>
<docker.buildArg.PULSAR_TARBALL>target/pulsar-server-distribution-bin.tar.gz</docker.buildArg.PULSAR_TARBALL>
<docker.buildArg.UBUNTU_MIRROR>${env.UBUNTU_MIRROR}</docker.buildArg.UBUNTU_MIRROR>
</properties>
<activation>
<property>
<name>integrationTests</name>
Expand Down Expand Up @@ -135,39 +139,32 @@
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>${dockerfile-maven.version}</version>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<executions>
<execution>
<id>default</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
<execution>
<id>add-latest-tag</id>
<phase>package</phase>
<goals>
<goal>tag</goal>
</goals>
<configuration>
<repository>${docker.organization}/java-test-image</repository>
<tag>latest</tag>
<images>
<image>
<name>${docker.organization}/java-test-image</name>
<build>
<contextDir>${project.basedir}</contextDir>
<tags>
<tag>latest</tag>
<tag>${project.version}</tag>
</tags>
<noCache>true</noCache>
</build>
</image>
</images>
</configuration>
</execution>
</executions>
<configuration>
<repository>${docker.organization}/java-test-image</repository>
<tag>${project.version}</tag>
<pullNewerImage>false</pullNewerImage>
<noCache>true</noCache>
<buildArgs>
<PULSAR_TARBALL>target/pulsar-server-distribution-bin.tar.gz</PULSAR_TARBALL>
<UBUNTU_MIRROR>${env.UBUNTU_MIRROR}</UBUNTU_MIRROR>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
Loading

0 comments on commit 90e1e70

Please sign in to comment.