From fbcb4dab0ea0d8ddda5afc5c22e910f8c5312164 Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Sat, 12 Aug 2023 14:54:51 -0400 Subject: [PATCH] Adjusted Dockerfile names to keep them consistent with build script variables --- Dockerfile.GNU-Linux | 64 ++++++++++++++++++++++++++++ Dockerfile.intel => Dockerfile.Intel | 0 buildscripts/build_all.sh | 16 +++---- 3 files changed, 70 insertions(+), 10 deletions(-) create mode 100644 Dockerfile.GNU-Linux rename Dockerfile.intel => Dockerfile.Intel (100%) diff --git a/Dockerfile.GNU-Linux b/Dockerfile.GNU-Linux new file mode 100644 index 000000000..b8becbe6d --- /dev/null +++ b/Dockerfile.GNU-Linux @@ -0,0 +1,64 @@ +# Copyright 2023 - David Minton +# This file is part of Swiftest. +# Swiftest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +# Swiftest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# You should have received a copy of the GNU General Public License along with Swiftest. +# If not, see: https://www.gnu.org/licenses. +# +# This Dockerfile will build the Swiftest driver program with minimal external dependencies using the Intel Oneapi toolkit. +# This is done by building static versions of a minimal set of libraries that NetCDF-Fortran needs (Netcdf-C, HDF5, and Zlib). +# These, along with the Intel runtime libraries, are linked statically to the executable. Only the OS-specific libraries are linked +# dynamically. + +# This build target compiles all dependencies and the swiftest driver itself +FROM condaforge/mambaforge:23.1.0-4 as build-deps +ENV SCRIPT_DIR="buildscripts" +SHELL ["/bin/bash", "--login", "-c"] +ENV SHELL="/bin/bash" +WORKDIR /swiftest + +# Compile the dependencies +COPY ./${SCRIPT_DIR}/get_platform.sh ./${SCRIPT_DIR}/ +COPY ./${SCRIPT_DIR}/make_build_environment.sh ./${SCRIPT_DIR} +COPY ./${SCRIPT_DIR}/build_dependencies.sh ./${SCRIPT_DIR}/ +COPY ./${SCRIPT_DIR}/swiftest-build-env.yml ./${SCRIPT_DIR}/ +COPY ./${SCRIPT_DIR}/fetch_dependencies.sh ./${SCRIPT_DIR}/ +RUN ${SCRIPT_DIR}/fetch_dependencies.sh +RUN ${SCRIPT_DIR}/make_build_environment.sh && \ + echo "conda activate swiftest-build-env" >> ~/.bashrc && \ + /bin/bash -lic "${SCRIPT_DIR}/build_dependencies.sh GNU-Linux" + +FROM condaforge/mambaforge:23.1.0-4 as build-swiftest +ENV SCRIPT_DIR="buildscripts" +SHELL ["/bin/bash", "--login", "-c"] +ENV SHELL="/bin/bash" +WORKDIR /swiftest +ENV BUILD_DIR=/swiftest/build + +# Copy build artifacts over to the swiftest package builder stage +COPY --from=build-deps ${BUILD_DIR}/lib/ /usr/local/lib/ +COPY --from=build-deps ${BUILD_DIR}/include/ /usr/local/include/ +COPY --from=build-deps ${BUILD_DIR}/bin/ /usr/local/bin/ +COPY --from=build-deps ${BUILD_DIR}/share/ /usr/local/share/ +COPY --from=build-deps /opt/conda/envs/ /opt/conda/envs/ +COPY --from=build-deps /root/.bashrc /root/ + +# Compile the Swiftest project +COPY ./buildscripts/build_swiftest.sh ./buildscripts/ +COPY ./cmake/ ./cmake/ +COPY ./src/ ./src/ +COPY ./swiftest/ ./swiftest/ +COPY ./CMakeLists.txt ./ +COPY ./setup.py ./ +COPY ./environment.yml ./ +COPY ./pyproject.toml ./ +COPY ./requirements.txt ./ +COPY ./version.txt ./ +ENV PIP_ROOT_USER_ACTION=ignore +RUN /bin/bash -lic "${SCRIPT_DIR}/build_swiftest.sh GNU-Linux /usr/local" + +#Export the generated wheel file to the host machine +FROM scratch as export-wheel +COPY --from=build-swiftest /swiftest/dist/ /dist/ \ No newline at end of file diff --git a/Dockerfile.intel b/Dockerfile.Intel similarity index 100% rename from Dockerfile.intel rename to Dockerfile.Intel diff --git a/buildscripts/build_all.sh b/buildscripts/build_all.sh index 95fb44109..597aa1b35 100755 --- a/buildscripts/build_all.sh +++ b/buildscripts/build_all.sh @@ -41,25 +41,21 @@ echo "Building Swiftest version ${VERSION} for ${OS}-${ARCH}" case $OS in Linux) + if [ "$ARCH" = "x86_64" ]; then + COMPILER="Intel" + else + COMPILER="GNU-Linux" + fi # Determine if Docker is available if command -v docker &> /dev/null; then echo "Docker detected" - if [ "$ARCH" = "x86_64" ]; then - COMPILER="intel" - else - COMPILER="gnu" - fi + cmd="docker build --tag swiftest:latest --tag swiftest:${VERSION} --file=dockerfile.${COMPILER} ." echo "Executing Docker build:\n${cmd}" eval "$cmd" exit 0 else echo "Docker not detected" - if [ "$ARCH" = "x86_64" ]; then - COMPILER="Intel" - else - COMPILER="GNU-Linux" - fi fi ;; MacOSX)