This is an automated email from the ASF dual-hosted git repository.

lhotari pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new fa63b688e6f [fix][build] Fix the pulsar-all image may use the wrong 
upstream image (#20435)
fa63b688e6f is described below

commit fa63b688e6f4be2de2027b5f4572d3fd728eafeb
Author: Zike Yang <[email protected]>
AuthorDate: Tue Jun 6 19:45:58 2023 +0800

    [fix][build] Fix the pulsar-all image may use the wrong upstream image 
(#20435)
    
    Signed-off-by: Zike Yang <[email protected]>
    Co-authored-by: Lari Hotari <[email protected]>
    (cherry picked from commit d7f355881b2b1eebf2be6ea262c202660d684fb7)
---
 docker/build.sh              |  2 +-
 docker/get-version.sh        |  2 +-
 docker/pom.xml               | 14 ++++++++++++++
 docker/publish.sh            | 24 ++++++++++++++++--------
 docker/pulsar-all/Dockerfile |  3 ++-
 docker/pulsar-all/pom.xml    | 14 +++++++++++++-
 docker/pulsar/pom.xml        | 17 ++++++++++++++---
 pom.xml                      | 27 ++++++++++++++++++++++++++-
 pulsar-common/pom.xml        |  3 ++-
 9 files changed, 89 insertions(+), 17 deletions(-)

diff --git a/docker/build.sh b/docker/build.sh
index d8ab4bea882..88be44f23e7 100755
--- a/docker/build.sh
+++ b/docker/build.sh
@@ -18,7 +18,7 @@
 # under the License.
 #
 
-ROOT_DIR=$(git rev-parse --show-toplevel)
+ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. >/dev/null 2>&1 && pwd )"
 cd $ROOT_DIR/docker
 
 mvn package -Pdocker,-main
diff --git a/docker/get-version.sh b/docker/get-version.sh
index 07145e7cf0c..0b736baf3b2 100755
--- a/docker/get-version.sh
+++ b/docker/get-version.sh
@@ -18,7 +18,7 @@
 # under the License.
 #
 
-ROOT_DIR=$(git rev-parse --show-toplevel)
+ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. >/dev/null 2>&1 && pwd )"
 
 pushd $ROOT_DIR > /dev/null
 
diff --git a/docker/pom.xml b/docker/pom.xml
index 16f905e5ebe..6e6b27c7d75 100644
--- a/docker/pom.xml
+++ b/docker/pom.xml
@@ -60,6 +60,20 @@
         <module>pulsar</module>
         <module>pulsar-all</module>
       </modules>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>pl.project13.maven</groupId>
+            <artifactId>git-commit-id-plugin</artifactId>
+            <configuration>
+              <skip>false</skip>
+              <injectAllReactorProjects>true</injectAllReactorProjects>
+              <runOnlyOnce>true</runOnlyOnce>
+              <skipPoms>false</skipPoms>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
     </profile>
   </profiles>
 </project>
diff --git a/docker/publish.sh b/docker/publish.sh
index 45b338d85f8..651fefc1498 100755
--- a/docker/publish.sh
+++ b/docker/publish.sh
@@ -18,7 +18,7 @@
 # under the License.
 #
 
-ROOT_DIR=$(git rev-parse --show-toplevel)
+ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. >/dev/null 2>&1 && pwd )"
 cd $ROOT_DIR/docker
 
 # We should only publish images that are made from official and approved 
releases
@@ -49,6 +49,9 @@ fi
 
 MVN_VERSION=`./get-version.sh`
 echo "Pulsar version: ${MVN_VERSION}"
+GIT_COMMIT_ID_ABBREV=$(git rev-parse --short=7 HEAD 2>/dev/null || echo no-git)
+GIT_BRANCH=$(git branch --show-current 2>/dev/null || echo no-git)
+IMAGE_TAG="${MVN_VERSION}-${GIT_COMMIT_ID_ABBREV}"
 
 if [[ -z ${DOCKER_REGISTRY} ]]; then
     docker_registry_org=${DOCKER_ORG}
@@ -62,16 +65,21 @@ set -x
 # Fail if any of the subsequent commands fail
 set -e
 
-docker tag apachepulsar/pulsar:latest ${docker_registry_org}/pulsar:latest
-docker tag apachepulsar/pulsar-all:latest 
${docker_registry_org}/pulsar-all:latest
+if [[ "$GIT_BRANCH" == "master" ]]; then
+  docker tag apachepulsar/pulsar:${IMAGE_TAG} 
${docker_registry_org}/pulsar:latest
+  docker tag apachepulsar/pulsar-all:${IMAGE_TAG} 
${docker_registry_org}/pulsar-all:latest
+fi
 
-docker tag apachepulsar/pulsar:latest 
${docker_registry_org}/pulsar:$MVN_VERSION
-docker tag apachepulsar/pulsar-all:latest 
${docker_registry_org}/pulsar-all:$MVN_VERSION
+docker tag apachepulsar/pulsar:${IMAGE_TAG} 
${docker_registry_org}/pulsar:$MVN_VERSION
+docker tag apachepulsar/pulsar-all:${IMAGE_TAG} 
${docker_registry_org}/pulsar-all:$MVN_VERSION
 
 # Push all images and tags
-docker push ${docker_registry_org}/pulsar:latest
-docker push ${docker_registry_org}/pulsar-all:latest
+if [[ "$GIT_BRANCH" == "master" ]]; then
+  docker push ${docker_registry_org}/pulsar:latest
+  docker push ${docker_registry_org}/pulsar-all:latest
+fi
+
 docker push ${docker_registry_org}/pulsar:$MVN_VERSION
 docker push ${docker_registry_org}/pulsar-all:$MVN_VERSION
 
-echo "Finished pushing images to ${docker_registry_org}"
+echo "Finished pushing images to ${docker_registry_org}"
\ No newline at end of file
diff --git a/docker/pulsar-all/Dockerfile b/docker/pulsar-all/Dockerfile
index 42431fc94a0..81ad74b6500 100644
--- a/docker/pulsar-all/Dockerfile
+++ b/docker/pulsar-all/Dockerfile
@@ -17,6 +17,7 @@
 # under the License.
 #
 
+ARG PULSAR_IMAGE
 FROM busybox as pulsar-all
 
 ARG PULSAR_IO_DIR
@@ -26,6 +27,6 @@ ADD ${PULSAR_IO_DIR} /connectors
 ADD ${PULSAR_OFFLOADER_TARBALL} /
 RUN mv /apache-pulsar-offloaders-*/offloaders /offloaders
 
-FROM apachepulsar/pulsar:latest
+FROM $PULSAR_IMAGE
 COPY --from=pulsar-all /connectors /pulsar/connectors
 COPY --from=pulsar-all /offloaders /pulsar/offloaders
diff --git a/docker/pulsar-all/pom.xml b/docker/pulsar-all/pom.xml
index 509084bfada..d4b9e35aff3 100644
--- a/docker/pulsar-all/pom.xml
+++ b/docker/pulsar-all/pom.xml
@@ -66,6 +66,17 @@
   </dependencies>
 
   <profiles>
+    <profile>
+      <id>git-commit-id-no-git</id>
+      <activation>
+        <file>
+          <missing>${basedir}/../../.git/index</missing>
+        </file>
+      </activation>
+      <properties>
+        <git.commit.id.abbrev>no-git</git.commit.id.abbrev>
+      </properties>
+    </profile>
     <profile>
       <id>docker</id>
       <!-- include the docker image only when docker profile is active -->
@@ -144,11 +155,12 @@
                         <contextDir>${project.basedir}</contextDir>
                         <tags>
                           <tag>latest</tag>
-                          <tag>${project.version}</tag>
+                          <tag>${project.version}-${git.commit.id.abbrev}</tag>
                         </tags>
                         <args>
                           
<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>
+                          
<PULSAR_IMAGE>${docker.organization}/pulsar:${project.version}-${git.commit.id.abbrev}</PULSAR_IMAGE>
                         </args>
                         <buildx>
                           <platforms>
diff --git a/docker/pulsar/pom.xml b/docker/pulsar/pom.xml
index 3b8a9933cea..7ec474aca9d 100644
--- a/docker/pulsar/pom.xml
+++ b/docker/pulsar/pom.xml
@@ -48,11 +48,22 @@
   </dependencies>
 
   <properties>
-      <UBUNTU_MIRROR>mirror://mirrors.ubuntu.com/mirrors.txt</UBUNTU_MIRROR>
-      
<UBUNTU_SECURITY_MIRROR>http://security.ubuntu.com/ubuntu/</UBUNTU_SECURITY_MIRROR>
+    <UBUNTU_MIRROR>mirror://mirrors.ubuntu.com/mirrors.txt</UBUNTU_MIRROR>
+    
<UBUNTU_SECURITY_MIRROR>http://security.ubuntu.com/ubuntu/</UBUNTU_SECURITY_MIRROR>
   </properties>
 
   <profiles>
+    <profile>
+      <id>git-commit-id-no-git</id>
+      <activation>
+        <file>
+          <missing>${basedir}/../../.git/index</missing>
+        </file>
+      </activation>
+      <properties>
+        <git.commit.id.abbrev>no-git</git.commit.id.abbrev>
+      </properties>
+    </profile>
     <profile>
       <id>docker</id>
       <build>
@@ -82,7 +93,7 @@
                         <contextDir>${project.basedir}</contextDir>
                         <tags>
                           <tag>latest</tag>
-                          <tag>${project.version}</tag>
+                          <tag>${project.version}-${git.commit.id.abbrev}</tag>
                         </tags>
                         <buildx>
                           <platforms>
diff --git a/pom.xml b/pom.xml
index 028d6a7dc89..cd82fd9ce39 100644
--- a/pom.xml
+++ b/pom.xml
@@ -285,7 +285,7 @@ flexible messaging model and an intuitive client 
API.</description>
     <properties-maven-plugin.version>1.1.0</properties-maven-plugin.version>
     <nifi-nar-maven-plugin.version>1.5.0</nifi-nar-maven-plugin.version>
     <maven-checkstyle-plugin.version>3.1.2</maven-checkstyle-plugin.version>
-    <git-commit-id-plugin.version>4.0.2</git-commit-id-plugin.version>
+    <git-commit-id-plugin.version>4.9.10</git-commit-id-plugin.version>
     <wagon-ssh-external.version>3.5.3</wagon-ssh-external.version>
     <os-maven-plugin.version>1.7.0</os-maven-plugin.version>
     <jacoco-maven-plugin.version>0.8.8</jacoco-maven-plugin.version>
@@ -1570,6 +1570,31 @@ flexible messaging model and an intuitive client 
API.</description>
         </executions>
       </plugin>
 
+      <plugin>
+        <groupId>pl.project13.maven</groupId>
+        <artifactId>git-commit-id-plugin</artifactId>
+        <version>${git-commit-id-plugin.version}</version>
+        <executions>
+          <execution>
+            <id>git-info</id>
+            <goals>
+              <goal>revision</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <skip>true</skip>
+          <useNativeGit>true</useNativeGit>
+          <prefix>git</prefix>
+          <failOnNoGitDirectory>false</failOnNoGitDirectory>
+          <skipPoms>false</skipPoms>
+          <gitDescribe>
+            <skip>false</skip>
+            <always>false</always>
+          </gitDescribe>
+        </configuration>
+      </plugin>
+
       <plugin>
         <groupId>com.mycila</groupId>
         <artifactId>license-maven-plugin</artifactId>
diff --git a/pulsar-common/pom.xml b/pulsar-common/pom.xml
index 8d64ee4ae3c..88daa51d823 100644
--- a/pulsar-common/pom.xml
+++ b/pulsar-common/pom.xml
@@ -194,7 +194,7 @@
       <scope>provided</scope>
       <optional>true</optional>
     </dependency>
-    
+
     <dependency>
       <groupId>com.google.protobuf</groupId>
          <artifactId>protobuf-java</artifactId>
@@ -296,6 +296,7 @@
           </execution>
         </executions>
         <configuration>
+          <skip>false</skip>
           <useNativeGit>true</useNativeGit>
           <prefix>git</prefix>
           <verbose>false</verbose>

Reply via email to