Skip to content

Commit f2bc778

Browse files
authored
Merge pull request ITHACA-FV#619 from ITHACA-FV/Docker
ENH: add Docker dependencies workflow and restructure OF2506 Dockerfiles
2 parents 843ca48 + 4bd4c87 commit f2bc778

File tree

6 files changed

+210
-40
lines changed

6 files changed

+210
-40
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Build Dependencies Docker Images
2+
3+
on:
4+
workflow_dispatch:
5+
6+
env:
7+
REGISTRY: docker.io
8+
IMAGE_NAME: ithacafv/ithacafv-dependencies
9+
10+
jobs:
11+
build-amd64-deps:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
digest: ${{ steps.build.outputs.digest }}
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v3
22+
23+
- name: Log into registry ${{ env.REGISTRY }}
24+
uses: docker/login-action@v3
25+
with:
26+
registry: ${{ env.REGISTRY }}
27+
username: ${{ secrets.DOCKER_USERNAME }}
28+
password: ${{ secrets.DOCKER_PASSWORD }}
29+
30+
- name: Build and push AMD64 dependencies
31+
id: build
32+
uses: docker/build-push-action@v5
33+
with:
34+
context: ./dockerfiles/OF2506/amd64-deps
35+
platforms: linux/amd64
36+
push: true
37+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:amd64
38+
cache-from: type=gha
39+
cache-to: type=gha,mode=max
40+
41+
build-arm64-deps:
42+
runs-on: ubuntu-24.04-arm
43+
outputs:
44+
digest: ${{ steps.build.outputs.digest }}
45+
46+
steps:
47+
- name: Checkout repository
48+
uses: actions/checkout@v4
49+
50+
- name: Set up Docker Buildx
51+
uses: docker/setup-buildx-action@v3
52+
53+
- name: Log into registry ${{ env.REGISTRY }}
54+
uses: docker/login-action@v3
55+
with:
56+
registry: ${{ env.REGISTRY }}
57+
username: ${{ secrets.DOCKER_USERNAME }}
58+
password: ${{ secrets.DOCKER_PASSWORD }}
59+
60+
- name: Build and push ARM64 dependencies
61+
id: build
62+
uses: docker/build-push-action@v5
63+
with:
64+
context: ./dockerfiles/OF2506/arm64-deps
65+
platforms: linux/arm64
66+
push: true
67+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:arm64
68+
cache-from: type=gha
69+
cache-to: type=gha,mode=max

dockerfiles/OF2412/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
ARG TARGETARCH
44
FROM ithacafv/openfoam2412-muq2-pytorch:${TARGETARCH} AS base
55

6-
LABEL maintainer="[email protected]"
6+
LABEL maintainer="[email protected]"
77

88
USER root
99

@@ -72,4 +72,4 @@ WORKDIR $HOME
7272
# Source bashrc on container start
7373
RUN /bin/bash -c "source /etc/bash.bashrc"
7474

75-
ENTRYPOINT ["/bin/bash"]
75+
ENTRYPOINT ["/bin/bash"]

dockerfiles/OF2506/Dockerfile

Lines changed: 73 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,75 @@
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)
362
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"
3174

75+
ENTRYPOINT ["/bin/bash"]

dockerfiles/OF2506/Makefile

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Start from the ubuntu Openfoam 2106 image
2+
FROM opencfd/openfoam-dev:2506
3+
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/openfoam2412/etc/bashrc' >> ~/.bashrc
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Start from the ubuntu Openfoam 2106 image
2+
FROM opencfd/openfoam-dev:2505
3+
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 libc6-dev && \
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-aarch64.sh && \
17+
bash Miniconda3-latest-Linux-aarch64.sh -b && \
18+
rm Miniconda3-latest-Linux-aarch64.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 cmake pybind11 eigen hdf5 nlopt && \
27+
git clone https://bitbucket.org/mituq/muq2.git /tmp/muq2 && \
28+
cd /tmp/muq2 && rm -rf build && mkdir build && cd build && \
29+
cmake -DCMAKE_INSTALL_PREFIX=/root/miniconda3 -DMUQ_USE_PYTHON=ON .. && \
30+
make -j4 && make install && \
31+
cd / && rm -rf /tmp/muq2 && \
32+
conda clean -y --all
33+
ENV TORCH_LIBRARIES=/libtorch
34+
ENV MUQ_LIBRARIES=/root/miniconda3
35+
RUN echo 'source /usr/lib/openfoam/openfoam2412/etc/bashrc' >> ~/.bashrc
36+

0 commit comments

Comments
 (0)