Merge branch 'stable-3.6' into stable-3.7
* stable-3.6:
Add trailing slash in default canonicalWebUrl
Set Gerrit to 3.6.7
Set Gerrit to 3.6.6
Set Gerrit to 3.6.5
Change-Id: I5de6cc11031a3d57a45cf9ce6ecdf35d02bf1633
diff --git a/README.md b/README.md
index d648262..21a9e00 100644
--- a/README.md
+++ b/README.md
@@ -60,6 +60,29 @@
The build argument defaults to the URL pointing to the last successful build of the Gerrit master
branch on the [Gerrit CI](https://gerrit-ci.gerritforge.com).
+## Build multi-platform images
+
+For the official releases one can build both `amd64` and `arm64` images at once and either
+load them to the local docker registry or push them to the `gerritcodereview` dockerhub account.
+In order to do that one simply calls:
+
+```
+./build_multiplatform.sh --load
+```
+
+And multiplatform images will be created and loaded locally. Calling:
+
+```
+./build_multiplatform.sh --push
+```
+
+pushes images to the dockerhub instead.
+
+Notes:
+* in the `--load` target only the current system architecture image is pushed to the local
+ registry
+* the almalinux image is additionally tagged as the default release image.
+
## Using persistent volumes
Use docker persistent volumes to keep Gerrit data across restarts.
diff --git a/almalinux/8/Dockerfile b/almalinux/8/Dockerfile
index 3773491..4dac66a 100644
--- a/almalinux/8/Dockerfile
+++ b/almalinux/8/Dockerfile
@@ -10,7 +10,7 @@
# (pre-trans Gerrit script needs to have access to the Java command)
RUN yum -y install initscripts && \
yum -y install java-11-openjdk && \
- yum -y install gerrit-3.6.7-1 && \
+ yum -y install gerrit-3.7.5-1 && \
/entrypoint.sh init && \
rm -f /var/gerrit/etc/{ssh,secure}* && rm -Rf /var/gerrit/{static,index,logs,data,index,cache,git,db,tmp}/* && chown -R gerrit:gerrit /var/gerrit && \
yum -y clean all
diff --git a/build_multiplatform.sh b/build_multiplatform.sh
new file mode 100755
index 0000000..944978f
--- /dev/null
+++ b/build_multiplatform.sh
@@ -0,0 +1,80 @@
+#!/bin/bash
+
+help() {
+ echo "Helper script to build single or multiplatform (depending on the input parameter)"
+ echo "images for both almalinux and ubuntu distributions."
+ echo
+ echo "Syntax: $0 [--load|--push]"
+ echo "options:"
+ echo "load Builds single platform (of runner's system type) images and loads them into"
+ echo " into local docker registry (they are visible through the 'docker images'"
+ echo " command."
+ echo "push Builds both 'amd64' and 'arm64' architectures images and pushes them to the."
+ echo " dockerhub. Note that in this case one needs to be logged in to"
+ echo " 'gerritcodereview' account and images are not visible in the local registry."
+ echo
+}
+
+DESTINATION=$1
+
+if ! [[ "$DESTINATION" =~ ^(--load|--push)$ ]]; then
+ help
+ exit
+fi
+
+if [[ $DESTINATION == *load ]]; then
+ if [[ $(uname -m) == *arm64* ]]; then
+ PLATFORMS="linux/arm64"
+ else
+ PLATFORMS="linux/amd64"
+ fi
+else
+ PLATFORMS="linux/amd64,linux/arm64"
+fi
+
+echo "### Building images for $DESTINATION destination and $PLATFORMS platforms"
+
+BUILDER=gerrit-multiplatform-image-builder
+DOCKER_USER=gerritcodereview/gerrit
+
+function create_builder() {
+ if [[ "$OSTYPE" == "linux"* ]]; then
+ docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
+ fi
+ docker buildx create --name $BUILDER --platform "$PLATFORMS" --driver docker-container --use
+ docker buildx inspect --bootstrap
+}
+
+STATUS="$(docker buildx inspect $BUILDER 2>&1 | grep Status:)"
+if [ "$?" -ne "0" ]; then
+ set -e
+ echo "### Multi-platform builder $BUILDER doesn't exist and will be created."
+ create_builder
+else
+ set -e
+ STATUS="${STATUS##* }"
+ if [[ $STATUS == *running* ]]; then
+ echo "### Multi-platform builder $BUILDER is up and running."
+ else
+ echo "### Multi-platform builder $BUILDER exists but it doesn't run. It will be re-created."
+ docker buildx rm $BUILDER
+ create_builder
+ fi
+fi
+
+VERSION=$(git describe)
+VERSION=${VERSION:1}
+
+echo
+echo "### Building almalinux multi-platform: [$PLATFORMS] iamges"
+(cd almalinux/8 && docker buildx build --platform "$PLATFORMS" --no-cache -t "$DOCKER_USER:${VERSION}-almalinux8" -t "$DOCKER_USER:$VERSION" "$DESTINATION" .)
+
+echo
+echo "### Building ubuntu multi-platform: [$PLATFORMS] iamges"
+(cd ubuntu/20 && docker buildx build --platform "$PLATFORMS" --no-cache -t "$DOCKER_USER:${VERSION}-ubuntu20" "$DESTINATION" .)
+
+echo
+echo "### Removing multi-platform builder"
+echo y | docker buildx prune
+docker buildx stop $BUILDER
+docker buildx rm $BUILDER
diff --git a/ubuntu/20/Dockerfile b/ubuntu/20/Dockerfile
index 3f530dd..4598190 100644
--- a/ubuntu/20/Dockerfile
+++ b/ubuntu/20/Dockerfile
@@ -16,7 +16,7 @@
# Install OpenJDK and Gerrit in two subsequent transactions
# (pre-trans Gerrit script needs to have access to the Java command)
RUN apt-get -y install openjdk-11-jdk
-RUN apt-get -y install gerrit=3.6.7-1 && \
+RUN apt-get -y install gerrit=3.7.5-1 && \
apt-mark hold gerrit && \
/entrypoint.sh init && \
bash -c 'rm -f /var/gerrit/etc/{ssh,secure}* && rm -Rf /var/gerrit/{static,index,logs,data,index,cache,git,db,tmp}/*' && \