Skip to content

Commit

Permalink
Add arm64 Docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
kezhenxu94 committed Jan 28, 2022
1 parent 93b74b5 commit 6eb08b8
Show file tree
Hide file tree
Showing 14 changed files with 245 additions and 249 deletions.
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
34 changes: 17 additions & 17 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,20 +59,23 @@ 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-grafana:latest ${docker_registry_org}/pulsar-grafana: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
# TODO mvnd -> mvn
mvnd -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-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
#docker tag pulsar:latest ${docker_registry_org}/pulsar:latest
#docker tag pulsar-all:latest ${docker_registry_org}/pulsar-all:latest
#docker tag pulsar-grafana:latest ${docker_registry_org}/pulsar-grafana: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}"
28 changes: 0 additions & 28 deletions docker/get-version.sh

This file was deleted.

71 changes: 38 additions & 33 deletions docker/grafana/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,53 +36,58 @@
<build>
<plugins>
<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-grafana</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-grafana</repository>
<tag>latest</tag>
<executable>docker</executable>
<workingDirectory>${project.basedir}</workingDirectory>
<arguments>
<argument>build</argument>
<argument>-t</argument>
<argument>pulsar-grafana:${project.version}</argument>
<argument>-t</argument>
<argument>pulsar-grafana:latest</argument>
<argument>-t</argument>
<argument>${docker.organization}/pulsar-grafana:${project.version}</argument>
<argument>-t</argument>
<argument>${docker.organization}/pulsar-grafana: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-grafana</repository>
<tag>latest</tag>
<environmentVariables>
<DOCKER_BUILDKIT>1</DOCKER_BUILDKIT>
</environmentVariables>
<executable>docker</executable>
<workingDirectory>${project.basedir}</workingDirectory>
<arguments>
<argument>buildx</argument>
<argument>build</argument>
<argument>--push</argument>
<argument>-t</argument>
<argument>${docker.organization}/pulsar-grafana:${project.version}</argument>
<argument>-t</argument>
<argument>${docker.organization}/pulsar-grafana:latest</argument>
<argument>.</argument>
</arguments>
</configuration>
</execution>
</executions>
<configuration>
<repository>${docker.organization}/pulsar-grafana</repository>
<tag>${project.version}</tag>
<pullNewerImage>false</pullNewerImage>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
Loading

0 comments on commit 6eb08b8

Please sign in to comment.