Skip to content

Commit 995fbd1

Browse files
authored
Merge pull request ITHACA-FV#620 from ITHACA-FV/Docker
ENH: consolidate Docker build architecture and update workflow
2 parents 3ca55c0 + 5b71b19 commit 995fbd1

File tree

6 files changed

+85
-103
lines changed

6 files changed

+85
-103
lines changed

.github/workflows/docker-publish.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ jobs:
4444
id: build
4545
uses: docker/build-push-action@v5
4646
with:
47-
context: ./dockerfiles/OF2412
47+
context: ./dockerfiles
48+
file: ./dockerfiles/Dockerfile
4849
platforms: linux/amd64
4950
labels: ${{ steps.meta.outputs.labels }}
5051
cache-from: type=gha
@@ -85,7 +86,8 @@ jobs:
8586
id: build
8687
uses: docker/build-push-action@v5
8788
with:
88-
context: ./dockerfiles/OF2412
89+
context: ./dockerfiles
90+
file: ./dockerfiles/Dockerfile
8991
platforms: linux/arm64
9092
labels: ${{ steps.meta.outputs.labels }}
9193
cache-from: type=gha

.github/workflows/docker_ithaca.yml

Lines changed: 0 additions & 91 deletions
This file was deleted.

dockerfiles/Dockerfile

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Multi-architecture Dockerfile for ITHACA-FV
2+
# Automatically selects the correct base image based on target platform
3+
ARG TARGETARCH
4+
FROM ghcr.io/ithaca-fv/ithacafv-dependencies:${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 with architecture-specific flags
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+
if [ \"$TARGETARCH\" = \"amd64\" ]; then \
60+
./Allwmake -taumq -j 4; \
61+
else \
62+
./Allwmake -tau -j 4; \
63+
fi"
64+
65+
# Copy binaries and libraries to system paths (as root)
66+
USER root
67+
RUN if [ -d "/home/$USER/OpenFOAM/$USER-openfoam2412/platforms/linux64GccDPInt32Opt/bin" ]; then \
68+
cp -r /home/$USER/OpenFOAM/$USER-openfoam2412/platforms/linux64GccDPInt32Opt/bin/* /usr/local/bin/ || true; \
69+
cp -r /home/$USER/OpenFOAM/$USER-openfoam2412/platforms/linux64GccDPInt32Opt/lib/* /usr/local/lib/ || true; \
70+
fi
71+
72+
# Final setup
73+
USER $USER
74+
WORKDIR $HOME
75+
76+
# Source bashrc on container start
77+
RUN /bin/bash -c "source /etc/bash.bashrc"
78+
79+
ENTRYPOINT ["/bin/bash"]

dockerfiles/OF2412/arm64-deps/Dockerfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ bash Miniconda3-latest-Linux-aarch64.sh -b && \
1818
rm Miniconda3-latest-Linux-aarch64.sh && \
1919
. /root/miniconda3/etc/profile.d/conda.sh && \
2020
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 && \
2421
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main && \
2522
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r && \
2623
conda install -y -c conda-forge cmake pybind11 eigen hdf5 nlopt && \
@@ -30,7 +27,6 @@ cmake -DCMAKE_INSTALL_PREFIX=/root/miniconda3 -DMUQ_USE_PYTHON=ON .. && \
3027
make -j4 && make install && \
3128
cd / && rm -rf /tmp/muq2 && \
3229
conda clean -y --all
33-
ENV TORCH_LIBRARIES=/libtorch
3430
ENV MUQ_LIBRARIES=/root/miniconda3
3531
RUN echo 'source /usr/lib/openfoam/openfoam2412/etc/bashrc' >> ~/.bashrc
3632

dockerfiles/OF2506/amd64-deps/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ conda install -y -c conda-forge muq cmake pybind11 && \
2727
conda clean -y --all
2828
ENV TORCH_LIBRARIES=/libtorch
2929
ENV MUQ_LIBRARIES=/root/miniconda3
30-
RUN echo 'source /usr/lib/openfoam/openfoam2412/etc/bashrc' >> ~/.bashrc
30+
RUN echo 'source /usr/lib/openfoam/openfoam2506/etc/bashrc' >> ~/.bashrc

dockerfiles/OF2506/arm64-deps/Dockerfile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ bash Miniconda3-latest-Linux-aarch64.sh -b && \
1818
rm Miniconda3-latest-Linux-aarch64.sh && \
1919
. /root/miniconda3/etc/profile.d/conda.sh && \
2020
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 && \
2421
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main && \
2522
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r && \
2623
conda install -y -c conda-forge cmake pybind11 eigen hdf5 nlopt && \
@@ -30,7 +27,6 @@ cmake -DCMAKE_INSTALL_PREFIX=/root/miniconda3 -DMUQ_USE_PYTHON=ON .. && \
3027
make -j4 && make install && \
3128
cd / && rm -rf /tmp/muq2 && \
3229
conda clean -y --all
33-
ENV TORCH_LIBRARIES=/libtorch
3430
ENV MUQ_LIBRARIES=/root/miniconda3
35-
RUN echo 'source /usr/lib/openfoam/openfoam2412/etc/bashrc' >> ~/.bashrc
31+
RUN echo 'source /usr/lib/openfoam/openfoam2506/etc/bashrc' >> ~/.bashrc
3632

0 commit comments

Comments
 (0)