Skip to content

Commit

Permalink
[fix][build] Fix the pulsar-all image may use the wrong upstream image (
Browse files Browse the repository at this point in the history
apache#20435)

Signed-off-by: Zike Yang <[email protected]>
Co-authored-by: Lari Hotari <[email protected]>

(cherry picked from commit d7f3558)
Signed-off-by: Zixuan Liu <[email protected]>
  • Loading branch information
2 people authored and nodece committed Apr 28, 2024
1 parent ac8f8dd commit 1afc667
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docker/get-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions docker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
24 changes: 16 additions & 8 deletions docker/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand All @@ -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}"
3 changes: 2 additions & 1 deletion docker/pulsar-all/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# under the License.
#

ARG PULSAR_IMAGE
FROM busybox as pulsar-all

ARG PULSAR_IO_DIR
Expand All @@ -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
14 changes: 13 additions & 1 deletion docker/pulsar-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand Down Expand Up @@ -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>
Expand Down
17 changes: 14 additions & 3 deletions docker/pulsar/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
27 changes: 26 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ flexible messaging model and an intuitive client API.</description>
<properties-maven-plugin.version>1.0.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.4.3</wagon-ssh-external.version>
<os-maven-plugin.version>1.4.1.Final</os-maven-plugin.version>
<jacoco-maven-plugin.version>0.8.7</jacoco-maven-plugin.version>
Expand Down Expand Up @@ -1512,6 +1512,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>
Expand Down
1 change: 1 addition & 0 deletions pulsar-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@
</execution>
</executions>
<configuration>
<skip>false</skip>
<useNativeGit>true</useNativeGit>
<prefix>git</prefix>
<verbose>false</verbose>
Expand Down

0 comments on commit 1afc667

Please sign in to comment.