Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix][build] Fix the pulsar-all image may use the wrong upstream image #20435

Merged
merged 10 commits into from
Jun 6, 2023
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 @@ -286,7 +286,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>
Expand Down Expand Up @@ -1571,6 +1571,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
3 changes: 2 additions & 1 deletion pulsar-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
<scope>provided</scope>
<optional>true</optional>
</dependency>

<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
Expand Down Expand Up @@ -296,6 +296,7 @@
</execution>
</executions>
<configuration>
<skip>false</skip>
<useNativeGit>true</useNativeGit>
<prefix>git</prefix>
<verbose>false</verbose>
Expand Down