forked from underworldcode/underworld2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.mpich
94 lines (80 loc) · 2.89 KB
/
Dockerfile.mpich
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#####################################################################
# 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="3.4.3"
ARG PYTHON_VERSION="3.12"
ARG BASE_IMAGE="python:${PYTHON_VERSION}-slim-bookworm"
FROM ${BASE_IMAGE} 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
# 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 \
&& 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/
# 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 $NB_USER