From 677a904b6ccd00f659a0ef97f801cc7d2eb847de Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 28 Feb 2025 14:21:10 +0000 Subject: [PATCH] Avoid x86-specific Dockerfiles/enable ARM Dockerfiles hardcoded one copy operation to x86; generalize to capture ARM as well. Since the target directory cannot have any globs, we need to manually check the right directory, then move the file. Note that this is only necessary since we are forced to switch the compiler, as Ubuntu's default gcc-11 does not work with FlexRIC. When upgrading to Ubuntu 24, these lines should disappear and asan be installed as normal. See commit 94497435e738 ("Upgrade CI images to Ubuntu 22"). --- docker/Dockerfile.gNB.ubuntu22 | 13 ++++++++++++- docker/Dockerfile.nr-cuup.ubuntu22 | 13 ++++++++++++- docker/Dockerfile.nrUE.ubuntu22 | 13 ++++++++++++- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile.gNB.ubuntu22 b/docker/Dockerfile.gNB.ubuntu22 index 35e442f93d..da2074c64b 100644 --- a/docker/Dockerfile.gNB.ubuntu22 +++ b/docker/Dockerfile.gNB.ubuntu22 @@ -77,7 +77,18 @@ RUN apt-get update && \ # library version. Installing it above would install the wrong version. Hence, # copy the right version from ran-build. When upgrading to Ubuntu24, install # the correct one above! -COPY --from=gnb-build /usr/lib/x86_64-linux-gnu/libasan.so.8.0.0 /usr/lib/x86_64-linux-gnu/ +# note: this dockerfile should work for both x86 and arm, hence the glob below +# which should either match "x86_64" (x86) or "aarch64" (ARM); since the target +# directory needs to be also one of those two, but globs don't work in target +# directories, work around this with mv +COPY --from=gnb-build /usr/lib/*-linux-gnu/libasan.so.8.0.0 /usr/lib/ +ARG TARGETPLATFORM +RUN case "${TARGETPLATFORM}" in \ + "linux/amd64") TARGET_DIR=x86_64-linux-gnu ;; \ + "linux/arm64") TARGET_DIR=aarch64-linux-gnu ;; \ + *) exit 1 ;; \ + esac; \ + mv /usr/lib/libasan.so.8.0.0 /usr/lib/$TARGET_DIR/libasan.so.8.0.0 WORKDIR /opt/oai-gnb/bin COPY --from=gnb-build \ diff --git a/docker/Dockerfile.nr-cuup.ubuntu22 b/docker/Dockerfile.nr-cuup.ubuntu22 index 242fac61b8..2952afa34b 100644 --- a/docker/Dockerfile.nr-cuup.ubuntu22 +++ b/docker/Dockerfile.nr-cuup.ubuntu22 @@ -54,7 +54,18 @@ RUN apt-get update && \ # library version. Installing it above would install the wrong version. Hence, # copy the right version from ran-build. When upgrading to Ubuntu24, install # the correct one above! -COPY --from=gnb-build /usr/lib/x86_64-linux-gnu/libasan.so.8.0.0 /usr/lib/x86_64-linux-gnu/ +# note: this dockerfile should work for both x86 and arm, hence the glob below +# which should either match "x86_64" (x86) or "aarch64" (ARM); since the target +# directory needs to be also one of those two, but globs don't work in target +# directories, work around this with mv +COPY --from=gnb-build /usr/lib/*-linux-gnu/libasan.so.8.0.0 /usr/lib/ +ARG TARGETPLATFORM +RUN case "${TARGETPLATFORM}" in \ + "linux/amd64") TARGET_DIR=x86_64-linux-gnu ;; \ + "linux/arm64") TARGET_DIR=aarch64-linux-gnu ;; \ + *) exit 1 ;; \ + esac; \ + mv /usr/lib/libasan.so.8.0.0 /usr/lib/$TARGET_DIR/libasan.so.8.0.0 ## Copy E2 SM models COPY --from=gnb-build /usr/local/lib/flexric /usr/local/lib/flexric diff --git a/docker/Dockerfile.nrUE.ubuntu22 b/docker/Dockerfile.nrUE.ubuntu22 index dc0d425956..45ad4bbe03 100644 --- a/docker/Dockerfile.nrUE.ubuntu22 +++ b/docker/Dockerfile.nrUE.ubuntu22 @@ -77,7 +77,18 @@ RUN apt-get update && \ # library version. Installing it above would install the wrong version. Hence, # copy the right version from ran-build. When upgrading to Ubuntu24, install # the correct one above! -COPY --from=nr-ue-build /usr/lib/x86_64-linux-gnu/libasan.so.8.0.0 /usr/lib/x86_64-linux-gnu/ +# note: this dockerfile should work for both x86 and arm, hence the glob below +# which should either match "x86_64" (x86) or "aarch64" (ARM); since the target +# directory needs to be also one of those two, but globs don't work in target +# directories, work around this with mv +COPY --from=nr-ue-build /usr/lib/*-linux-gnu/libasan.so.8.0.0 /usr/lib/ +ARG TARGETPLATFORM +RUN case "${TARGETPLATFORM}" in \ + "linux/amd64") TARGET_DIR=x86_64-linux-gnu ;; \ + "linux/arm64") TARGET_DIR=aarch64-linux-gnu ;; \ + *) exit 1 ;; \ + esac; \ + mv /usr/lib/libasan.so.8.0.0 /usr/lib/$TARGET_DIR/libasan.so.8.0.0 WORKDIR /opt/oai-nr-ue/bin COPY --from=nr-ue-build \