From f25a79415cd052d9f46a38d47836a98f7c1a5003 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 30 Apr 2024 05:25:05 +0100 Subject: [PATCH] Move erlang installation to base image --- stack/base-with-services/Dockerfile | 10 ++++------ stack/base/Dockerfile | 9 +++++++++ stack/full-stack/Dockerfile | 10 ---------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/stack/base-with-services/Dockerfile b/stack/base-with-services/Dockerfile index 1a987e63..60b71f39 100644 --- a/stack/base-with-services/Dockerfile +++ b/stack/base-with-services/Dockerfile @@ -18,7 +18,9 @@ RUN mamba create -p /opt/conda/envs/aiida-core-services --yes \ # Install RabbitMQ in a dedicated conda environment. # If the architecture is arm64, we install the default version of rabbitmq provided by the generic binary, -# # https://www.rabbitmq.com/install-generic-unix.html the version needs to be compatible with system's erlang version. +# https://www.rabbitmq.com/install-generic-unix.html the version needs to be compatible with system's erlang version. +# Note that system erlang from arm64 is already installed in the base image, together with other APT dependencies +# to save build time. RUN if [ "$TARGETARCH" = "amd64" ]; then \ mamba install -p /opt/conda/envs/aiida-core-services --yes \ rabbitmq-server=3.8.14 && \ @@ -26,10 +28,6 @@ RUN if [ "$TARGETARCH" = "amd64" ]; then \ fix-permissions "${CONDA_DIR}" && \ fix-permissions "/home/${NB_USER}"; \ elif [ "$TARGETARCH" = "arm64" ]; then \ - apt-get update && apt-get install -y --no-install-recommends \ - erlang && \ - rm -rf /var/lib/apt/lists/* && \ - apt-get clean all && \ export RMQ_VERSION=3.9.13 && \ wget -c https://github.com/rabbitmq/rabbitmq-server/releases/download/v${RMQ_VERSION}/rabbitmq-server-generic-unix-${RMQ_VERSION}.tar.xz && \ tar -xf rabbitmq-server-generic-unix-${RMQ_VERSION}.tar.xz && \ @@ -38,7 +36,7 @@ elif [ "$TARGETARCH" = "arm64" ]; then \ fix-permissions "/opt/conda/envs/aiida-core-services/rabbitmq_server-${RMQ_VERSION}" && \ ln -sf /opt/conda/envs/aiida-core-services/rabbitmq_server-${RMQ_VERSION}/sbin/* /opt/conda/envs/aiida-core-services/bin/; \ else \ - echo "Unknown architecture: ${TARGETARCH}."; \ + echo "Unknown architecture: ${TARGETARCH}."; \ fi # Configure AiiDA profile. diff --git a/stack/base/Dockerfile b/stack/base/Dockerfile index 2dcb6476..1f0ce2e2 100644 --- a/stack/base/Dockerfile +++ b/stack/base/Dockerfile @@ -11,6 +11,15 @@ USER root # rsync: needed to support the new AiiDA backup command # povray: rendering engine used in aiidalab-widgets-base ENV EXTRA_APT_PACKAGES "curl povray rsync build-essential" + +# For ARM64 we need to install erlang as it is not available on conda-forge +# (this is needed later as rabbitmq dependency in base-with-services image, +# but we install it here so that we don't have to invoke apt multiple times. +ARG TARGETARCH +RUN if [ "$TARGETARCH" = "arm64" ]; then \ + EXTRA_APT_PACKAGES="erlang "${EXTRA_APT_PACKAGES} \ + fi + RUN apt-get update --yes && \ apt-get install --yes --no-install-recommends ${EXTRA_APT_PACKAGES} && \ apt-get clean && rm -rf /var/lib/apt/lists/* diff --git a/stack/full-stack/Dockerfile b/stack/full-stack/Dockerfile index 05210246..aefe2a82 100644 --- a/stack/full-stack/Dockerfile +++ b/stack/full-stack/Dockerfile @@ -9,16 +9,6 @@ COPY --from=base /opt/config-quick-setup.yaml /opt/ COPY --from=base "${CONDA_DIR}/envs/aiida-core-services" "${CONDA_DIR}/envs/aiida-core-services" COPY --from=base /usr/local/bin/before-notebook.d /usr/local/bin/before-notebook.d -# This is needed because we use multi-stage build, -# the erlang package is not available after the first stage. -ARG TARGETARCH -RUN if [ "$TARGETARCH" = "arm64" ]; then \ - # Install erlang. - apt-get update --yes && \ - apt-get install --yes --no-install-recommends erlang && \ - apt-get clean && rm -rf /var/lib/apt/lists/*; \ -fi - RUN fix-permissions "${CONDA_DIR}" RUN fix-permissions "/home/${NB_USER}/.aiida"