Skip to content

Commit d7f3558

Browse files
RobertIndielhotari
andauthored
[fix][build] Fix the pulsar-all image may use the wrong upstream image (#20435)
Signed-off-by: Zike Yang <zike@apache.org> Co-authored-by: Lari Hotari <lhotari@apache.org>
1 parent ad352a9 commit d7f3558

File tree

9 files changed

+89
-17
lines changed

9 files changed

+89
-17
lines changed

docker/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# under the License.
1919
#
2020

21-
ROOT_DIR=$(git rev-parse --show-toplevel)
21+
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. >/dev/null 2>&1 && pwd )"
2222
cd $ROOT_DIR/docker
2323

2424
mvn package -Pdocker,-main

docker/get-version.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# under the License.
1919
#
2020

21-
ROOT_DIR=$(git rev-parse --show-toplevel)
21+
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. >/dev/null 2>&1 && pwd )"
2222

2323
pushd $ROOT_DIR > /dev/null
2424

docker/pom.xml

+14
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@
6060
<module>pulsar</module>
6161
<module>pulsar-all</module>
6262
</modules>
63+
<build>
64+
<plugins>
65+
<plugin>
66+
<groupId>pl.project13.maven</groupId>
67+
<artifactId>git-commit-id-plugin</artifactId>
68+
<configuration>
69+
<skip>false</skip>
70+
<injectAllReactorProjects>true</injectAllReactorProjects>
71+
<runOnlyOnce>true</runOnlyOnce>
72+
<skipPoms>false</skipPoms>
73+
</configuration>
74+
</plugin>
75+
</plugins>
76+
</build>
6377
</profile>
6478
</profiles>
6579
</project>

docker/publish.sh

+16-8
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# under the License.
1919
#
2020

21-
ROOT_DIR=$(git rev-parse --show-toplevel)
21+
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. >/dev/null 2>&1 && pwd )"
2222
cd $ROOT_DIR/docker
2323

2424
# We should only publish images that are made from official and approved releases
@@ -49,6 +49,9 @@ fi
4949

5050
MVN_VERSION=`./get-version.sh`
5151
echo "Pulsar version: ${MVN_VERSION}"
52+
GIT_COMMIT_ID_ABBREV=$(git rev-parse --short=7 HEAD 2>/dev/null || echo no-git)
53+
GIT_BRANCH=$(git branch --show-current 2>/dev/null || echo no-git)
54+
IMAGE_TAG="${MVN_VERSION}-${GIT_COMMIT_ID_ABBREV}"
5255

5356
if [[ -z ${DOCKER_REGISTRY} ]]; then
5457
docker_registry_org=${DOCKER_ORG}
@@ -62,16 +65,21 @@ set -x
6265
# Fail if any of the subsequent commands fail
6366
set -e
6467

65-
docker tag apachepulsar/pulsar:latest ${docker_registry_org}/pulsar:latest
66-
docker tag apachepulsar/pulsar-all:latest ${docker_registry_org}/pulsar-all:latest
68+
if [[ "$GIT_BRANCH" == "master" ]]; then
69+
docker tag apachepulsar/pulsar:${IMAGE_TAG} ${docker_registry_org}/pulsar:latest
70+
docker tag apachepulsar/pulsar-all:${IMAGE_TAG} ${docker_registry_org}/pulsar-all:latest
71+
fi
6772

68-
docker tag apachepulsar/pulsar:latest ${docker_registry_org}/pulsar:$MVN_VERSION
69-
docker tag apachepulsar/pulsar-all:latest ${docker_registry_org}/pulsar-all:$MVN_VERSION
73+
docker tag apachepulsar/pulsar:${IMAGE_TAG} ${docker_registry_org}/pulsar:$MVN_VERSION
74+
docker tag apachepulsar/pulsar-all:${IMAGE_TAG} ${docker_registry_org}/pulsar-all:$MVN_VERSION
7075

7176
# Push all images and tags
72-
docker push ${docker_registry_org}/pulsar:latest
73-
docker push ${docker_registry_org}/pulsar-all:latest
77+
if [[ "$GIT_BRANCH" == "master" ]]; then
78+
docker push ${docker_registry_org}/pulsar:latest
79+
docker push ${docker_registry_org}/pulsar-all:latest
80+
fi
81+
7482
docker push ${docker_registry_org}/pulsar:$MVN_VERSION
7583
docker push ${docker_registry_org}/pulsar-all:$MVN_VERSION
7684

77-
echo "Finished pushing images to ${docker_registry_org}"
85+
echo "Finished pushing images to ${docker_registry_org}"

docker/pulsar-all/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# under the License.
1818
#
1919

20+
ARG PULSAR_IMAGE
2021
FROM busybox as pulsar-all
2122

2223
ARG PULSAR_IO_DIR
@@ -26,6 +27,6 @@ ADD ${PULSAR_IO_DIR} /connectors
2627
ADD ${PULSAR_OFFLOADER_TARBALL} /
2728
RUN mv /apache-pulsar-offloaders-*/offloaders /offloaders
2829

29-
FROM apachepulsar/pulsar:latest
30+
FROM $PULSAR_IMAGE
3031
COPY --from=pulsar-all /connectors /pulsar/connectors
3132
COPY --from=pulsar-all /offloaders /pulsar/offloaders

docker/pulsar-all/pom.xml

+13-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@
6666
</dependencies>
6767

6868
<profiles>
69+
<profile>
70+
<id>git-commit-id-no-git</id>
71+
<activation>
72+
<file>
73+
<missing>${basedir}/../../.git/index</missing>
74+
</file>
75+
</activation>
76+
<properties>
77+
<git.commit.id.abbrev>no-git</git.commit.id.abbrev>
78+
</properties>
79+
</profile>
6980
<profile>
7081
<id>docker</id>
7182
<!-- include the docker image only when docker profile is active -->
@@ -144,11 +155,12 @@
144155
<contextDir>${project.basedir}</contextDir>
145156
<tags>
146157
<tag>latest</tag>
147-
<tag>${project.version}</tag>
158+
<tag>${project.version}-${git.commit.id.abbrev}</tag>
148159
</tags>
149160
<args>
150161
<PULSAR_IO_DIR>target/apache-pulsar-io-connectors-${project.version}-bin</PULSAR_IO_DIR>
151162
<PULSAR_OFFLOADER_TARBALL>target/pulsar-offloader-distribution-${project.version}-bin.tar.gz</PULSAR_OFFLOADER_TARBALL>
163+
<PULSAR_IMAGE>${docker.organization}/pulsar:${project.version}-${git.commit.id.abbrev}</PULSAR_IMAGE>
152164
</args>
153165
<buildx>
154166
<platforms>

docker/pulsar/pom.xml

+14-3
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,22 @@
4848
</dependencies>
4949

5050
<properties>
51-
<UBUNTU_MIRROR>mirror://mirrors.ubuntu.com/mirrors.txt</UBUNTU_MIRROR>
52-
<UBUNTU_SECURITY_MIRROR>http://security.ubuntu.com/ubuntu/</UBUNTU_SECURITY_MIRROR>
51+
<UBUNTU_MIRROR>mirror://mirrors.ubuntu.com/mirrors.txt</UBUNTU_MIRROR>
52+
<UBUNTU_SECURITY_MIRROR>http://security.ubuntu.com/ubuntu/</UBUNTU_SECURITY_MIRROR>
5353
</properties>
5454

5555
<profiles>
56+
<profile>
57+
<id>git-commit-id-no-git</id>
58+
<activation>
59+
<file>
60+
<missing>${basedir}/../../.git/index</missing>
61+
</file>
62+
</activation>
63+
<properties>
64+
<git.commit.id.abbrev>no-git</git.commit.id.abbrev>
65+
</properties>
66+
</profile>
5667
<profile>
5768
<id>docker</id>
5869
<build>
@@ -82,7 +93,7 @@
8293
<contextDir>${project.basedir}</contextDir>
8394
<tags>
8495
<tag>latest</tag>
85-
<tag>${project.version}</tag>
96+
<tag>${project.version}-${git.commit.id.abbrev}</tag>
8697
</tags>
8798
<buildx>
8899
<platforms>

pom.xml

+26-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ flexible messaging model and an intuitive client API.</description>
286286
<properties-maven-plugin.version>1.1.0</properties-maven-plugin.version>
287287
<nifi-nar-maven-plugin.version>1.5.0</nifi-nar-maven-plugin.version>
288288
<maven-checkstyle-plugin.version>3.1.2</maven-checkstyle-plugin.version>
289-
<git-commit-id-plugin.version>4.0.2</git-commit-id-plugin.version>
289+
<git-commit-id-plugin.version>4.9.10</git-commit-id-plugin.version>
290290
<wagon-ssh-external.version>3.5.3</wagon-ssh-external.version>
291291
<os-maven-plugin.version>1.7.0</os-maven-plugin.version>
292292
<jacoco-maven-plugin.version>0.8.8</jacoco-maven-plugin.version>
@@ -1571,6 +1571,31 @@ flexible messaging model and an intuitive client API.</description>
15711571
</executions>
15721572
</plugin>
15731573

1574+
<plugin>
1575+
<groupId>pl.project13.maven</groupId>
1576+
<artifactId>git-commit-id-plugin</artifactId>
1577+
<version>${git-commit-id-plugin.version}</version>
1578+
<executions>
1579+
<execution>
1580+
<id>git-info</id>
1581+
<goals>
1582+
<goal>revision</goal>
1583+
</goals>
1584+
</execution>
1585+
</executions>
1586+
<configuration>
1587+
<skip>true</skip>
1588+
<useNativeGit>true</useNativeGit>
1589+
<prefix>git</prefix>
1590+
<failOnNoGitDirectory>false</failOnNoGitDirectory>
1591+
<skipPoms>false</skipPoms>
1592+
<gitDescribe>
1593+
<skip>false</skip>
1594+
<always>false</always>
1595+
</gitDescribe>
1596+
</configuration>
1597+
</plugin>
1598+
15741599
<plugin>
15751600
<groupId>com.mycila</groupId>
15761601
<artifactId>license-maven-plugin</artifactId>

pulsar-common/pom.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
<scope>provided</scope>
195195
<optional>true</optional>
196196
</dependency>
197-
197+
198198
<dependency>
199199
<groupId>com.google.protobuf</groupId>
200200
<artifactId>protobuf-java</artifactId>
@@ -296,6 +296,7 @@
296296
</execution>
297297
</executions>
298298
<configuration>
299+
<skip>false</skip>
299300
<useNativeGit>true</useNativeGit>
300301
<prefix>git</prefix>
301302
<verbose>false</verbose>

0 commit comments

Comments
 (0)