Skip to content

Commit 20d12b3

Browse files
extend packaging support for Docker/Singularity definition files & images (WIP, initial structure) (#1)
1 parent 8176e1b commit 20d12b3

2 files changed

Lines changed: 50 additions & 3 deletions

File tree

easybuild/tools/config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,13 @@
5959
UNSET = 'unset'
6060
WARN = 'warn'
6161

62+
PKG_TOOL_DOCKER = 'docker'
6263
PKG_TOOL_FPM = 'fpm'
64+
PKG_TOOL_SINGULARITY = 'singularity'
65+
PKG_TYPE_DEF = 'def'
66+
PKG_TYPE_IMG = 'img'
6367
PKG_TYPE_RPM = 'rpm'
6468

65-
6669
DEFAULT_JOB_BACKEND = 'GC3Pie'
6770
DEFAULT_LOGFILE_FORMAT = ("easybuild", "easybuild-%(name)s-%(version)s-%(date)s.%(time)s.log")
6871
DEFAULT_MAX_FAIL_RATIO_PERMS = 0.5

easybuild/tools/package/utilities.py

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
from vsc.utils.missing import get_subclasses
4141
from vsc.utils.patterns import Singleton
4242

43-
from easybuild.tools.config import PKG_TOOL_FPM, PKG_TYPE_RPM, build_option, get_package_naming_scheme, log_path
43+
from easybuild.tools.config import PKG_TOOL_DOCKER, PKG_TOOL_FPM, PKG_TOOL_SINGULARITY
44+
from easybuild.tools.config import PKG_TYPE_DEF, PKG_TYPE_IMG, PKG_TYPE_RPM
45+
from easybuild.tools.config import build_option, get_package_naming_scheme, log_path
4446
from easybuild.tools.build_log import EasyBuildError
4547
from easybuild.tools.filetools import change_dir, which
4648
from easybuild.tools.package.package_naming_scheme.pns import PackageNamingScheme
@@ -66,14 +68,37 @@ def package(easyblock):
6668
Package installed software, according to active packaging configuration settings."""
6769
pkgtool = build_option('package_tool')
6870

69-
if pkgtool == PKG_TOOL_FPM:
71+
if pkgtool == PKG_TOOL_DOCKER:
72+
pkgdir = package_with_docker(easyblock)
73+
elif pkgtool == PKG_TOOL_FPM:
7074
pkgdir = package_with_fpm(easyblock)
75+
elif pkgtool == PKG_TOOL_SINGULARITY:
76+
pkgdir = package_with_singularity(easyblock)
7177
else:
7278
raise EasyBuildError("Unknown packaging tool specified: %s", pkgtool)
7379

7480
return pkgdir
7581

7682

83+
def package_with_docker(easyblock):
84+
"""
85+
Package software with Docker,
86+
i.e. either generate a container definition file, or build an actual Docker container image
87+
(depending on the value for --package-type, 'def' or 'img')
88+
"""
89+
workdir = tempfile.mkdtemp(prefix='eb-pkgs-')
90+
pkgtype = build_option('package_type')
91+
92+
if pkgtype == PKG_TYPE_DEF:
93+
raise NotImplementedError
94+
elif pkgtype == PKG_TYPE_IMG:
95+
raise NotImplementedError
96+
else:
97+
raise EasyBuildError("Unknown package type '%s' for Docker", pkgtype)
98+
99+
return workdir
100+
101+
77102
def package_with_fpm(easyblock):
78103
"""
79104
This function will build a package using fpm and return the directory where the packages are
@@ -153,6 +178,25 @@ def package_with_fpm(easyblock):
153178
return workdir
154179

155180

181+
def package_with_singularity(easyblock):
182+
"""
183+
Package software with Singularity,
184+
i.e. either generate a container definition file, or build an actual Singularity container image
185+
(depending on the value for --package-type, 'def' or 'img')
186+
"""
187+
workdir = tempfile.mkdtemp(prefix='eb-pkgs-')
188+
pkgtype = build_option('package_type')
189+
190+
if pkgtype == PKG_TYPE_DEF:
191+
raise NotImplementedError
192+
elif pkgtype == PKG_TYPE_IMG:
193+
raise NotImplementedError
194+
else:
195+
raise EasyBuildError("Unknown package type '%s' for Singularity", pkgtype)
196+
197+
return workdir
198+
199+
156200
def check_pkg_support():
157201
"""Check whether packaging is possible, if required dependencies are available."""
158202
pkgtool = build_option('package_tool')

0 commit comments

Comments
 (0)