forked from NVIDIA/hpc-container-maker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
easybuild.py
49 lines (40 loc) · 1.92 KB
/
easybuild.py
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
"""EasyBuild container (https://github.com/easybuilders/easybuild)
Set the user argument 'easyconfig' to specify the EasyConfig to
build. Otherwise, it will just build a base EasyBuild container
image.
Sample workflow:
$ hpccm.py --recipe recipes/easybuild.py --userarg easyconfig=GROMACS-2019.3-fosscuda-2019b.eb > Dockerfile.gromacs.eb
$ docker build -t gromacs.eb -f Dockerfile.gromacs.eb .
$ nvidia-docker run --rm -ti gromacs.eb bash -l
container:/tmp> module load GROMACS
...
"""
# pylint: disable=invalid-name, undefined-variable, used-before-assignment
import os
Stage0 += comment(__doc__, reformat=False)
Stage0 += baseimage(image='rockylinux:8')
Stage0 += shell(commands=['yum update -y rocky-release',
'rm -rf /var/cache/yum/*'])
# Base dependencies
Stage0 += python(python3=False)
Stage0 += gnu()
Stage0 += ofed()
Stage0 += packages(epel=True, powertools=True,
yum=['bzip2', 'diffutils', 'file', 'git', 'gzip',
'libtool', 'Lmod', 'make', 'openssh-clients',
'openssl-devel', 'patch', 'rsh', 'tar', 'unzip',
'which', 'xz'])
# Setup and install EasyBuild
Stage0 += pip(packages=['easybuild'], pip='pip2')
Stage0 += shell(commands=['useradd -m easybuild',
'mkdir -p /opt/easybuild',
'chown easybuild:easybuild /opt/easybuild'])
# Module environment
Stage0 += environment(variables={'MODULEPATH': '/opt/easybuild/modules/all:/home/easybuild/.local/easybuild/modules/all:$MODULEPATH'})
easyconfig = USERARG.get('easyconfig', None)
if easyconfig:
# If the easyconfig is a file in the local build context, inject it
# into the container image
if os.path.isfile(easyconfig):
Stage0 += copy(src=easyconfig, dest='/home/easybuild')
Stage0 += shell(commands=['runuser easybuild -l -c "eb {} -r --installpath /opt/easybuild"'.format(easyconfig)])