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 updates #711

Merged
merged 3 commits into from
Feb 3, 2025
Merged
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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
84 changes: 64 additions & 20 deletions docs/development/docker/docker-builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
30 changes: 15 additions & 15 deletions docs/development/docker/lavavu/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 \
Expand All @@ -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 \
Expand All @@ -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" \
Expand All @@ -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

Expand Down
12 changes: 9 additions & 3 deletions docs/development/docker/mpi/Dockerfile.mpich
Original file line number Diff line number Diff line change
Expand Up @@ -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/"

################
Expand Down Expand Up @@ -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 \
Expand Down
5 changes: 3 additions & 2 deletions docs/development/docker/mpi/Dockerfile.openmpi
Original file line number Diff line number Diff line change
Expand Up @@ -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/"

################
Expand Down
101 changes: 0 additions & 101 deletions docs/development/docker/pawsey/mpich.dockerfile

This file was deleted.

Loading