Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Separated out the Intel and GNU versions of the Dockerfile into separ…
Browse files Browse the repository at this point in the history
…ate files for clarity
  • Loading branch information
MintoDA1 authored and MintoDA1 committed Aug 12, 2023
1 parent 20abadb commit d5168fe
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dump*
#Docker and Singularity files
!docker/
!singularity/
!Dockerfile
!Dockerfile.*
!environment.yml
!.dockerignore

Expand Down
62 changes: 62 additions & 0 deletions Dockerfile.gnu
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# 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/

# 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"

#Export the generated wheel file to the host machine
FROM scratch as export-wheel
COPY --from=build-swiftest /swiftest/dist/ /dist/
23 changes: 6 additions & 17 deletions Dockerfile → Dockerfile.intel
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
# dynamically.

# This build target compiles all dependencies and the swiftest driver itself
ARG BUILDIMAGE="intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04"
FROM ${BUILDIMAGE} as build-deps
ARG BUILDIMAGE="intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04"
FROM intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04 as build-deps
ENV SCRIPT_DIR="buildscripts"
SHELL ["/bin/bash", "--login", "-c"]
ENV SHELL="/bin/bash"
Expand All @@ -28,18 +26,12 @@ 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 if [ "$BUILDIMAGE" = "intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04" ]; then \
apt-get update && \
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends m4 && \
rm -rf /var/lib/apt/lists/* && \
${SCRIPT_DIR}/build_dependencies.sh Intel; \
else \
${SCRIPT_DIR}/make_build_environment.sh && \
echo "conda activate swiftest-build-env" >> ~/.bashrc && \
/bin/bash -lic "${SCRIPT_DIR}/build_dependencies.sh GNU-Linux"; \
fi
${SCRIPT_DIR}/build_dependencies.sh Intel

FROM ${BUILDIMAGE} as build-swiftest
FROM intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04 as build-swiftest
ENV SCRIPT_DIR="buildscripts"
SHELL ["/bin/bash", "--login", "-c"]
ENV SHELL="/bin/bash"
Expand All @@ -64,11 +56,8 @@ COPY ./pyproject.toml ./
COPY ./requirements.txt ./
COPY ./version.txt ./
ENV PIP_ROOT_USER_ACTION=ignore
RUN if [ "$BUILDIMAGE" = "intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04" ]; then \
/bin/bash -lic "${SCRIPT_DIR}/build_swiftest.sh Intel"; \
else \
/bin/bash -lic "${SCRIPT_DIR}/build_swiftest.sh GNU-Linux"; \
fi
RUN /bin/bash -lic && "${SCRIPT_DIR}/make_build_environment" && \
/bin/bash -lic "${SCRIPT_DIR}/build_swiftest.sh Intel"

#Export the generated wheel file to the host machine
FROM scratch as export-wheel
Expand Down
6 changes: 3 additions & 3 deletions buildscripts/build_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ case $OS in
if command -v docker &> /dev/null; then
echo "Docker detected"
if [ "$ARCH" = "x86_64" ]; then
BUILDIMAGE="intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04"
COMPILER="intel"
else
BUILDIMAGE="condaforge/mambaforge:23.1.0-4"
COMPILER="gnu"
fi
cmd="docker build --tag swiftest:latest --tag swiftest:${VERSION} --build-arg BUILDIMAGE=\"${BUILDIMAGE}\" ."
cmd="docker build --tag swiftest:latest --tag swiftest:${VERSION} --file=dockerfile.${COMPILER} ."
echo "Executing Docker build:\n${cmd}"
eval "$cmd"
exit 0
Expand Down

0 comments on commit d5168fe

Please sign in to comment.