Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
swiftest/Dockerfile.GNU-Linux
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
73 lines (64 sloc)
2.93 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 ubuntu:focal-20240123 as build-deps | |
SHELL ["/bin/bash", "--login", "-c"] | |
WORKDIR /swiftest | |
ENV INSTALL_DIR=/usr/local | |
ENV NCDIR="${INSTALL_DIR}" | |
ENV NFDIR="${INSTALL_DIR}" | |
ENV HDF5_ROOT="${INSTALL_DIR}" | |
ENV HDF5_LIBDIR="${HDF5_ROOT}/lib" | |
ENV HDF5_INCLUDE_DIR="${HDF5_ROOT}/include" | |
ENV HDF5_PLUGIN_PATH="${HDF5_LIBDIR}/plugin" | |
ENV LD_LIBRARY_PATH="${INSTALL_DIR}/lib" | |
ENV LDFLAGS="-L${INSTALL_DIR}/lib" | |
ENV CPPFLAGS="-I${INSTALL_DIR}/include" | |
COPY ./buildscripts/ ./buildscripts/ | |
RUN apt-get update && \ | |
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ | |
m4 && \ | |
rm -rf /var/lib/apt/lists/* && \ | |
buildscripts/build_dependencies.sh -p ${INSTALL_DIR} | |
FROM ubuntu:focal-20240123 as build-swiftest | |
SHELL ["/bin/bash", "--login", "-c"] | |
ENV SHELL="/bin/bash" | |
WORKDIR /swiftest | |
# Copy build artifacts over to the swiftest package builder stage | |
ENV INSTALL_DIR=/usr/local | |
COPY --from=build-deps ${INSTALL_DIR}/ ${INSTALL_DIR}/ | |
# Compile the Swiftest project | |
COPY ./cmake/ ./cmake/ | |
COPY ./pyproject.toml ./ | |
COPY ./src/ ./src/ | |
COPY ./swiftest/ ./swiftest/ | |
COPY ./tests/ ./tests/ | |
COPY ./CMakeLists.txt ./ | |
COPY ./version.txt ./ | |
# Generate the build environment in conda | |
ENV PIP_ROOT_USER_ACTION=ignore | |
ENV LDFLAGS="-L${INSTALL_DIR}/lib" | |
ENV CFLAGS="-fPIC" | |
ENV FFLAGS=${CFLAGS} | |
ENV SKBUILD_CONFIGURE_OPTIONS="-DBUILD_SHARED_LIBS=OFF -DMACHINE_CODE_VALUE=\"native\"" | |
RUN export NFCFG="${INSTALL_DIR}/bin/nf-config" && \ | |
export LIBS=$($NFCFG --flibs) && \ | |
python3 -m pip install build pip && \ | |
python3 -m build --wheel | |
#Export the generated wheel file to the host machine | |
FROM scratch as export-wheel | |
COPY --from=build-swiftest /swiftest/dist/ ./ | |
FROM scratch as export-driver | |
COPY --from=build-swiftest /swiftest/build/bin/swiftest ./ | |
COPY --from=build-swiftest /swiftest/build/bin/libswiftest.so ./ |