diff --git a/Dockerfile b/Dockerfile index 19bd695f..75a8919c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -147,27 +147,6 @@ RUN curl -fsSL https://github.com/lh3/minimap2/releases/download/v2.24/minimap2- # 3. Install programs via pip -# Build cvxopt on linux/arm64 -# cvxopt, an Augur dependency, does not have pre-built binaries for linux/arm64. -# -# First, add system deps for building¹: -# - libopenblas-dev: Contains optimized versions of BLAS and LAPACK. -# - libsuitesparse-dev: Contains SuiteSparse. -# -# Then, "install" (build) separately since the process requires a special -# environment variable². -# -# ¹ https://cvxopt.org/install/#building-and-installing-from-source -# ² https://github.com/cvxopt/cvxopt/issues/125#issuecomment-407396491 -RUN if [[ "$TARGETPLATFORM" == linux/arm64 ]]; then \ - apt-get update && apt-get install -y --no-install-recommends \ - libopenblas-dev \ - libsuitesparse-dev \ - && CVXOPT_SUITESPARSE_INC_DIR=/usr/include/suitesparse \ - pip3 install cvxopt \ - ; \ - fi - # Install jaxlib on linux/arm64 # jaxlib, an evofr dependency, does not have official pre-built binaries for # linux/arm64. A GitHub user has provided them in a fork repo. @@ -239,6 +218,31 @@ RUN /builder-scripts/download-repo https://github.com/nextstrain/fauna master . RUN pip3 install phylo-treetime # Augur + +# Build CVXOPT on linux/arm64 +# CVXOPT, an Augur dependency, does not have pre-built binaries for linux/arm64. +# +# First, add system deps for building¹: +# - libopenblas-dev: Contains optimized versions of BLAS and LAPACK. +# - SuiteSparse: Download the source code so it can be built alongside CVXOPT. +# +# Then, "install" (build) separately since the process requires a special +# environment variable². +# +# ¹ https://cvxopt.org/install/#building-and-installing-from-source +# ² https://cvxopt.org/install/#ubuntu-debian +WORKDIR /cvxopt +RUN if [[ "$TARGETPLATFORM" == linux/arm64 ]]; then \ + apt-get update && apt-get install -y --no-install-recommends \ + libopenblas-dev \ + && mkdir SuiteSparse \ + && curl -fsSL https://api.github.com/repos/DrTimothyAldenDavis/SuiteSparse/tarball/v5.8.1 \ + | tar xzvpf - --no-same-owner --strip-components=1 -C SuiteSparse \ + && CVXOPT_SUITESPARSE_SRC_DIR=$(pwd)/SuiteSparse \ + pip3 install cvxopt \ + ; \ + fi + # Augur is an editable install so we can overlay the augur version in the image # with --volume=.../augur:/nextstrain/augur and still have it globally # accessible and importable. @@ -309,6 +313,20 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash - \ && apt-get update && apt-get install -y nodejs +# Used for platform-specific instructions +ARG TARGETPLATFORM + +# Install CVXOPT deps on linux/arm64 +# CVXOPT, an Augur dependency, was built separately above without runtime deps¹ +# packaged like they are for the amd64 wheel. +# +# ¹ https://cvxopt.org/install/#building-and-installing-from-source +RUN if [[ "$TARGETPLATFORM" == linux/arm64 ]]; then \ + apt-get update && apt-get install -y --no-install-recommends \ + libopenblas-base \ + ; \ + fi + # Configure bash for interactive usage COPY bashrc /etc/bash.bashrc