This repository has been archived by the owner on Oct 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_dockerimage.sh
executable file
·95 lines (83 loc) · 3 KB
/
make_dockerimage.sh
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
95
#!/bin/bash
# © Copyright 2020-2020 UCAR
# This software is licensed under the terms of the Apache Licence Version 2.0 which can be obtained at
# http://www.apache.org/licenses/LICENSE-2.0.
#
# make_dockerimage.sh - Generate the dockerfile from base.py via HPCCM
#
# Useage:
# make_dockerimage.sh <name> <tag> <hpc>
#
# <name> - name of image to build in format <compiler>-<mpi>-<type>
# where <type> is dev (development) or app (application)
# Default: gnu-openmpi-dev
#
# <tag> - optional tag for docker image
#
# <hpc> - this selects amoung possible hpc configurations
# accepted values include:
# 0 (default): No hpc options
# 1: base configuration - sufficient for, e.g., S4
# - UCX with KNEM, XPMEM
# - OFED: linux inbox
# - PMI: slurm-pmi2
# - PSM: None
# 2: with Mellanox OFED and PSM
# - UCX with KNEM, XPMEM
# - OFED: Mellanox
# - PMI: slurm-pmi2
# - PSM: Yes
#
#------------------------------------------------------------------------
function get_ans {
ans=''
while [[ $ans != y ]] && [[ $ans != n ]]; do
echo $1
read ans < /dev/stdin
if [[ $ans != y ]] && [[ $ans != n ]]; then echo "You must enter y or n"; fi
done
}
#------------------------------------------------------------------------
if [[ $# -lt 1 ]]; then
echo "usage: make_dockerimage <name> [<tag>] [<HPC>]"
exit 1
fi
CNAME=${1:-"gnu-openmpi-dev"}
TAG=${2:-"beta"}
HPC=${3:-"1"}
CompilerName=$(echo $CNAME| cut -d- -f1)
MPIName=$(echo $CNAME| cut -d- -f2)
[[ HPC == 2 ]] && CNAME=${CNAME}-mlnx
echo $CompilerName
case ${HPC} in
"0")
hpccm --recipe base-dev.py --userarg compiler=${CompilerName} \
mpi=${MPIName} \
--format docker > Dockerfile.$CNAME
;;
"1")
hpccm --recipe base-dev.py --userarg compiler=${CompilerName} \
mpi=${MPIName} \
hpc="True" \
--format docker > Dockerfile.$CNAME
;;
"2")
hpccm --recipe base-dev.py --userarg compiler=${CompilerName} \
mpi=${MPIName} \
hpc="True" \
mellanox="True" \
psm="True" \
--format docker > Dockerfile.$CNAME
;;
*)
echo "ERROR: unsupported HPC option"
exit 1
;;
esac
echo "Generated with hpccm version: " > generated.version
hpccm --version >> generated.version
docker image build --no-cache -f Dockerfile.$CNAME -t jcsda/docker_base-$CNAME:${TAG} .
get_ans "Push to Docker Hub?"
if [[ $ans == y ]] ; then
docker push jcsda/docker_base-$CNAME:${TAG}
fi