Unable to build gemnasium-maven on non-amd64 machines
Summary
The gemnasium-maven
image is only compatible with amd64
architectures.
Steps to reproduce
-
Using an arm64 machine, attempt to build
gemnasium-maven
:docker build -t gemnasium-maven:latest -f build/gemnasium-maven/debian/Dockerfile .
-
Verify that the image does not build successfully:
$ docker build -t gemnasium-maven:latest -f build/gemnasium-maven/debian/Dockerfile . /opt/asdf/installs/gradle/6.7.1/gradle-6.7.1-bin.zip: OK Archive: gradle-6.7.1-bin.zip ... inflating: gradle-6.7.1/lib/plugins/opentest4j-1.2.0.jar Unknown machine architecture: aarch64 The command '/bin/sh -c cat /etc/*-release; bash /root/install.sh' returned a non-zero code: 1
What is the current bug behavior?
It's not possible to build gemnasium-maven
on a non-amd64 machine e.g. MacBook M1.
What is the expected correct behavior?
Building the image completes successfully with no errors. Additionally, we build for arm64 targets in our pipeline.
Relevant logs and/or screenshots
Possible fixes
See the troubleshooting section for possible workarounds.
Apply the following patch:
patch
Here are the changes made:
- Update ASDF to version
0.10.2
- Add the
xz-utils
dependencies required by the Maven ASDF plugin - Update
asdf_update_java_home
callsite(s) to_asdf_java_update_java_home
. See gemnasium-maven build broken because asdf_updat... (#324267 - closed) for more information. - Create a symbolic link from
/usr/bin/env
to/bin/env
to fix missing/bin/env
issue caused by one of the plugins. It expects to find/bin/env
instead of/usr/bin/env
. - Add the
bats
,shfmt
, andshellcheck
plugins that seem to be required by ASDF0.10.2
.
diff --git a/build/gemnasium-maven/debian/Dockerfile b/build/gemnasium-maven/debian/Dockerfile
index d1cb72df..47a8b6f0 100644
--- a/build/gemnasium-maven/debian/Dockerfile
+++ b/build/gemnasium-maven/debian/Dockerfile
@@ -40,7 +40,7 @@ ENV DEP_GRAPH_PLUGIN="addSbtPlugin(\"net.virtual-void\" % \"sbt-dependency-graph
ENV FIPS_MODE="false"
ENV ASDF_DATA_DIR="/opt/asdf"
-ENV ASDF_VERSION="v0.8.1"
+ENV ASDF_VERSION="v0.10.2"
ENV HOME=/gemnasium-maven
ENV TERM="xterm"
WORKDIR $HOME
diff --git a/build/gemnasium-maven/debian/config/.bashrc b/build/gemnasium-maven/debian/config/.bashrc
index 151402d7..105bc2fc 100644
--- a/build/gemnasium-maven/debian/config/.bashrc
+++ b/build/gemnasium-maven/debian/config/.bashrc
@@ -48,7 +48,7 @@ function switch_to() {
echo "Using ${tool} version '${selected_version}'"
asdf shell "$tool" "$selected_version"
- asdf_update_java_home
+ _asdf_update_java_home
}
function enable_dev_mode() {
diff --git a/build/gemnasium-maven/debian/install.sh b/build/gemnasium-maven/debian/install.sh
index 79295782..9bbf5f52 100644
--- a/build/gemnasium-maven/debian/install.sh
+++ b/build/gemnasium-maven/debian/install.sh
@@ -13,7 +13,7 @@ echo ["$(date "+%H:%M:%S")"] "==> Installing packages…"
apt-get clean
apt-get update -q
-apt-get install -y --no-install-recommends bsdmainutils git jq curl ca-certificates zstd unzip
+apt-get install -y --no-install-recommends bsdmainutils git jq curl ca-certificates zstd unzip xz-utils
apt-get upgrade -y
# give write access to CA certificates (OpenShift)
@@ -31,12 +31,15 @@ git checkout "$(git describe --abbrev=0 --tags)"
. "$ASDF_DATA_DIR"/asdf.sh
asdf plugin add java
# Fix issue https://gitlab.com/gitlab-org/gitlab/-/issues/324267
-asdf plugin update java 7dbb3cbb535d755f38d06792821eaf3793f44ae9
+# asdf plugin update java 7dbb3cbb535d755f38d06792821eaf3793f44ae9
# TODO: Use official asdf-maven plugin in gemnasium-maven
# See https://gitlab.com/gitlab-org/gitlab/-/issues/224142
asdf plugin add maven https://github.com/adamcohen/asdf-maven
asdf plugin add sbt
asdf plugin add gradle
+asdf plugin add bats
+asdf plugin add shellcheck
+asdf plugin add shfmt
asdf install
asdf reshim
Implementation
-
Remove from the troubleshooting section in the gemnasium project
/cc @adamcohen @brytannia
Edited by Oscar Tovar