Skip to content

Commit 843ca48

Browse files
authored
Merge pull request ITHACA-FV#618 from ITHACA-FV/Docker
update Docker workflow for release-based publishing with multi-arch support
2 parents 52d03d9 + 59ca169 commit 843ca48

File tree

6 files changed

+269
-41
lines changed

6 files changed

+269
-41
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: Build and Push Multi-Arch Docker Images
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
env:
9+
REGISTRY: docker.io
10+
IMAGE_NAME: ithacafv/ithacafv
11+
12+
jobs:
13+
build-amd64:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
digest: ${{ steps.build.outputs.digest }}
17+
metadata: ${{ steps.meta.outputs.json }}
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Log into registry ${{ env.REGISTRY }}
27+
if: github.event_name != 'pull_request'
28+
uses: docker/login-action@v3
29+
with:
30+
registry: ${{ env.REGISTRY }}
31+
username: ${{ secrets.DOCKER_USERNAME }}
32+
password: ${{ secrets.DOCKER_PASSWORD }}
33+
34+
- name: Extract metadata for ITHACA-FV image
35+
id: meta
36+
uses: docker/metadata-action@v5
37+
with:
38+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
39+
tags: |
40+
type=semver,pattern={{version}}
41+
type=raw,value=latest
42+
43+
- name: Build and push AMD64 image
44+
id: build
45+
uses: docker/build-push-action@v5
46+
with:
47+
context: ./dockerfiles/OF2412
48+
platforms: linux/amd64
49+
labels: ${{ steps.meta.outputs.labels }}
50+
cache-from: type=gha
51+
cache-to: type=gha,mode=max
52+
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
53+
54+
build-arm64:
55+
runs-on: ubuntu-24.04-arm
56+
outputs:
57+
digest: ${{ steps.build.outputs.digest }}
58+
metadata: ${{ steps.meta.outputs.json }}
59+
60+
steps:
61+
- name: Checkout repository
62+
uses: actions/checkout@v4
63+
64+
- name: Set up Docker Buildx
65+
uses: docker/setup-buildx-action@v3
66+
67+
- name: Log into registry ${{ env.REGISTRY }}
68+
if: github.event_name != 'pull_request'
69+
uses: docker/login-action@v3
70+
with:
71+
registry: ${{ env.REGISTRY }}
72+
username: ${{ secrets.DOCKER_USERNAME }}
73+
password: ${{ secrets.DOCKER_PASSWORD }}
74+
75+
- name: Extract metadata for ITHACA-FV image
76+
id: meta
77+
uses: docker/metadata-action@v5
78+
with:
79+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
80+
tags: |
81+
type=semver,pattern={{version}}
82+
type=raw,value=latest
83+
84+
- name: Build and push ARM64 image
85+
id: build
86+
uses: docker/build-push-action@v5
87+
with:
88+
context: ./dockerfiles/OF2412
89+
platforms: linux/arm64
90+
labels: ${{ steps.meta.outputs.labels }}
91+
cache-from: type=gha
92+
cache-to: type=gha,mode=max
93+
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
94+
95+
merge:
96+
runs-on: ubuntu-latest
97+
needs:
98+
- build-amd64
99+
- build-arm64
100+
steps:
101+
- name: Set up Docker Buildx
102+
uses: docker/setup-buildx-action@v3
103+
104+
- name: Log into registry ${{ env.REGISTRY }}
105+
uses: docker/login-action@v3
106+
with:
107+
registry: ${{ env.REGISTRY }}
108+
username: ${{ secrets.DOCKER_USERNAME }}
109+
password: ${{ secrets.DOCKER_PASSWORD }}
110+
111+
- name: Extract metadata for ITHACA-FV image
112+
id: meta
113+
uses: docker/metadata-action@v5
114+
with:
115+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
116+
tags: |
117+
type=semver,pattern={{version}}
118+
type=raw,value=latest
119+
120+
- name: Create and push manifest list
121+
working-directory: /tmp
122+
run: |
123+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
124+
${{ needs.build-amd64.outputs.digest }} \
125+
${{ needs.build-arm64.outputs.digest }}
126+
env:
127+
DOCKER_METADATA_OUTPUT_JSON: ${{ steps.meta.outputs.json }}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ These images are based **OpenFOAM-v2106**, and provided an isolated environment,
8888
In order to pull the image, run the following command:
8989

9090
```
91-
docker pull ithacafv/ithacafv:manifest-latest
91+
docker pull ithacafv/ithacafv:latest
9292
```
9393

9494
Once the image is downloaded, you can start the container and mount the $HOME directory by executing:
9595

9696
```
97-
docker run -ti --rm -v "${HOME}:/home/ithacafv/${USER}" ithacafv/ithacafv:manifest-latest
97+
docker run -ti --rm -v "${HOME}:/home/ithacafv/${USER}" ithacafv/ithacafv:latest
9898
```
9999

100100
### 4. Singularity
@@ -114,7 +114,7 @@ export SINGULARITY_CACHEDIR=$HOME/mycontainter
114114
Buidling singularity image file `.sif` from the docker image, which is build and stored in `$HOME/mycontainter`, The below image used is based **OpenFOAM-v2106**, and where you can find a compiled version of the master branch of **ITHACA-FV**.
115115

116116
```
117-
singularity build ithacafv.sif docker://ithacafv/ithacafv:manifest-latest
117+
singularity build ithacafv.sif docker://ithacafv/ithacafv:latest
118118
```
119119

120120
To view / list all the images/cache,

dockerfiles/OF2412/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:2412
1+
# Multi-architecture Dockerfile for ITHACA-FV
2+
# Automatically selects the correct base image based on target platform
3+
ARG TARGETARCH
4+
FROM ithacafv/openfoam2412-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/openfoam2412/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/OF2412/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:2412
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:2412
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)