forked from NVIDIA/hpc-container-maker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspack.py
45 lines (37 loc) · 1.67 KB
/
spack.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
"""Spack container (https://github.com/spack/spack)
Set the user argument 'package' to specify the Spack package to
install. Otherwise, it will just build a base Spack container
image.
Sample workflow:
$ hpccm.py --recipe recipes/spack.py --userarg package="[email protected] +cuda" > Dockerfile.gromacs.spack
$ docker build -t gromacs.spack -f Dockerfile.gromacs.spack .
$ nvidia-docker run --rm -ti gromacs.spack bash -l
container:/> spack load gromacs
"""
# pylint: disable=invalid-name, undefined-variable, used-before-assignment
import os
from hpccm.templates.git import git
spack_branch = 'master'
Stage0 += comment(__doc__, reformat=False)
Stage0 += baseimage(image='ubuntu:16.04')
# Base dependencies
Stage0 += python()
Stage0 += gnu()
# Additional dependencies
ospackages = ['autoconf', 'build-essential', 'bzip2', 'ca-certificates',
'coreutils', 'curl', 'environment-modules', 'git', 'gzip',
'libssl-dev', 'make', 'openssh-client', 'patch', 'pkg-config',
'tcl', 'tar', 'unzip', 'zlib1g']
Stage0 += apt_get(ospackages=ospackages)
# Setup and install Spack
Stage0 += shell(commands=[
git().clone_step(repository='https://github.com/spack/spack',
branch=spack_branch, path='/opt'),
'/opt/spack/bin/spack bootstrap',
'ln -s /opt/spack/share/spack/setup-env.sh /etc/profile.d/spack.sh',
'ln -s /opt/spack/share/spack/spack-completion.bash /etc/profile.d'])
Stage0 += environment(variables={'PATH': '/opt/spack/bin:$PATH'})
spack_package = USERARG.get('package', None)
if spack_package:
Stage0 += shell(commands=['spack install {}'.format(spack_package),
'spack clean --all'])