|
1 | | -# Start from the ubuntu Openfoam 2106 image |
2 | | -FROM opencfd/openfoam-dev:2506 |
| 1 | +# Multi-architecture Dockerfile for ITHACA-FV |
| 2 | +# Automatically selects the correct base image based on target platform |
| 3 | +ARG TARGETARCH |
| 4 | +FROM ithacafv/openfoam2506-muq2-pytorch:${TARGETARCH} AS base |
| 5 | + |
| 6 | +LABEL maintainer= "[email protected]" |
| 7 | + |
| 8 | +USER root |
| 9 | + |
| 10 | +# Install additional packages |
| 11 | +RUN apt-get update && \ |
| 12 | + apt-get install -y \ |
| 13 | + git \ |
| 14 | + vim \ |
| 15 | + ssh \ |
| 16 | + sudo \ |
| 17 | + wget \ |
| 18 | + software-properties-common && \ |
| 19 | + rm -rf /var/lib/apt/lists/* |
| 20 | + |
| 21 | +# Create ithacafv user and group |
| 22 | +ARG USER=ithacafv |
| 23 | +RUN if id -u 1000 >/dev/null 2>&1; then \ |
| 24 | + userdel $(id -nu 1000) || true; \ |
| 25 | + fi && \ |
| 26 | + if getent group 1000 >/dev/null 2>&1; then \ |
| 27 | + groupdel $(getent group 1000 | cut -d: -f1) || true; \ |
| 28 | + fi && \ |
| 29 | + adduser --disabled-password --gecos '' --uid 1000 $USER && \ |
| 30 | + adduser $USER sudo && \ |
| 31 | + echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers |
| 32 | + |
| 33 | +# Set environment variables |
| 34 | +ENV HOME=/home/$USER |
| 35 | +ENV USER=$USER |
| 36 | + |
| 37 | +# Set working directory and clone ITHACA-FV |
| 38 | +WORKDIR /opt |
| 39 | +RUN git clone https://github.com/mathLab/ITHACA-FV.git && \ |
| 40 | + chown -R $USER:$USER ITHACA-FV && \ |
| 41 | + chown -R $USER:$USER /home/$USER |
| 42 | + |
| 43 | +# Environment variables for bashrc |
| 44 | +ARG of_var="source /usr/lib/openfoam/openfoam2412/etc/bashrc" |
| 45 | +ARG ithaca_var="source /opt/ITHACA-FV/etc/bashrc" |
| 46 | + |
| 47 | +# Update bashrc with OpenFOAM and ITHACA-FV sources |
| 48 | +RUN echo $of_var >> /etc/bash.bashrc && \ |
| 49 | + echo $ithaca_var >> /etc/bash.bashrc |
| 50 | + |
| 51 | +# Switch to ithacafv user |
| 52 | +USER $USER |
| 53 | + |
| 54 | +# Build ITHACA-FV |
| 55 | +RUN /bin/bash -c "source /usr/lib/openfoam/openfoam2412/etc/bashrc && \ |
| 56 | + cd ITHACA-FV && \ |
| 57 | + git submodule update --init && \ |
| 58 | + source etc/bashrc && \ |
| 59 | + ./Allwmake -au -j 4" |
| 60 | + |
| 61 | +# Copy binaries and libraries to system paths (as root) |
3 | 62 | USER root |
4 | | -ARG PYTHON_VERSION=3.7 |
5 | | -ENV PATH="/root/miniconda3/bin:${PATH}" |
6 | | - |
7 | | -RUN rm /etc/apt/sources.list.d/openfoam.list && \ |
8 | | - cp /etc/apt/sources.list /etc/apt/sources.list.backup && \ |
9 | | - grep -v -e "openfoam" /etc/apt/sources.list.backup > /etc/apt/sources.list && \ |
10 | | - echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \ |
11 | | - apt-get update && \ |
12 | | - apt-get install -yy -q pwgen npm nodejs cmake git wget bzip2 unzip && \ |
13 | | - apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* |
14 | | - |
15 | | -# Anaconda installing |
16 | | -RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \ |
17 | | -bash Miniconda3-latest-Linux-x86_64.sh -b && \ |
18 | | -rm Miniconda3-latest-Linux-x86_64.sh && \ |
19 | | -. /root/miniconda3/etc/profile.d/conda.sh && \ |
20 | | -export PATH=/root/miniconda3/bin:$PATH && \ |
21 | | -wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.7.1%2Bcpu.zip && \ |
22 | | -unzip libtorch-cxx11-abi-shared-with-deps-2.7.1+cpu.zip && \ |
23 | | -rm libtorch-cxx11-abi-shared-with-deps-2.7.1+cpu.zip && \ |
24 | | -conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main && \ |
25 | | -conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r && \ |
26 | | -conda install -y -c conda-forge muq cmake pybind11 && \ |
27 | | -conda clean -y --all |
28 | | -ENV TORCH_LIBRARIES=/libtorch |
29 | | -ENV MUQ_LIBRARIES=/root/miniconda3 |
30 | | -RUN echo 'source /usr/lib/openfoam/openfoam2506/etc/bashrc' >> ~/.bashrc |
| 63 | +RUN if [ -d "/home/$USER/OpenFOAM/$USER-openfoam2412/platforms/linux64GccDPInt32Opt/bin" ]; then \ |
| 64 | + cp -r /home/$USER/OpenFOAM/$USER-openfoam2412/platforms/linux64GccDPInt32Opt/bin/* /usr/local/bin/ || true; \ |
| 65 | + cp -r /home/$USER/OpenFOAM/$USER-openfoam2412/platforms/linux64GccDPInt32Opt/lib/* /usr/local/lib/ || true; \ |
| 66 | + fi |
| 67 | + |
| 68 | +# Final setup |
| 69 | +USER $USER |
| 70 | +WORKDIR $HOME |
| 71 | + |
| 72 | +# Source bashrc on container start |
| 73 | +RUN /bin/bash -c "source /etc/bash.bashrc" |
31 | 74 |
|
| 75 | +ENTRYPOINT ["/bin/bash"] |
0 commit comments