-
-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathDockerfile
More file actions
292 lines (274 loc) · 11.1 KB
/
Copy pathDockerfile
File metadata and controls
292 lines (274 loc) · 11.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
FROM ubuntu:24.04 AS base_image
USER root
SHELL ["/bin/bash", "-c"]
ENV DEBIAN_FRONTEND=noninteractive
# We set a sensical value, but still have the possibilty to influence this via the build time arguments.
# When the dockerfile is built using the systemtests.py we set the PRECICE_UID and PRECICE_GID to the user executing the systemtests.
# This ensures no file ownership problems down the line and is the most easy fix, as we normally built the containers locally
# If not built via the systemtests.py its either possible to specify manually but 1000 would be the default anyway.
ARG PRECICE_UID=1000
ARG PRECICE_GID=1000
RUN set -eux; \
if getent group "${PRECICE_GID}" >/dev/null; then \
existing_group="$(getent group "${PRECICE_GID}" | cut -d: -f1)"; \
if [ "${existing_group}" != "precice" ]; then \
groupmod -n precice "${existing_group}"; \
fi; \
else \
groupadd -g "${PRECICE_GID}" precice; \
fi; \
if getent passwd "${PRECICE_UID}" >/dev/null; then \
existing_user="$(getent passwd "${PRECICE_UID}" | cut -d: -f1)"; \
if [ "${existing_user}" != "precice" ]; then \
usermod -l precice -d /home/precice -m "${existing_user}"; \
fi; \
usermod -g "${PRECICE_GID}" precice; \
else \
useradd -u "${PRECICE_UID}" -g "${PRECICE_GID}" -ms /bin/bash precice; \
fi; \
mkdir -p /home/precice; \
chown -R "${PRECICE_UID}:${PRECICE_GID}" /home/precice
ENV PATH="${PATH}:/home/precice/.local/bin"
ENV LD_LIBRARY_PATH="/home/precice/.local/lib:${LD_LIBRARY_PATH}"
ENV CPATH="/home/precice/.local/include:$CPATH"
# Enable detection with pkg-config and CMake
ENV PKG_CONFIG_PATH="/home/precice/.local/lib/pkgconfig:$PKG_CONFIG_PATH"
ENV CMAKE_PREFIX_PATH="/home/precice/.local:$CMAKE_PREFIX_PATH"
USER precice
FROM base_image AS precice_dependecies
USER root
# Installing necessary dependecies for preCICE
RUN apt-get -qq update && \
apt-get -qq -y install \
build-essential \
software-properties-common \
cmake \
curl \
g++ \
gfortran \
git \
libbenchmark-dev \
libboost-all-dev \
libeigen3-dev \
libopenmpi-dev \
libxml2-dev \
lsb-release \
openmpi-bin \
petsc-dev \
python3-dev \
python3-numpy \
python3-pip \
python3-venv \
pkg-config \
wget
USER precice
FROM precice_dependecies AS precice
# Install & build precice into /home/precice/precice
ARG PRECICE_PR
ARG PRECICE_REF
ARG PRECICE_PRESET
USER precice
WORKDIR /home/precice
RUN git clone https://github.com/precice/precice.git precice && \
cd precice && \
if [ -n "${PRECICE_PR}" ]; then git fetch origin pull/${PRECICE_PR}/head; fi && \
git checkout ${PRECICE_REF} && \
mkdir build && cd build &&\
cmake .. --preset=${PRECICE_PRESET} -DCMAKE_INSTALL_PREFIX=/home/precice/.local/ -DBUILD_TESTING=OFF && \
make all install -j $(nproc)
FROM precice_dependecies AS openfoam_adapter
ARG OPENFOAM_EXECUTABLE
USER root
RUN apt-get update &&\
wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | bash &&\
apt-get -qq install ${OPENFOAM_EXECUTABLE}-dev &&\
ln -s $(which ${OPENFOAM_EXECUTABLE} ) /usr/bin/openfoam
USER precice
COPY --from=precice /home/precice/.local/ /home/precice/.local/
ARG OPENFOAM_ADAPTER_PR
ARG OPENFOAM_ADAPTER_REF
# Build the OpenFOAM adapter
USER precice
WORKDIR /home/precice
RUN git clone https://github.com/precice/openfoam-adapter.git &&\
cd openfoam-adapter && \
if [ -n "${OPENFOAM_ADAPTER_PR}" ]; then git fetch origin pull/${OPENFOAM_ADAPTER_PR}/head; fi && \
git checkout ${OPENFOAM_ADAPTER_REF} && \
/usr/bin/${OPENFOAM_EXECUTABLE} ./Allwmake -j $(nproc)
FROM precice_dependecies AS python_bindings
COPY --from=precice /home/precice/.local/ /home/precice/.local/
ARG PYTHON_BINDINGS_REF
USER precice
WORKDIR /home/precice
# Builds the precice python bindings for python3
# Installs also matplotlib as its needed for the elastic-tube 1d fluid-python participant.
RUN python3 -m venv --system-site-packages /home/precice/venv && \
. /home/precice/venv/bin/activate && \
pip3 install git+https://github.com/precice/python-bindings.git@${PYTHON_BINDINGS_REF} && \
pip3 install matplotlib
ENV VIRTUAL_ENV=/home/precice/venv
ENV PATH="/home/precice/venv/bin:$PATH"
FROM python_bindings AS fenics_adapter
USER root
RUN add-apt-repository -y ppa:fenics-packages/fenics && \
apt-get -qq update && \
apt-get -qq install --no-install-recommends fenics
USER precice
ARG FENICS_ADAPTER_REF
# Building fenics-adapter
RUN pip3 install git+https://github.com/precice/fenics-adapter.git@${FENICS_ADAPTER_REF}
FROM python_bindings AS nutils_adapter
USER precice
# Installing nutils - There is no adapter
RUN pip3 install nutils
FROM precice_dependecies AS calculix_adapter
COPY --from=precice /home/precice/.local /home/precice/.local
USER root
RUN apt-get -qq update && \
apt-get -qq install libarpack2-dev libspooles-dev libyaml-cpp-dev
ARG CALCULIX_VERSION
USER precice
#Download Calculix
WORKDIR /home/precice
RUN wget http://www.dhondt.de/ccx_${CALCULIX_VERSION}.src.tar.bz2 && \
tar xvjf ccx_${CALCULIX_VERSION}.src.tar.bz2 && \
rm -fv ccx_${CALCULIX_VERSION}.src.tar.bz2
ARG CALCULIX_ADAPTER_PR
ARG CALCULIX_ADAPTER_REF
WORKDIR /home/precice
RUN git clone https://github.com/precice/calculix-adapter.git && \
cd calculix-adapter && \
if [ -n "${CALCULIX_ADAPTER_PR}" ]; then git fetch origin pull/${CALCULIX_ADAPTER_PR}/head; fi && \
git checkout ${CALCULIX_ADAPTER_REF} &&\
make CXX_VERSION=${CALCULIX_VERSION} ADDITIONAL_FFLAGS="-fallow-argument-mismatch" -j $(nproc) && \
ln -s /home/precice/calculix-adapter/bin/ccx_preCICE /home/precice/.local/bin/ccx_preCICE
FROM python_bindings AS su2_adapter
USER root
RUN apt-get -qq update && \
apt-get -qq install swig python3-mpi4py python3-setuptools
ARG SU2_VERSION
USER precice
# Download and build SU2 (We could also use pre-built binaries from the SU2 releases)
# The sed command applies a patch needed for Ubuntu 24.04.
WORKDIR /home/precice
RUN wget https://github.com/su2code/SU2/archive/refs/tags/v${SU2_VERSION}.tar.gz && \
tar xvzf v${SU2_VERSION}.tar.gz && \
rm -fv v${SU2_VERSION}.tar.gz
ARG SU2_ADAPTER_PR
ARG SU2_ADAPTER_REF
WORKDIR /home/precice
ENV SU2_RUN="/home/precice/SU2_RUN"
ENV SU2_HOME="/home/precice/SU2-${SU2_VERSION}"
ENV PATH="/home/precice/su2-adapter/run:$SU2_RUN:$PATH"
ENV PYTHONPATH="$SU2_RUN:$PYTHONPATH"
RUN git clone https://github.com/precice/su2-adapter.git && \
cd su2-adapter &&\
if [ -n "${SU2_ADAPTER_PR}" ]; then git fetch origin pull/${SU2_ADAPTER_PR}/head; fi && \
git checkout ${SU2_ADAPTER_REF} &&\
./su2AdapterInstall
RUN cd "${SU2_HOME}" &&\
sed -i '1s/^/#include <cstdint>\n/' SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp &&\
./meson.py build -Denable-pywrapper=true --prefix=$SU2_RUN &&\
./ninja -C build install
FROM precice_dependecies AS dealii_adapter
USER root
RUN apt-get update &&\
apt-get -qq install libdeal.ii-dev libdeal.ii-doc cmake make g++
USER precice
COPY --from=precice /home/precice/.local/ /home/precice/.local/
ARG DEALII_ADAPTER_PR
ARG DEALII_ADAPTER_REF
# Build the deal.II adapter
USER precice
WORKDIR /home/precice
ENV PATH="/home/precice/dealii-adapter/:$PATH"
RUN git clone https://github.com/precice/dealii-adapter.git &&\
cd dealii-adapter && \
if [ -n "${DEALII_ADAPTER_PR}" ]; then git fetch origin pull/${DEALII_ADAPTER_PR}/head; fi && \
git checkout ${DEALII_ADAPTER_REF} && \
cmake . && \
make -j $(nproc)
FROM python_bindings AS micro_manager
USER precice
WORKDIR /home/precice
COPY --from=precice /home/precice/.local/ /home/precice/.local/
ARG MICRO_MANAGER_REF
RUN git clone https://github.com/precice/micro-manager.git && \
cd micro-manager && \
if [ -n "${MICRO_MANAGER_PR}" ]; then git fetch origin pull/${MICRO_MANAGER_PR}/head; fi && \
git checkout ${MICRO_MANAGER_REF} && \
pip3 install .
RUN pip3 install pybind11
WORKDIR /home/precice
FROM micro_manager AS dumux_adapter
USER root
ARG DUNE_VERSION
ARG DUMUX_VERSION
USER precice
WORKDIR /home/precice/dumux
ENV PATH="/home/precice/dumux/dune-common/bin:${PATH}"
# This cascade of git clones often led to HTTP 502. Adding some delay and retries in between as a workaround.
RUN for i in $(seq 1 3); do \
if git clone --depth 1 https://gitlab.dune-project.org/core/dune-common.git -b releases/${DUNE_VERSION}; then break; fi; \
rm -rf dune-common; \
if [[ $i -eq 3 ]]; then exit 1; fi; \
sleep 10; \
done
RUN for i in $(seq 1 3); do \
if git clone --depth 1 https://gitlab.dune-project.org/core/dune-geometry.git -b releases/${DUNE_VERSION}; then break; fi; \
rm -rf dune-geometry; \
if [[ $i -eq 3 ]]; then exit 1; fi; \
sleep 10; \
done
RUN for i in $(seq 1 3); do \
if git clone --depth 1 https://gitlab.dune-project.org/core/dune-grid.git -b releases/${DUNE_VERSION}; then break; fi; \
rm -rf dune-grid; \
if [[ $i -eq 3 ]]; then exit 1; fi; \
sleep 10; \
done
RUN for i in $(seq 1 3); do \
if git clone --depth 1 https://gitlab.dune-project.org/core/dune-istl.git -b releases/${DUNE_VERSION}; then break; fi; \
rm -rf dune-istl; \
if [[ $i -eq 3 ]]; then exit 1; fi; \
sleep 10; \
done
RUN for i in $(seq 1 3); do \
if git clone --depth 1 https://gitlab.dune-project.org/extensions/dune-subgrid.git -b releases/${DUNE_VERSION}; then break; fi; \
rm -rf dune-subgrid; \
if [[ $i -eq 3 ]]; then exit 1; fi; \
sleep 10; \
done
RUN for i in $(seq 1 3); do \
if git clone --depth 1 https://git.iws.uni-stuttgart.de/dumux-repositories/dumux.git -b releases/${DUMUX_VERSION}; then break; fi; \
rm -rf dumux; \
if [[ $i -eq 3 ]]; then exit 1; fi; \
sleep 10; \
done
RUN for i in $(seq 1 3); do \
if git clone -b cell_problems https://git.iws.uni-stuttgart.de/dumux-appl/dumux-phasefield.git; then break; fi; \
rm -rf dumux-phasefield; \
if [[ $i -eq 3 ]]; then exit 1; fi; \
sleep 10; \
done
RUN for i in $(seq 1 3); do \
if git clone --depth 1 https://gitlab.dune-project.org/extensions/dune-SPGrid.git -b releases/${DUNE_VERSION}; then break; fi; \
rm -rf dune-SPGrid; \
if [[ $i -eq 3 ]]; then exit 1; fi; \
sleep 10; \
done
RUN for i in $(seq 1 3); do \
if git clone --depth 1 https://gitlab.dune-project.org/core/dune-localfunctions.git -b releases/${DUNE_VERSION}; then break; fi; \
rm -rf dune-localfunctions; \
if [[ $i -eq 3 ]]; then exit 1; fi; \
sleep 10; \
done
# build core DUNE, DuMuX and the adapter
ARG DUMUX_ADAPTER_PR
ARG DUMUX_ADAPTER_REF
RUN git clone https://github.com/precice/dumux-adapter.git &&\
cd dumux-adapter && \
if [ -n "${DUMUX_ADAPTER_PR}" ]; then git fetch origin pull/${DUMUX_ADAPTER_PR}/head; fi && \
git checkout ${DUMUX_ADAPTER_REF} && \
cd .. &&\
./dune-common/bin/dunecontrol --opts=./dumux/cmake.opts cmake &&\
./dune-common/bin/dunecontrol make -j $(nproc)