-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdocker.py
More file actions
72 lines (61 loc) · 1.92 KB
/
docker.py
File metadata and controls
72 lines (61 loc) · 1.92 KB
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
from faasmtools.docker import (
build_container,
push_container,
CR_NAME,
)
from faasmtools.env import (
LLVM_VERSION,
PROJ_ROOT,
get_version,
)
from invoke import task
from os.path import join
LLVM_IMAGE_NAME = "{}/llvm".format(CR_NAME)
LLVM_DOCKERFILE = join(PROJ_ROOT, "docker", "llvm.dockerfile")
SYSROOT_IMAGE_NAME = "{}/cpp-sysroot".format(CR_NAME)
SYSROOT_DOCKERFILE = join(PROJ_ROOT, "docker", "cpp-sysroot.dockerfile")
def get_sysroot_tag():
version = get_version()
return "{}:{}".format(SYSROOT_IMAGE_NAME, version)
def get_llvm_tag():
version = get_version()
return "{}:{}".format(LLVM_IMAGE_NAME, version)
@task(iterable=["c"])
def build(ctx, c, nocache=False, push=False):
"""
Build container images. Possible images are: `llvm`, and `cpp-sysroot`.
"""
build_args = {"SYSROOT_VERSION": get_version()}
for ctr in c:
if ctr == "llvm":
build_args["LLVM_VERSION_MAJOR"] = LLVM_VERSION.split(".")[0]
dockerfile = LLVM_DOCKERFILE
tag = get_llvm_tag()
elif ctr == "cpp-sysroot":
dockerfile = SYSROOT_DOCKERFILE
tag = get_sysroot_tag()
else:
print("Unrecognised container image: {}".format(ctr))
raise RuntimeError("Unrecognised container image")
build_container(
tag,
dockerfile,
PROJ_ROOT,
nocache=nocache,
push=push,
build_args=build_args,
)
@task(iterable=["c"])
def push(ctx, c):
"""
Push container images. Possible images are: `llvm`, and `cpp-sysroot`.
"""
for ctr in c:
if ctr == "llvm":
tag = get_llvm_tag()
elif ctr == "cpp-sysroot":
tag = get_sysroot_tag()
else:
print("Unrecognised container image: {}".format(ctr))
raise RuntimeError("Unrecognised container image")
push_container(tag)