diff --git a/CHANGES.md b/CHANGES.md index 9752fe56..21e184f3 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,7 @@ New: Changes: * UWGeodynamics - 'ressources' folder is now 'resources' (but previous name is still supported). +* Modify docker building script to allow changing MPI implementation. Fixes: * Update UWGeoTutorials.rst #693. diff --git a/docs/development/docker/docker-builder.sh b/docs/development/docker/docker-builder.sh index 183506fb..609090ea 100755 --- a/docs/development/docker/docker-builder.sh +++ b/docs/development/docker/docker-builder.sh @@ -7,54 +7,81 @@ set -e # - mpi and lavavu dockers are automatically generated via github actions # - petsc and underworld2 must be created by runn the following script. -UBUNTU_VERSION=24.04 -PYTHON_VERSION=3.12 +PYTHON_VERSION=3.11 OMPI_VERSION=4.1.4 +MPICH_VERSION=3.4.3 PETSC_VERSION=3.22.2 +MPI_IMPLEMENTATION=opmi + +BASE_IMAGE="python:$PYTHON_VERSION-slim-bookworm" + +#### x86 images can be built on mac arm architecture using rosetta ARCH=$(uname -m) -echo "Will build docker image locally for architecture type: $ARCH" +echo "Will build docker image locally for architecture type: $ARCH, with mpi implementation: $MPI_IMPLEMENTATION" echo "************************************************************\n" -# Get the ubuntu image -podman pull ubuntu:$UBUNTU_VERSION + +# Get the base image +podman pull $BASE_IMAGE ## The mpi and lavavu images should be automatically made via github actions -podman build . \ - --rm --squash-all \ - -f ./docs/development/docker/mpi/Dockerfile.openmpi \ - --build-arg UBUNTU_VERSION=$UBUNTU_VERSION \ - --build-arg OMPI_VERSION=$OMPI_VERSION \ - -t underworldcode/openmpi:$OMPI_VERSION-$ARCH + +if [ "$MPI_IMPLEMENTATION" = "MPICH" ] +then + ## Default is openmpi, but can be switched to mpich + podman build . \ + --rm --squash-all \ + -f ./docs/development/docker/mpi/Dockerfile.mpich \ + --build-arg BASE_IMAGE=$BASE_IMAGE \ + --build-arg PYTHON_VERSION=$PYTHON_VERSION \ + --build-arg MPICH_VERSION=$MPICH_VERSION \ + -t underworldcode/mpich:$MPICH_VERSION-$ARCH + + MPI_IMAGE=underworldcode/mpich:$MPICH_VERSION-$ARCH + mpi_lowercase="mpich" +else + podman build . \ + --rm --squash-all \ + -f ./docs/development/docker/mpi/Dockerfile.openmpi \ + --build-arg BASE_IMAGE=$BASE_IMAGE \ + --build-arg PYTHON_VERSION=$PYTHON_VERSION \ + --build-arg OMPI_VERSION=$OMPI_VERSION \ + -t underworldcode/openmpi:$OMPI_VERSION-$ARCH + + MPI_IMAGE=underworldcode/openmpi:$OMPI_VERSION-$ARCH + mpi_lowercase="ompi" +fi podman build . \ --rm --squash-all \ -f ./docs/development/docker/lavavu/Dockerfile \ - --build-arg UBUNTU_VERSION=$UBUNTU_VERSION \ + --build-arg BASE_IMAGE=$BASE_IMAGE \ --build-arg PYTHON_VERSION=$PYTHON_VERSION \ -t underworldcode/lavavu:$ARCH podman build . \ --rm --squash-all \ -f ./docs/development/docker/petsc/Dockerfile \ - --build-arg MPI_IMAGE="underworldcode/openmpi:$OMPI_VERSION-$ARCH" \ - --build-arg UBUNTU_VERSION=$UBUNTU_VERSION \ + --build-arg BASE_IMAGE=$BASE_IMAGE \ + --build-arg MPI_IMAGE=$MPI_IMAGE \ --build-arg PYTHON_VERSION=$PYTHON_VERSION \ --build-arg PETSC_VERSION=$PETSC_VERSION \ - -t underworldcode/petsc:$PETSC_VERSION-$ARCH + -t underworldcode/petsc-$mpi_lowercase:$PETSC_VERSION-$ARCH ### don't use pull here as we want the petsc image above podman build . \ --rm --squash-all \ - --build-arg UBUNTU_VERSION=$UBUNTU_VERSION \ + --build-arg BASE_IMAGE=$BASE_IMAGE \ --build-arg PYTHON_VERSION=$PYTHON_VERSION \ - --build-arg PETSC_IMAGE="underworldcode/petsc:$PETSC_VERSION-$ARCH" \ + --build-arg PETSC_IMAGE="underworldcode/petsc-$mpi_lowercase:$PETSC_VERSION-$ARCH" \ --build-arg LAVAVU_IMAGE="underworldcode/lavavu:$ARCH" \ -f ./docs/development/docker/underworld2/Dockerfile \ - -t underworldcode/underworld2:2.16.0b-$ARCH + -t underworldcode/underworld2-$mpi_lowercase:2.16.0b-$ARCH + -#docker push underworldcode/petsc:3.19.4-$ARCH -#docker push underworldcode/underworld2:2.15.0b-$ARCH +#docker push underworldcode/petsc-$mpi_lowercase:$PETSC_VERSION-$ARCH +#docker push underworldcode/underworld2-$mpi_lowercase:2.16.0b-$ARCH #### if updates for both arm64 and x86_64 build manifest, ie # docker manifest create underworldcode/petsc:3.18.1 \ @@ -64,3 +91,20 @@ podman build . \ # docker manifest push underworldcode/petsc:3.18.1 # # in future this should be automated + + + +## How to use image on HPC with singularity/apptainer + +### save the docker image +# podman save -o underworld2-$mpi_lowercase-2.16.0b-$ARCH.tar underworldcode/underworld2-$mpi_lowercase:2.16.0b-$ARCH +### upload to hpc +# scp underworld2-$mpi_lowercase-2.16.0b-$ARCH.tar user@setonix.pawsey.org.au:/path/to/store/container +### extract using singularity/apptainer on HPC +# module load singularity... +# singularity build underworld2-mpich-2.16.0b-x86_64.sif docker-archive://underworld2-mpich-2.16.0b-x86_64.tar + + +### Some good resources for using containers on HPC: +# (1) checking mpi is using system install not container +# https://pawseysc.github.io/containers-astro-python-workshop/3.hpc/index.html \ No newline at end of file diff --git a/docs/development/docker/lavavu/Dockerfile b/docs/development/docker/lavavu/Dockerfile index c80882c6..97f45a92 100644 --- a/docs/development/docker/lavavu/Dockerfile +++ b/docs/development/docker/lavavu/Dockerfile @@ -1,11 +1,10 @@ -ARG UBUNTU_VERSION="24.04" ARG PYTHON_VERSION="3.12" +ARG BASE_IMAGE="python:$PYTHON_VERSION-slim-bookworm" -FROM ubuntu:${UBUNTU_VERSION} as base_runtime +FROM ${BASE_IMAGE} as base_runtime LABEL maintainer="https://github.com/underworldcode/" # need to repeat ARGS after every FROM -ARG UBUNTU_VERSION ARG PYTHON_VERSION ENV LANG=C.UTF-8 @@ -33,11 +32,13 @@ RUN mkdir ${VIRTUAL_ENV} \ # install runtime requirements RUN apt-get update -qq \ && DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ - python3-minimal \ - python3-venv \ - python3-pip \ - libpng16-16t64 \ - libjpeg8 \ + # python3-minimal \ + # python3-venv \ + # python3-pip \ + # libpng16-16t64 \ + libpng16-16 \ + #libjpeg8 \ + libjpeg-dev \ libtiff-dev \ libglu1-mesa-dev \ libosmesa6 \ @@ -53,15 +54,14 @@ RUN apt-get update -qq \ FROM base_runtime AS build_base -ARG UBUNTU_VERSION ARG PYTHON_VERSION # install build requirements RUN apt-get update -qq RUN DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ build-essential \ - python3-setuptools \ - libpython${PYTHON_VERSION}-dev \ + # python3-setuptools \ + # libpython${PYTHON_VERSION}-dev \ libpng-dev \ libjpeg-dev \ libtiff-dev \ @@ -76,14 +76,14 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ cmake \ libopenblas-dev \ libz-dev \ - gcc \ - python3-full + gcc + # python3-full # lavavu # create a virtualenv to put new python modules USER $NB_USER -RUN /usr/bin/python3 -m venv --system-site-packages ${VIRTUAL_ENV} +RUN python3 -m venv --system-site-packages ${VIRTUAL_ENV} RUN pip3 install -U setuptools \ && pip3 install --no-cache-dir \ "numpy<2" \ @@ -101,7 +101,7 @@ COPY --from=build_base /usr/local /usr/local # ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/x86_64-linux-gnu/ # Record Python packages, but only record system packages! # Not venv packages, which will be copied directly in. -RUN PYTHONPATH= /usr/bin/pip3 freeze >/opt/requirements.txt +RUN PYTHONPATH= pip3 freeze >/opt/requirements.txt # Record manually install apt packages. RUN apt-mark showmanual >/opt/installed.txt diff --git a/docs/development/docker/mpi/Dockerfile.mpich b/docs/development/docker/mpi/Dockerfile.mpich index fb003e1a..2589b529 100644 --- a/docs/development/docker/mpi/Dockerfile.mpich +++ b/docs/development/docker/mpi/Dockerfile.mpich @@ -14,9 +14,10 @@ ##################################################################### ARG MPICH_VERSION="3.4.3" -ARG UBUNTU_VERSION="24.04" +ARG PYTHON_VERSION="3.12" +ARG BASE_IMAGE="python:${PYTHON_VERSION}-slim-bookworm" -FROM ubuntu:${UBUNTU_VERSION} as runtime +FROM ${BASE_IMAGE} as runtime LABEL maintainer="https://github.com/underworldcode/" ################ @@ -46,7 +47,12 @@ FROM runtime as build ARG MPICH_VERSION # Build options for Dockerfile -ARG MPICH_CONFIGURE_OPTIONS="--enable-fast=all,O3 --prefix=/usr/local --with-device=ch4:ofi FFLAGS=-fallow-argument-mismatch FCFLAGS=-fallow-argument-mismatch" +# ARG MPICH_CONFIGURE_OPTIONS="--enable-fast=all,O3 --prefix=/usr/local --with-device=ch4:ofi FFLAGS=-fallow-argument-mismatch FCFLAGS=-fallow-argument-mismatch" + +### pawsey config from pawsey base image +### from https://quay.io/repository/pawsey/mpich-base/manifest/sha256:ca1cf20a4f1a8793ec794b7f927a03289f4ad449b51bc821ac98c5a269ea5e8a +ARG MPICH_CONFIGURE_OPTIONS="--enable-fast=all,O3 --enable-fortran --enable-romio --prefix=/usr/local --with-device=ch4:ofi CC=gcc CXX=g++ FC=gfortran FFLAGS=-fallow-argument-mismatch" + ARG MPICH_MAKE_OPTIONS="-j4" RUN apt-get update -qq \ diff --git a/docs/development/docker/mpi/Dockerfile.openmpi b/docs/development/docker/mpi/Dockerfile.openmpi index 4c353c7e..d872ea32 100644 --- a/docs/development/docker/mpi/Dockerfile.openmpi +++ b/docs/development/docker/mpi/Dockerfile.openmpi @@ -15,9 +15,10 @@ # https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact ARG OMPI_VERSION=4.1.4 -ARG UBUNTU_VERSION=24.04 +ARG PYTHON_VERSION="3.12" +ARG BASE_IMAGE="python:$PYTHON_VERSION-slim-bookworm" -FROM ubuntu:${UBUNTU_VERSION} as runtime +FROM ${BASE_IMAGE} as runtime LABEL maintainer="https://github.com/underworldcode/" ################ diff --git a/docs/development/docker/pawsey/mpich.dockerfile b/docs/development/docker/pawsey/mpich.dockerfile deleted file mode 100644 index 115c0893..00000000 --- a/docs/development/docker/pawsey/mpich.dockerfile +++ /dev/null @@ -1,101 +0,0 @@ -##################################################################### -# Multi stage Dockerfile structure: -# 1. runtime -# 2. build -# 3. final == runtime + min. build -# -# It begins with layers for runtime execution. -# The runtime environment (packages, permissions, ENV vars.) -# are consistent accross all layer of this Dockerfile. -# The build layer takes the runtime layer and builds the software -# stack in /usr/local. -# The final image is a composite of the runtime layer and -# minimal sections of the build layer. -##################################################################### - -ARG MPICH_VERSION="4.2.3" -ARG PYTHON_VERSION="3.11" -ARG MPI4PY_VERSION="4.0.1" - -FROM python:$PYTHON_VERSION-slim as runtime -LABEL maintainer="https://github.com/underworldcode/" - -################ -## 1. Runtime ## -################ -# Dockerfile ENV vars - for all image stages -ENV LANG=C.UTF-8 -# openmpi lib will be install at /usr/local/lib -ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH -# add user jovyan -ENV NB_USER jovyan -ENV NB_HOME /home/$NB_USER -RUN useradd -m -s /bin/bash -N $NB_USER - -#install runtime packages -RUN apt-get update -qq \ -&& DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ - ssh \ - bash \ -&& apt-get clean \ -&& rm -rf /var/lib/apt/lists/* - -################ -## 2. Build ## -################ -FROM runtime as build - -ARG MPICH_VERSION -# Build options for Dockerfile - -### from https://quay.io/repository/pawsey/mpich-base/manifest/sha256:ca1cf20a4f1a8793ec794b7f927a03289f4ad449b51bc821ac98c5a269ea5e8a -ARG MPICH_CONFIGURE_OPTIONS="--enable-fast=all,O3 --enable-fortran --enable-romio --prefix=/usr/local --with-device=ch4:ofi CC=gcc CXX=g++ FC=gfortran FFLAGS=-fallow-argument-mismatch" - -ARG MPICH_MAKE_OPTIONS="-j4" - -RUN apt-get update -qq \ -&& DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ - wget \ - gcc \ - gfortran \ - g++ \ - make \ - file \ -&& apt-get clean \ -&& rm -rf /var/lib/apt/lists/* - -# build mpi -RUN mkdir -p /tmp/src -WORKDIR /tmp/src -RUN wget http://www.mpich.org/static/downloads/${MPICH_VERSION}/mpich-${MPICH_VERSION}.tar.gz --no-check-certificate \ -&& tar -zxf mpich-${MPICH_VERSION}.tar.gz -WORKDIR /tmp/src/mpich-${MPICH_VERSION} -RUN ./configure ${MPICH_CONFIGURE_OPTIONS} \ - && make ${MPICH_MAKE_OPTIONS} \ - && make install \ - && ldconfig \ - && rm -rf /tmp/src/ - -### Add mpi4py for testing -ARG MPI4PY_VERSION -# RUN pip --no-cache-dir install --no-deps mpi4py==${MPI4PY_VERSION} -# RUN pip install mpi4py==${MPI4PY_VERSION} -RUN pip install --break-system-packages mpi4py==${MPI4PY_VERSION} -# record build packages used -RUN apt-mark showmanual > /opt/installed.txt - -################ -## 3. Final ## -################ -FROM runtime as final - -COPY --from=build /usr/local /usr/local -COPY --from=build /opt/installed.txt /opt/installed.txt - -# switch to user and workspace -WORKDIR $NB_HOME -USER $ - -### default location -CMD [ "/bin/bash" ] - diff --git a/docs/development/docker/pawsey/pawsey_docker_builder.sh b/docs/development/docker/pawsey/pawsey_docker_builder.sh deleted file mode 100644 index dcc1314b..00000000 --- a/docs/development/docker/pawsey/pawsey_docker_builder.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# Example Usage: -# - Run from underworld2 repository head -# - mpi and lavavu dockers are automatically generated via github actions -# - petsc and underworld2 must be created by runn the following script. - - -MPICH_VERSION=3.4.3 #3.4a2 #3.4.3 #4.0.1 -MPI4PY_VERSION=3.1.6 #3.1.6 #3.1.6 #4.0.1 -PYTHON_VERSION=3.11 -PETSC_VERSION=3.22.2 #3.22.2 - -ARCH=$(uname -m) -# ARCH=x86_64 ### pawsey -echo "Will build docker image locally for architecture type: $ARCH" -echo "************************************************************" -echo "" - -if [ "$ARCH" = "x86_64" ] -then - PLATFORM="linux/amd64" -else - PLATFORM="linux/arm64" -fi - - - - -echo " .. Now building mpich" -# The mpi and lavavu images should be automatically made via github actions -podman build . \ ---rm --squash-all \ --f ./docs/development/docker/pawsey/mpich.dockerfile \ ---platform $PLATFORM \ ---build-arg PYTHON_VERSION=$PYTHON_VERSION \ ---build-arg MPICH_VERSION=$MPICH_VERSION \ ---build-arg MPI4PY_VERSION=$MPI4PY_VERSION \ --t underworldcode/mpich:$MPICH_VERSION-$ARCH - -echo " .. Finished building mpich" - -#podman save -o mpich_$MPICH_VERSION-$ARCH.tar underworldcode/mpich:$MPICH_VERSION-$ARCH - -# echo " .. Now building lavavu" -# podman build . \ -# --rm --squash-all \ -# -f ./docs/development/docker/lavavu/Dockerfile \ -# --platform $PLATFORM \ -# --build-arg UBUNTU_VERSION=$UBUNTU_VERSION \ -# --build-arg PYTHON_VERSION=$PYTHON_VERSION \ -# -t underworldcode/lavavu:$ARCH - -echo " .. Now building petsc" -podman build . \ - --rm --squash-all \ - -f ./docs/development/docker/pawsey/petsc.dockerfile \ - --platform $PLATFORM \ - --build-arg MPI4PY_VERSION=$MPI4PY_VERSION \ - --build-arg MPI_IMAGE="underworldcode/mpich:$MPICH_VERSION-$ARCH" \ - --build-arg PYTHON_VERSION=$PYTHON_VERSION \ - --build-arg PETSC_VERSION=$PETSC_VERSION \ - -t underworldcode/petsc:$PETSC_VERSION-$ARCH - -echo " .. Finished building petsc" -# podman save -o petsc_$PETSC_VERSION-$ARCH.tar underworldcode/petsc:$PETSC_VERSION-$ARCH - -echo " .. Now building UW2" -### don't use pull here as we want the petsc image above -podman build . \ - --rm --squash-all \ - -f ./docs/development/docker/pawsey/underworld.dockerfile \ - --platform $PLATFORM \ - --build-arg MPI4PY_VERSION=$MPI4PY_VERSION \ - --build-arg PYTHON_VERSION=$PYTHON_VERSION \ - --build-arg PETSC_IMAGE="underworldcode/petsc:$PETSC_VERSION-$ARCH" \ - --build-arg LAVAVU_IMAGE="underworldcode/lavavu:$ARCH" \ - -t underworldcode/underworld2:2.16.0b-$ARCH - -### save to compressed file (tar), which can be converted by singularity on the HPC -podman save -o underworld2_2.16.0b-$ARCH.tar underworldcode/underworld2:2.16.0b-$ARCH - -### transfer to HPC using rsync/scp -# rsync -P -a underworld2_2.16.0b-$ARCH.tar username@setonix.pawsey.org.au:/container/directory - -### how to build from tar on HPC -# singularity build underworld2_2.16.0b-$ARCH.sif docker-archive://underworld2_2.16.0b-$ARCH.tar diff --git a/docs/development/docker/pawsey/petsc.dockerfile b/docs/development/docker/pawsey/petsc.dockerfile deleted file mode 100644 index 252335c2..00000000 --- a/docs/development/docker/pawsey/petsc.dockerfile +++ /dev/null @@ -1,167 +0,0 @@ -##################################################################### -# Multi stage Dockerfile structure: -# 1. runtime -# 2. build -# 3. final == runtime + min. build -# -# It begins with layers for runtime execution. -# The runtime environment (packages, permissions, ENV vars.) -# are consistent accross all layer of this Dockerfile. -# The build layer takes the runtime layer and builds the software -# stack in /usr/local. -# The final image is a composite of the runtime layer and -# minimal sections of the build layer. -##################################################################### - -ARG MPI_IMAGE="underworldcode/openmpi:4.1.4" -ARG PYTHON_VERSION="3.11" -ARG PETSC_VERSION="3.22.2" -ARG MPI4PY_VERSION="3.1.6" - -FROM ${MPI_IMAGE} as mpi-image - -FROM python:$PYTHON_VERSION-slim as runtime -LABEL maintainer="https://github.com/underworldcode/" - -# need to repeat ARGS after every FROM -ARG PYTHON_VERSION - -################ -## 1. Runtime ## -################ - - -#### Dockerfile ENV vars - for all image stages -ENV LANG=C.UTF-8 -# mpi lib will be install at /usr/local/lib -ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH - -# python env vars. -# prepappending on PATH means all pip install will goto the PYOPT -ENV PYVER=${PYTHON_VERSION} -ENV PYOPT=/opt/venv -ENV PATH=$PYOPT/bin:$PATH -ENV PYTHONPATH=$PYTHONPATH:$PYOPT/lib/python${PYVER}/site-packages -ENV PETSC_DIR=/usr/local -ENV PYTHONPATH=$PYTHONPATH:$PETSC_DIR/lib - -# add user jovyan -ENV NB_USER jovyan -ENV NB_HOME /home/$NB_USER -RUN useradd -m -s /bin/bash -N $NB_USER - -RUN apt-get update -qq \ -&& DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ - bash-completion \ - ssh \ - libopenblas0 \ - python3-full \ - python3-dev \ -&& apt-get clean \ -&& rm -rf /var/lib/apt/lists/* - -# build and open virtual environment -RUN python3 -m venv $PYOPT \ -&& chmod ugo+rwx $PYOPT \ -&& pip3 install -U setuptools \ - wheel - -################ -## 2. Build ## -################ - -FROM runtime as build - -ARG PYTHON_VERSION -ARG MPI4PY_VERSION -ARG PETSC_VERSION - -RUN apt-get update -qq \ -&& DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ - ca-certificates \ - wget \ - build-essential \ - gfortran \ - g++ \ - cmake \ - libopenblas-dev \ - libz-dev \ - git \ -&& apt-get clean \ -&& rm -rf /var/lib/apt/lists/* - -# copy in from mpi container -COPY --from=mpi-image /opt/installed.txt /opt/installed.txt -COPY --from=mpi-image /usr/local /usr/local -RUN apt-get update -qq \ -&& DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends $(awk '{print $1'} /opt/installed.txt) \ -&& apt-get clean \ -&& rm -rf /var/lib/apt/lists/* - -RUN pip3 install --no-cache-dir \ - "cython==3.0.10" \ - "numpy<2" - -RUN pip --no-cache-dir install --no-deps mpi4py==${MPI4PY_VERSION} - -# get petsc -RUN mkdir -p /tmp/src -WORKDIR /tmp/src -RUN wget https://web.cels.anl.gov/projects/petsc/download/release-snapshots/petsc-lite-${PETSC_VERSION}.tar.gz --no-check-certificate \ -&& tar -zxf petsc-lite-${PETSC_VERSION}.tar.gz -WORKDIR /tmp/src/petsc-${PETSC_VERSION} - -# install petsc as root -RUN PETSC_DIR=`pwd` ./configure --with-debugging=0 --prefix=/usr/local \ - --COPTFLAGS="-g -O3" --CXXOPTFLAGS="-g -O3" --FOPTFLAGS="-g -O3" \ - --with-shared-libraries \ - --with-petsc4py=1 \ - --with-zlib=1 \ - --with-shared-libraries=1 \ - --with-cxx-dialect=C++11 \ - --with-make-np=4 \ - --download-hdf5=1 \ - --download-mumps=1 \ - --download-parmetis=1 \ - --download-metis=1 \ - --download-superlu=1 \ - --download-hypre=1 \ - --download-scalapack=1 \ - --download-superlu_dist=1 \ - --download-pragmatic=1 \ - --download-ctetgen \ - --download-eigen \ - --download-superlu=1 \ - --download-triangle \ - --useThreads=0 \ -&& make PETSC_DIR=`pwd` PETSC_ARCH=arch-linux-c-opt all \ -&& make PETSC_DIR=`pwd` PETSC_ARCH=arch-linux-c-opt install \ -&& rm -rf /usr/local/share/petsc - -# install h5py with MPI enabled, does not currently work in containers on pawsey -#RUN CC=mpicc HDF5_MPI="ON" HDF5_DIR=${PETSC_DIR} pip3 install --no-cache-dir --no-build-isolation --no-binary=h5py h5py \ -#RUN HDF5_DIR=${PETSC_DIR} pip3 install --no-cache-dir --no-build-isolation --no-binary=h5py h5py \ -RUN pip install --no-cache-dir jupyterlab - -# record builder stage packages used -RUN pip3 freeze > /opt/requirements.txt \ -&& apt-mark showmanual > /opt/packages.txt - -################ -## 3. Final ## -################ - -FROM runtime as minimal - -COPY --from=build /opt /opt -COPY --from=build /usr/local /usr/local - -# add LD_LIBRARY_PATH -ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH - -# switch to not-root user and workspace -USER $NB_USER -WORKDIR $NB_HOME - -# default command is to run jupyter lab -CMD ["jupyter-lab", "--no-browser", "--ip='0.0.0.0'"] diff --git a/docs/development/docker/pawsey/underworld.dockerfile b/docs/development/docker/pawsey/underworld.dockerfile deleted file mode 100644 index 1a1ed7fb..00000000 --- a/docs/development/docker/pawsey/underworld.dockerfile +++ /dev/null @@ -1,220 +0,0 @@ -##################################################################### -# Multi stage Dockerfile structure: -# 1. runtime -# 2. build -# 3. final == runtime + min. build -# -# It begins with layers for runtime execution. -# The runtime environment (packages, permissions, ENV vars.) -# are consistent accross all layer of this Dockerfile. -# The build layer takes the runtime layer and builds the software -# stack in /usr/local. -# The final image is a composite of the runtime layer and -# minimal sections of the build layer. -##################################################################### - -# The following are passed in via --build-args -# Used for github actions on the underworld repo -# Must go before the 1st FROM see -# https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact -ARG PETSC_IMAGE="underworldcode/petsc:3.22.2" -ARG LAVAVU_IMAGE="none" -ARG PYTHON_VERSION="3.11" -ARG MPI4PY_VERSION="4.0.1" - -# 'petsc-image' will be used later on in build stage COPY command -FROM ${PETSC_IMAGE} as petsc-image -FROM ${LAVAVU_IMAGE} as lavavu-image - -ARG PYTHON_VERSION - -FROM python:$PYTHON_VERSION-slim as runtime -LABEL maintainer="https://github.com/underworldcode/" - -################ -## 1. Runtime ## -################ - -# need to repeat ARGS after every FROM -ARG PYTHON_VERSION - -#### Dockerfile ENV vars - for all image stages -ENV LANG=C.UTF-8 -# mpi lib will be install at /usr/local/lib -ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH - -# python env vars. -# prepappending on PATH means all pip install will goto the PYOPT -ENV PYVER=${PYTHON_VERSION} -ENV PYOPT=/opt/venv -ENV PATH=$PYOPT/bin:$PATH -ENV PYTHONPATH=$PYTHONPATH:$PYOPT/lib/python${PYVER}/site-packages -# taken from PETSC images -ENV PETSC_DIR=/usr/local -ENV PYTHONPATH=$PYTHONPATH:$PETSC_DIR/lib - -# add user jovyan -ENV NB_USER jovyan -ENV NB_HOME /home/$NB_USER -RUN useradd -m -s /bin/bash -N $NB_USER - -# runtime packages -RUN apt-get update -qq \ -&& DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ - ca-certificates \ - bash-completion \ - ssh \ - python3-venv \ - python3-dev \ - libopenblas0 \ - python3-full \ - libxml2 \ - vim \ - git \ - gdb \ -# libpng16-16t64 \ -# libjpeg8 \ - libtiff-dev \ - libglu1-mesa \ - libosmesa6 \ -# libavcodec60 \ -# libavformat60 \ -# libavutil58 \ -# libswscale7 \ - zlib1g \ -&& apt-get clean \ -&& rm -rf /var/lib/apt/lists/* - -# start a virtual environment install runtime modules in 'build' as some -# packages need gcc -RUN python3 -m venv $PYOPT \ -&& chmod ugo+rwx $PYOPT - -################ -## 2. Build ## -################ - -FROM runtime as build - -ARG PYTHON_VERSION -ARG MPI4PY_VERSION - - -RUN apt-get update -qq \ -&& DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ - swig \ - cmake \ - make \ - gfortran \ - python3-dev \ - pkg-config \ - libxml2-dev \ - ninja-build \ -&& apt-get clean \ -&& rm -rf /var/lib/apt/lists/* - - - -# Remove this for future versions -# setuptools=65.6.0 has a unfixed error, so forcing version -RUN pip3 install setuptools --force-reinstall --no-cache \ -&& pip3 install --no-cache-dir \ - matplotlib \ - "cython==3.0.10" \ - "scipy==1.13" \ - "numpy<2" \ - pint \ - rise \ - pytest \ - nbmake \ - gFlex \ - tabulate - -# Lets grab lavavu & requirements -# COPY --from=lavavu-image /opt /opt -# COPY --from=lavavu-image /usr/local /usr/local -# RUN apt-get update \ -# && DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends $(awk '{print $1'} /opt/installed.txt) \ -# && apt-get clean \ -# && rm -rf /var/lib/apt/lists/* -# RUN pip3 install -r /opt/requirements.txt - -# mpi, petsc, mpi4py, petsc4py, h5py -COPY --from=petsc-image /opt /opt -COPY --from=petsc-image /usr/local /usr/local - -RUN apt-get update \ -&& DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends $(awk '{print $1'} /opt/installed.txt) \ -&& apt-get clean \ -&& rm -rf /var/lib/apt/lists/* -RUN pip3 install -r /opt/requirements.txt - - - -### install h5py -ENV PETSC_DIR=/usr/local -# install h5py with MPI enabled, does not currently work in containers on pawsey -#RUN CC=mpicc HDF5_MPI="ON" HDF5_DIR=${PETSC_DIR} pip3 install --no-cache-dir --no-build-isolation --no-binary=h5py h5py \ -# RUN pip3 install --no-cache-dir --no-build-isolation --no-binary=h5py h5py -RUN pip3 install h5py - - - -WORKDIR /tmp -COPY --chown=$NB_USER:users . /tmp/underworld2 -WORKDIR /tmp/underworld2 -RUN pip3 install -vvv . -RUN pip3 install setuptools --force-reinstall --no-cache-dir \ -&& pip3 install --no-cache-dir \ - "git+https://github.com/drufat/triangle.git" \ - "badlands @ git+https://github.com/julesghub/badlands.git@julesghub/meson-build#subdirectory=badlands" \ - jupyter_contrib_nbextensions - - - -RUN pip3 freeze >/opt/requirements.txt -# Record manually install apt packages. -RUN apt-mark showmanual >/opt/installed.txt - - -################ -## 3. Final ## -################ - - -# Build the final image, a combination of the runtime and build stages -FROM runtime as final - -ARG PYTHON_VERSION - -COPY --from=build --chown=$NB_USER:users /opt /opt -COPY --from=build --chown=$NB_USER:users /usr/local /usr/local - -# must make directory before COPY into it for permissions to work (!!!) -RUN mkdir -p $NB_HOME/workspace $NB_HOME/Underworld/UWGeodynamics \ -&& chown $NB_USER:users -R $NB_HOME \ -&& jupyter-server extension enable --sys-prefix jupyter_server_proxy - -#Copy in examples, tests, etc. -COPY --chown=$NB_USER:users ./docs/examples $NB_HOME/Underworld/examples -COPY --chown=$NB_USER:users ./docs/cheatsheet $NB_HOME/Underworld/cheatsheet -COPY --chown=$NB_USER:users ./docs/user_guide $NB_HOME/Underworld/user_guide -COPY --chown=$NB_USER:users ./docs/test $NB_HOME/Underworld/test -COPY --chown=$NB_USER:users ./docs/UWGeodynamics/examples $NB_HOME/Underworld/UWGeodynamics/examples -COPY --chown=$NB_USER:users ./docs/UWGeodynamics/benchmarks $NB_HOME/Underworld/UWGeodynamics/benchmarks -COPY --chown=$NB_USER:users ./docs/UWGeodynamics/tutorials $NB_HOME/Underworld/UWGeodynamics/tutorials - -EXPOSE 8888 -WORKDIR $NB_HOME -USER $NB_USER - -### fix for error: ImportError: /opt/cray/pe/gcc-libs/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by /usr/local/lib/libpragmatic.so) ??? -# ENV LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH -### for gmsh -# ENV PYTHONPATH=${PYTHONPATH}:/usr/local/lib - -# Declare a volume space -VOLUME $NB_HOME/workspace - -CMD ["jupyter-lab", "--no-browser", "--ip='0.0.0.0'"] - diff --git a/docs/development/docker/petsc/Dockerfile b/docs/development/docker/petsc/Dockerfile index 902aa18d..b74dbda0 100644 --- a/docs/development/docker/petsc/Dockerfile +++ b/docs/development/docker/petsc/Dockerfile @@ -14,16 +14,15 @@ ##################################################################### ARG MPI_IMAGE="underworldcode/openmpi:4.1.4" -ARG UBUNTU_VERSION="24.02" ARG PYTHON_VERSION="3.12" +ARG BASE_IMAGE="python:$PYTHON_VERSION-slim-bookworm" FROM ${MPI_IMAGE} as mpi-image -FROM ubuntu:${UBUNTU_VERSION} as runtime +FROM ${BASE_IMAGE} as runtime LABEL maintainer="https://github.com/underworldcode/" # need to repeat ARGS after every FROM -ARG UBUNTU_VERSION ARG PYTHON_VERSION #### Dockerfile ENV vars - for all image stages @@ -50,8 +49,8 @@ RUN apt-get update -qq \ bash-completion \ ssh \ libopenblas0 \ - python3-full \ - python3-dev \ + # python3-full \ + # python3-dev \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* @@ -63,7 +62,6 @@ RUN python3 -m venv $PYOPT \ FROM runtime as build -ARG UBUNTU_VERSION ARG PYTHON_VERSION RUN apt-get update -qq \ @@ -127,9 +125,10 @@ RUN PETSC_DIR=`pwd` ./configure --with-debugging=0 --prefix=/usr/local \ && make PETSC_DIR=`pwd` PETSC_ARCH=arch-linux-c-opt install \ && rm -rf /usr/local/share/petsc -# install h5py with MPI enabled -RUN CC=mpicc HDF5_MPI="ON" HDF5_DIR=${PETSC_DIR} pip3 install --no-cache-dir --no-build-isolation --no-binary=h5py h5py \ -&& pip install --no-cache-dir jupyterlab +### move h5py install to UW script +# # install h5py with MPI enabled +# RUN CC=mpicc HDF5_MPI="ON" HDF5_DIR=${PETSC_DIR} pip3 install --no-cache-dir --no-build-isolation --no-binary=h5py h5py \ +# && pip install --no-cache-dir jupyterlab # record builder stage packages used RUN pip3 freeze > /opt/requirements.txt \ diff --git a/docs/development/docker/underworld2/Dockerfile b/docs/development/docker/underworld2/Dockerfile index deba8a33..0399a0d5 100644 --- a/docs/development/docker/underworld2/Dockerfile +++ b/docs/development/docker/underworld2/Dockerfile @@ -19,19 +19,18 @@ # https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact ARG PETSC_IMAGE="underworldcode/petsc:3.22.2" ARG LAVAVU_IMAGE="none" -ARG UBUNTU_VERSION="24.02" ARG PYTHON_VERSION="3.12" +ARG BASE_IMAGE="python:$PYTHON_VERSION-slim-bookworm" # 'petsc-image' will be used later on in build stage COPY command FROM ${PETSC_IMAGE} as petsc-image FROM ${LAVAVU_IMAGE} as lavavu-image -FROM ubuntu:${UBUNTU_VERSION} as runtime +FROM ${BASE_IMAGE} as runtime LABEL maintainer="https://github.com/underworldcode/" # need to repeat ARGS after every FROM -ARG UBUNTU_VERSION ARG PYTHON_VERSION #### Dockerfile ENV vars - for all image stages @@ -60,23 +59,29 @@ RUN apt-get update -qq \ ca-certificates \ bash-completion \ ssh \ - python3-venv \ - python3-dev \ + # python3-venv \ + # python3-dev \ libopenblas0 \ - python3-full \ + # python3-full \ libxml2 \ vim \ git \ gdb \ - libpng16-16t64 \ - libjpeg8 \ + # libpng16-16t64 \ + libpng16-16 \ + # libjpeg8 \ + libjpeg-dev \ libtiff-dev \ libglu1-mesa \ libosmesa6 \ - libavcodec60 \ - libavformat60 \ - libavutil58 \ - libswscale7 \ + # libavcodec60 \ + libavcodec-dev \ + # libavformat60 \ + libavformat-dev \ + # libavutil58 \ + libavutil-dev \ + # libswscale7 \ + libswscale-dev \ zlib1g \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* @@ -88,7 +93,6 @@ RUN python3 -m venv $PYOPT \ FROM runtime as build -ARG UBUNTU_VERSION ARG PYTHON_VERSION # install build packages @@ -98,7 +102,7 @@ RUN apt-get update -qq \ cmake \ make \ gfortran \ - python3-dev \ + # python3-dev \ pkg-config \ libxml2-dev \ ninja-build \ @@ -138,6 +142,10 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* RUN pip3 install -r /opt/requirements.txt +# install h5py with MPI enabled +RUN CC=mpicc HDF5_MPI="ON" HDF5_DIR=${PETSC_DIR} pip3 install --no-cache-dir --no-build-isolation --no-binary=h5py h5py \ +&& pip install --no-cache-dir jupyterlab + WORKDIR /tmp COPY --chown=$NB_USER:users . /tmp/underworld2 WORKDIR /tmp/underworld2 @@ -156,7 +164,6 @@ RUN apt-mark showmanual >/opt/installed.txt # Build the final image, a combination of the runtime and build stages FROM runtime as final -ARG UBUNTU_VERSION ARG PYTHON_VERSION COPY --from=build --chown=$NB_USER:users /opt /opt