Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker solver #283

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/docker_solver_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build and Push Docker Image

on: [push,pull_request]
# push:
# branches:
# - main # Trigger the workflow on pushes to the main branch
jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Log in to DockerHub as simvascular
uses: docker/login-action@v2
with:
username: simvascular
password: fontanpvad

- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
file: ./Docker/solver/dockerfile
push: true
tags: simvascular/solver:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: Move new cache to old cache
if: always()
run: mv /tmp/.buildx-cache-new /tmp/.buildx-cache

# ${{ secrets.DOCKER_PASSWORD }}
43 changes: 43 additions & 0 deletions Docker/solver/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Use the pre-configured image from Docker Hub as the base
FROM simvascular/libraries:ubuntu22 AS builder

# Get latest svFSIplus solver from GitHub repository
RUN git clone https://github.com/SimVascular/svFSIplus.git

# Trilinos build
WORKDIR /svFSIplus/build-trilinos
RUN cmake -DSV_USE_TRILINOS:BOOL=ON .. &&\
make -j4

# PETSc build
WORKDIR /svFSIplus/build-petsc
RUN cmake -DSV_PETSC_DIR:STRING=/petsc .. &&\
make -j4


# FINAL IMAGE with solver executable
FROM simvascular/libraries:ubuntu22 AS final

#Set arguments:
# BUILD: build type (petsc, trilinos, none)
# TASKS: number of tasks to run in parallel
# INPUT: input file to run the solver

ENV BUILD=none
ENV TASKS=2
ENV INPUT="svFSIplus.xml"

COPY --from=builder /svFSIplus/build-petsc /build-petsc
COPY --from=builder /svFSIplus/build-trilinos /build-trilinos
COPY --from=builder /svFSIplus/build-trilinos /build-none

# Set the working directory to where input files are mounted
WORKDIR /mnt

# Set entrypoint to run the solver when the container starts and checks if BUILD has the correct value
ENTRYPOINT ["sh", "-c", "\
if [ \"${BUILD}\" != \"none\" ] && [ \"${BUILD}\" != \"petsc\" ] && [ \"${BUILD}\" != \"trilinos\" ]; then \
echo \"Invalid BUILD value: ${BUILD}\" >&2; \
exit 1; \
fi; \
mpirun -n ${TASKS} /build-${BUILD}/svFSI-build/bin/svFSI ${INPUT}"]
Loading
Loading