|
| 1 | +FROM ubuntu:24.04 as base_image |
| 2 | +USER root |
| 3 | +SHELL ["/bin/bash", "-c"] |
| 4 | +ENV DEBIAN_FRONTEND=noninteractive |
| 5 | +# We set a sensical value, but still have the possibilty to influence this via the build time arguments. |
| 6 | +# When the dockerfile is built using the systemtests.py we set the PRECICE_UID and PRECICE_GID to the user executing the systemtests. |
| 7 | +# This ensures no file ownership problems down the line and is the most easy fix, as we normally built the containers locally |
| 8 | +# If not built via the systemtests.py its either possible to specify manually but 1000 would be the default anyway. |
| 9 | +ARG PRECICE_UID=1000 |
| 10 | +ARG PRECICE_GID=1000 |
| 11 | +RUN groupadd -g ${PRECICE_GID} precice && useradd -u ${PRECICE_UID} -g ${PRECICE_GID} -ms /bin/bash precice |
| 12 | +ENV PATH="${PATH}:/home/precice/.local/bin" |
| 13 | +ENV LD_LIBRARY_PATH="/home/precice/.local/lib:${LD_LIBRARY_PATH}" |
| 14 | +ENV CPATH="/home/precice/.local/include:$CPATH" |
| 15 | +# Enable detection with pkg-config and CMake |
| 16 | +ENV PKG_CONFIG_PATH="/home/precice/.local/lib/pkgconfig:$PKG_CONFIG_PATH" |
| 17 | +ENV CMAKE_PREFIX_PATH="/home/precice/.local:$CMAKE_PREFIX_PATH" |
| 18 | +USER precice |
| 19 | + |
| 20 | +FROM base_image as precice_dependecies |
| 21 | +USER root |
| 22 | +# Installing necessary dependecies for preCICE |
| 23 | +RUN apt-get -qq update && \ |
| 24 | + apt-get -qq -y install \ |
| 25 | + build-essential \ |
| 26 | + software-properties-common \ |
| 27 | + cmake \ |
| 28 | + curl \ |
| 29 | + g++ \ |
| 30 | + gfortran \ |
| 31 | + git \ |
| 32 | + libbenchmark-dev \ |
| 33 | + libboost-all-dev \ |
| 34 | + libeigen3-dev \ |
| 35 | + libxml2-dev \ |
| 36 | + lsb-release \ |
| 37 | + petsc-dev \ |
| 38 | + python3-dev \ |
| 39 | + python3-numpy \ |
| 40 | + python3-pip \ |
| 41 | + python3-venv \ |
| 42 | + pkg-config \ |
| 43 | + wget |
| 44 | +USER precice |
| 45 | +RUN python3 -m pip install --upgrade pip |
| 46 | + |
| 47 | + |
| 48 | +FROM precice_dependecies as precice |
| 49 | +# Install & build precice into /home/precice/precice |
| 50 | +ARG PRECICE_REF |
| 51 | +ARG PRECICE_PRESET |
| 52 | +USER precice |
| 53 | +WORKDIR /home/precice |
| 54 | +RUN git clone https://github.com/precice/precice.git precice && \ |
| 55 | + cd precice && \ |
| 56 | + git checkout ${PRECICE_REF} && \ |
| 57 | + mkdir build && cd build &&\ |
| 58 | + cmake .. --preset=${PRECICE_PRESET} -DCMAKE_INSTALL_PREFIX=/home/precice/.local/ -DPRECICE_PETScMapping=OFF -DBUILD_TESTING=OFF && \ |
| 59 | + make all install -j $(nproc) |
| 60 | + |
| 61 | +FROM precice_dependecies as openfoam_adapter |
| 62 | +ARG OPENFOAM_EXECUTABLE |
| 63 | +USER root |
| 64 | +RUN apt-get update &&\ |
| 65 | + wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | bash &&\ |
| 66 | + apt-get -qq install ${OPENFOAM_EXECUTABLE}-dev &&\ |
| 67 | + ln -s $(which ${OPENFOAM_EXECUTABLE} ) /usr/bin/openfoam |
| 68 | +USER precice |
| 69 | +COPY --from=precice /home/precice/.local/ /home/precice/.local/ |
| 70 | +ARG OPENFOAM_ADAPTER_REF |
| 71 | +# Build the OpenFOAM adapter |
| 72 | +USER precice |
| 73 | +WORKDIR /home/precice |
| 74 | +RUN git clone https://github.com/precice/openfoam-adapter.git &&\ |
| 75 | + cd openfoam-adapter && \ |
| 76 | + git checkout ${OPENFOAM_ADAPTER_REF} && \ |
| 77 | + /usr/bin/${OPENFOAM_EXECUTABLE} ./Allwmake -j $(nproc) |
| 78 | + |
| 79 | + |
| 80 | +FROM precice_dependecies as python_bindings |
| 81 | +COPY --from=precice /home/precice/.local/ /home/precice/.local/ |
| 82 | +ARG PYTHON_BINDINGS_REF |
| 83 | +USER precice |
| 84 | +WORKDIR /home/precice |
| 85 | +# Builds the precice python bindings for python3 |
| 86 | +# Installs also matplotlib as its needed for the elastic-tube 1d fluid-python participant. |
| 87 | +RUN python3 -m venv /home/precice/venv && \ |
| 88 | + . /home/precice/venv/bin/activate && \ |
| 89 | + pip3 install git+https://github.com/precice/python-bindings.git@${PYTHON_BINDINGS_REF} && \ |
| 90 | + pip3 install matplotlib |
| 91 | + |
| 92 | +FROM precice_dependecies as fenics_adapter |
| 93 | +COPY --from=python_bindings /home/precice/.local /home/precice/.local |
| 94 | +USER root |
| 95 | +RUN add-apt-repository -y ppa:fenics-packages/fenics && \ |
| 96 | + apt-get -qq update && \ |
| 97 | + apt-get -qq install --no-install-recommends fenics |
| 98 | +USER precice |
| 99 | +ARG FENICS_ADAPTER_REF |
| 100 | +# Building fenics-adapter |
| 101 | +RUN python3 -m venv /home/precice/venv && \ |
| 102 | + . /home/precice/venv/bin/activate && \ |
| 103 | + pip3 install git+https://github.com/precice/fenics-adapter.git@${FENICS_ADAPTER_REF} |
| 104 | + |
| 105 | + |
| 106 | +FROM precice_dependecies as nutils_adapter |
| 107 | +COPY --from=python_bindings /home/precice/.local /home/precice/.local |
| 108 | +USER precice |
| 109 | +# Installing nutils - There is no adapter |
| 110 | +RUN python3 -m venv /home/precice/venv && \ |
| 111 | + . /home/precice/venv/bin/activate && \ |
| 112 | + pip3 install nutils |
| 113 | + |
| 114 | + |
| 115 | +FROM precice_dependecies as calculix_adapter |
| 116 | +COPY --from=precice /home/precice/.local /home/precice/.local |
| 117 | +USER root |
| 118 | +RUN apt-get -qq update && \ |
| 119 | + apt-get -qq install libarpack2-dev libspooles-dev libyaml-cpp-dev |
| 120 | +ARG CALCULIX_VERSION |
| 121 | +USER precice |
| 122 | +#Download Calculix |
| 123 | +WORKDIR /home/precice |
| 124 | +RUN wget http://www.dhondt.de/ccx_${CALCULIX_VERSION}.src.tar.bz2 && \ |
| 125 | + tar xvjf ccx_${CALCULIX_VERSION}.src.tar.bz2 && \ |
| 126 | + rm -fv ccx_${CALCULIX_VERSION}.src.tar.bz2 |
| 127 | + |
| 128 | +ARG CALCULIX_ADAPTER_REF |
| 129 | +WORKDIR /home/precice |
| 130 | +RUN git clone https://github.com/precice/calculix-adapter.git && \ |
| 131 | + cd calculix-adapter && \ |
| 132 | + git checkout ${CALCULIX_ADAPTER_REF} &&\ |
| 133 | + make CXX_VERSION=${CALCULIX_VERSION} ADDITIONAL_FFLAGS="-fallow-argument-mismatch" -j $(nproc) && \ |
| 134 | + ln -s /home/precice/calculix-adapter/bin/ccx_preCICE /home/precice/.local/bin/ccx_preCICE |
| 135 | + |
| 136 | +FROM python_bindings as su2_adapter |
| 137 | +COPY --from=precice /home/precice/.local /home/precice/.local |
| 138 | +USER root |
| 139 | +RUN apt-get -qq update && \ |
| 140 | + apt-get -qq install swig |
| 141 | +ARG SU2_VERSION |
| 142 | +USER precice |
| 143 | + |
| 144 | +# Download and build SU2 (We could also use pre-built binaries from the SU2 releases) |
| 145 | +WORKDIR /home/precice |
| 146 | +RUN wget https://github.com/su2code/SU2/archive/refs/tags/v${SU2_VERSION}.tar.gz && \ |
| 147 | + tar xvzf v${SU2_VERSION}.tar.gz && \ |
| 148 | + rm -fv v${SU2_VERSION}.tar.gz |
| 149 | +RUN python3 -m venv /home/precice/venv && \ |
| 150 | + . /home/precice/venv/bin/activate && \ |
| 151 | + pip3 install mpi4py |
| 152 | +ARG SU2_ADAPTER_REF |
| 153 | +WORKDIR /home/precice |
| 154 | +ENV SU2_RUN="/home/precice/SU2_RUN" |
| 155 | +ENV SU2_HOME="/home/precice/SU2-${SU2_VERSION}" |
| 156 | +ENV PATH="/home/precice/su2-adapter/run:$SU2_RUN:$PATH" |
| 157 | +ENV PYTHONPATH="$SU2_RUN:$PYTHONPATH" |
| 158 | +RUN git clone https://github.com/precice/su2-adapter.git && \ |
| 159 | + cd su2-adapter &&\ |
| 160 | + git checkout ${SU2_ADAPTER_REF} &&\ |
| 161 | + ./su2AdapterInstall |
| 162 | +RUN cd "${SU2_HOME}" &&\ |
| 163 | + ./meson.py build -Denable-pywrapper=true --prefix=$SU2_RUN &&\ |
| 164 | + ./ninja -C build install |
0 commit comments