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

Add arm64 Docker images #14005

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/build_java_test_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ if [[ "$(docker version -f '{{.Server.Experimental}}' 2>/dev/null)" == "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 \
"$@" install
"$@" install
9 changes: 7 additions & 2 deletions build/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ RUN cd /usr/src/gmock && cmake . && make && cp libgmock.a /usr/lib
# Include gtest parallel to speed up unit tests
RUN git clone https://github.com/google/gtest-parallel.git

ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
ENV JAVA_HOME_11=/usr/lib/jvm/java-1.11.0-openjdk-amd64
RUN java_home=$(ls -d1 /usr/lib/jvm/java-1.8.0-openjdk-*) ; \
ln -s "$java_home" /usr/lib/jvm/java8 ; \
java_home_11=$(ls -d1 /usr/lib/jvm/java-1.11.0-openjdk-*) ; \
ln -s "$java_home_11" /usr/lib/jvm/java11

ENV JAVA_HOME /usr/lib/jvm/java8
ENV JAVA_HOME_11 /usr/lib/jvm/java11

## Website build dependencies

Expand Down
23 changes: 21 additions & 2 deletions build/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,32 @@ Example: `apachepulsar/pulsar-build:ubuntu-16.04`

### Build pulsar-build image

We provide Docker images for multiple architectures including amd64 and arm64, by leveraging Docker build kit, please
make sure to start a BuildKit daemon with command `docker buildx create --use --driver docker-container`.

If you want to build Docker image only for local testing in your current machine (without pushing to a registry), you
can build the image without BuildKit, like this:

```shell
docker build -t apachepulsar/pulsar-build:ubuntu-16.04 .
```

### Publish pulsar-build image
It's an unusual case when you want to build multi-arch images locally without pushing to a registry, but in case you
want to do this, run command:

```shell
publish.sh
docker buildx build --no-cache --platform=linux/amd64,linux/arm64 --load -t apachepulsar/pulsar-build:ubuntu-16.04 .
```

This command builds multi-arch images in your local machine, but be careful when you
run `docker push apachepulsar/pulsar-build:ubuntu-16.04`, **only one** image matching your system architecture will be
pushed.

If you want to push all images with different architectures to remote Docker registry, you can build and push with
command:

```shell
docker buildx build --no-cache --platform=linux/amd64,linux/arm64 --push -t apachepulsar/pulsar-build:ubuntu-16.04 .
```

> Make sure to log into the registry with command `docker login <registry.address>` before running the command above.
57 changes: 0 additions & 57 deletions build/docker/publish.sh

This file was deleted.

2 changes: 1 addition & 1 deletion docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
ROOT_DIR=$(git rev-parse --show-toplevel)
cd $ROOT_DIR/docker

mvn package -Pdocker,-main
mvn package -Ddocker.push.skip -Pdocker,-main
29 changes: 16 additions & 13 deletions docker/publish.sh → docker/build_and_publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ if [ $? -ne 0 ]; then
exit 1
fi

MVN_VERSION=`./get-version.sh`
echo "Pulsar version: ${MVN_VERSION}"

if [[ -z ${DOCKER_REGISTRY} ]]; then
docker_registry_org=${DOCKER_ORG}
else
Expand All @@ -62,16 +59,22 @@ set -x
# Fail if any of the subsequent commands fail
set -e

docker tag pulsar:latest ${docker_registry_org}/pulsar:latest
docker tag pulsar-all:latest ${docker_registry_org}/pulsar-all:latest

docker tag pulsar:latest ${docker_registry_org}/pulsar:$MVN_VERSION
docker tag pulsar-all:latest ${docker_registry_org}/pulsar-all:$MVN_VERSION
# TODO mvnd -> mvn
mvn -f pulsar/pom.xml install -Ddocker.organization=${docker_registry_org} -Pdocker,push,-main -am

# Push all images and tags
docker push ${docker_registry_org}/pulsar:latest
docker push ${docker_registry_org}/pulsar-all:latest
docker push ${docker_registry_org}/pulsar:$MVN_VERSION
docker push ${docker_registry_org}/pulsar-all:$MVN_VERSION
#docker tag pulsar:latest ${docker_registry_org}/pulsar:latest
#docker tag pulsar-all:latest ${docker_registry_org}/pulsar-all:latest
#
#docker tag pulsar:latest ${docker_registry_org}/pulsar:$MVN_VERSION
#docker tag pulsar-all:latest ${docker_registry_org}/pulsar-all:$MVN_VERSION
#docker tag pulsar-grafana:latest ${docker_registry_org}/pulsar-grafana:$MVN_VERSION
#
## Push all images and tags
#docker push ${docker_registry_org}/pulsar:latest
#docker push ${docker_registry_org}/pulsar-all:latest
#docker push ${docker_registry_org}/pulsar-grafana:latest
#docker push ${docker_registry_org}/pulsar:$MVN_VERSION
#docker push ${docker_registry_org}/pulsar-all:$MVN_VERSION
#docker push ${docker_registry_org}/pulsar-grafana:$MVN_VERSION

echo "Finished pushing images to ${docker_registry_org}"
98 changes: 53 additions & 45 deletions docker/pulsar-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,6 @@
<profile>
<id>docker</id>
<!-- include the docker image only when docker profile is active -->
<dependencies>
Copy link
Contributor

@heesung-sn heesung-sn Apr 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may need to keep this dependency in order to keep the build order, pulsar-docker-image -> pulsar-all-docker-image, since the pulsar-all-docker-image copies the pulsar server binaries from the pulsar-docker-image(newly built) and additionally inject the updated puslar-offloader and pulsar-io binaries.

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>pulsar-docker-image</artifactId>
<version>${project.version}</version>
<classifier>docker-info</classifier>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -119,57 +111,73 @@
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>${dockerfile-maven.version}</version>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec-maven-plugin.version}</version>
<executions>
<execution>
<id>default</id>
<id>docker-build</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>
</configuration>
</execution>
<execution>
<id>add-no-repo-and-latest</id>
<goals>
<goal>tag</goal>
<goal>exec</goal>
</goals>
<configuration>
<repository>pulsar-all</repository>
<tag>latest</tag>
<environmentVariables>
<DOCKER_BUILDKIT>1</DOCKER_BUILDKIT>
</environmentVariables>
<executable>docker</executable>
<workingDirectory>${project.basedir}</workingDirectory>
<arguments>
<argument>build</argument>
<argument>--no-cache</argument>
<argument>--build-arg</argument>
<argument>PULSAR_TARBALL=target/pulsar-server-distribution-${project.version}-bin.tar.gz</argument>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to pass PULSAR_OFFLOADER_TARBALL and PULSAR_IO_DIR instead of PULSAR_TARBALL for puslar-all/build. In fact, I think this is the root cause of bin/sh -c mv /apache-pulsar-offloaders-*/offloaders /offloaders error.

<argument>-t</argument>
<argument>pulsar-all:${project.version}</argument>
<argument>-t</argument>
<argument>pulsar-all:latest</argument>
<argument>-t</argument>
<argument>${docker.organization}/pulsar-all:${project.version}</argument>
<argument>-t</argument>
<argument>${docker.organization}/pulsar-all:latest</argument>
<argument>.</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>tag-and-push-latest</id>
<id>docker-push</id>
<phase>deploy</phase>
<goals>
<goal>tag</goal>
<goal>push</goal>
<goal>exec</goal>
</goals>
<configuration>
<repository>${docker.organization}/pulsar-all</repository>
<tag>latest</tag>
<environmentVariables>
<DOCKER_BUILDKIT>1</DOCKER_BUILDKIT>
</environmentVariables>
<executable>docker</executable>
<workingDirectory>${project.basedir}</workingDirectory>
<arguments>
<argument>buildx</argument>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think buildx requires BuildKit container in order to build for the multi platforms. Don't we need to exec(or check) docker buildx create --use --driver docker-container before this buildx execution?

<argument>build</argument>
<argument>--no-cache</argument>
<argument>--platform=linux/amd64,linux/arm64</argument>
<argument>--build-arg</argument>
<argument>
PULSAR_IO_DIR=target/apache-pulsar-io-connectors-${project.version}-bin
</argument>
<argument>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add <argument>--build-arg</argument> as the key prefix for PULSAR_OFFLOADER_TARBALL.

PULSAR_OFFLOADER_TARBALL=target/pulsar-offloader-distribution-${project.version}-bin.tar.gz
</argument>
<argument>--push</argument>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this --push might try to push the image to the DockerHub repo instead of local. Do we want to push the image to local or DockerHub here?

<argument>-t</argument>
<argument>${docker.organization}/pulsar-all:${project.version}</argument>
<argument>-t</argument>
<argument>${docker.organization}/pulsar-all:latest</argument>
<argument>.</argument>
</arguments>
</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
7 changes: 5 additions & 2 deletions docker/pulsar/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 10
# 4. /pulsar - hadoop writes to this directory
RUN mkdir /pulsar && chmod g+w /pulsar

ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64
RUN echo networkaddress.cache.ttl=1 >> /usr/lib/jvm/java-11-openjdk-amd64/conf/security/java.security
RUN java_home=$(ls -d1 /usr/lib/jvm/java-11-openjdk-*) ; \
ln -s "$java_home" /usr/lib/jvm/java

ENV JAVA_HOME /usr/lib/jvm/java
RUN echo networkaddress.cache.ttl=1 >> /usr/lib/jvm/java/conf/security/java.security
ADD target/python-client/ /pulsar/pulsar-client

ENV PULSAR_ROOT_LOGGER=INFO,CONSOLE
Expand Down
Loading