Skip to content

Commit f1d7f0f

Browse files
authored
Separate PETSc install into single image (#75)
1 parent 515046a commit f1d7f0f

3 files changed

Lines changed: 29 additions & 26 deletions

File tree

.github/workflows/pytest-petsc.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,15 @@ jobs:
5454

5555
- name: Build docker image
5656
run: |
57-
docker build . --file docker/Dockerfile.devito --tag devito_img --build-arg base=zoeleibowitz/bases:cpu-${{ matrix.arch }} --build-arg petscinstall=petsc
58-
docker tag devito_img ${{ secrets.DOCKER_USERNAME }}/devito_img:latest
57+
docker build -f docker/Dockerfile.devito --build-arg base=zoeleibowitz/petsc_image:latest --tag zoeleibowitz/petsc_devito_image:latest .
5958
6059
- name: Push Docker image to DockerHub
6160
run: |
62-
docker push ${{ secrets.DOCKER_USERNAME }}/devito_img:latest
61+
docker push ${{ secrets.DOCKER_USERNAME }}/petsc_devito_image:latest
6362
6463
- name: Set run prefix
6564
run: |
66-
echo "RUN_CMD=docker run --rm -t -e CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} --name testrun devito_img" >> $GITHUB_ENV
65+
echo "RUN_CMD=docker run --rm -t -e CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} --name testrun zoeleibowitz/petsc_devito_image:latest" >> $GITHUB_ENV
6766
id: set-run
6867

6968
- name: Set tests

docker/Dockerfile.devito

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,8 @@
44

55
# Base image with compilers
66
ARG base=devitocodes/bases:cpu-gcc
7-
ARG petscinstall=""
87

9-
FROM $base AS copybase
10-
11-
################## Install PETSc ############################################
12-
FROM copybase AS petsccopybase
13-
14-
RUN apt-get update && apt-get install -y git && \
15-
python3 -m venv /venv && \
16-
/venv/bin/pip install --no-cache-dir --upgrade pip && \
17-
/venv/bin/pip install --no-cache-dir --no-binary numpy numpy && \
18-
mkdir -p /opt/petsc && \
19-
cd /opt/petsc && \
20-
git clone -b release https://gitlab.com/petsc/petsc.git petsc && \
21-
cd petsc && \
22-
./configure --with-fortran-bindings=0 --with-mpi-dir=/opt/openmpi --with-openblas-include=$(pkg-config --variable=includedir openblas) --with-openblas-lib=$(pkg-config --variable=libdir openblas)/libopenblas.so PETSC_ARCH=devito_build && \
23-
make all
24-
25-
ARG petscinstall=""
26-
FROM ${petscinstall}copybase AS builder
8+
FROM $base AS builder
279

2810
# User/Group Ids
2911
ARG USER_ID=1000
@@ -87,9 +69,6 @@ ARG GROUP_ID=1000
8769
ENV HOME=/app
8870
ENV APP_HOME=/app
8971

90-
ENV PETSC_ARCH="devito_build"
91-
ENV PETSC_DIR="/opt/petsc/petsc"
92-
9372
# Create the home directory for the new app user.
9473
# Create an app user so our program doesn't run as root.
9574
# Chown all the files to the app user.

docker/Dockerfile.petsc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
##############################################################
2+
# Dockerfile.petsc: Installs PETSc
3+
##############################################################
4+
5+
# Base image with compilers
6+
# TODO: to be updated, but made some additions to Dockerfile.cpu so need to
7+
# use the one from my dockerhub
8+
ARG base=zoeleibowitz/bases:cpu-gcc
9+
10+
RUN apt-get update && apt-get install -y git && \
11+
python3 -m venv /venv && \
12+
/venv/bin/pip install --no-cache-dir --upgrade pip && \
13+
/venv/bin/pip install --no-cache-dir --no-binary numpy numpy && \
14+
mkdir -p /opt/petsc && \
15+
cd /opt/petsc && \
16+
git clone -b release https://gitlab.com/petsc/petsc.git petsc && \
17+
cd petsc && \
18+
./configure --with-fortran-bindings=0 --with-mpi-dir=/opt/openmpi \
19+
--with-openblas-include=$(pkg-config --variable=includedir openblas) \
20+
--with-openblas-lib=$(pkg-config --variable=libdir openblas)/libopenblas.so \
21+
PETSC_ARCH=devito_build && \
22+
make all
23+
24+
ENV PETSC_DIR="/opt/petsc/petsc"
25+
ENV PETSC_ARCH="devito_build"

0 commit comments

Comments
 (0)