-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
78 lines (60 loc) · 2.2 KB
/
tasks.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
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
from invoke import task
ARCHITECTURES = [
"arm32v7",
"arm64v8",
]
LIB_ARCHITECTURES = {
"arm32v7": "arm-linux-gnueabihf",
"arm64v8": "aarch64-linux-gnu"
}
DOCKER_REPOSITORY = "hannahsfamily/fluent-bit"
STABLE_VERSION = "1.2.0"
ADDITIONAL_MANIFEST_REPOS = ["fluent/fluent-bit"]
@task(iterable=["architectures"])
def build(c,
version=STABLE_VERSION,
architectures=[],
repository=DOCKER_REPOSITORY):
if len(architectures) == 0:
architectures = ARCHITECTURES.copy()
major, minor, patch = version.split(".")
tag = "{}:{}-$TARGET".format(repository, version)
cmd = [
"docker", "build", "-t", tag, "--build-arg", "\"target=$TARGET\"",
"--build-arg", "\"lib_target=$LIB_TARGET\"", "--build-arg",
"\"FLB_VERSION={}\"".format(version), "--build-arg",
"\"FLB_MAJOR={}\"".format(major), "--build-arg",
"\"FLB_MINOR={}\"".format(minor), "--build-arg",
"\"FLB_PATCH={}\"".format(patch), "."
]
for target in architectures:
env = {"TARGET": target, "LIB_TARGET": LIB_ARCHITECTURES[target]}
c.run(" ".join(cmd), env=env, pty=True)
@task(iterable=["architectures"])
def push(c,
version=STABLE_VERSION,
architectures=[],
repository=DOCKER_REPOSITORY):
if len(architectures) == 0:
architectures = ARCHITECTURES.copy()
cmd = ["docker", "push"]
for target in architectures:
c.run(" ".join([*cmd, "{}:{}-{}".format(repository, version, target)]),
pty=True)
@task(iterable=["architectures"])
def manifest(c,
version=STABLE_VERSION,
tag=None,
architectures=[],
repository=DOCKER_REPOSITORY):
if len(architectures) == 0:
architectures = ARCHITECTURES.copy()
if tag is None:
tag = version
cmd = ["docker", "manifest", "create", "{}:{}".format(repository, tag)]
cmd.extend("{}:{}-{}".format(repository, version, target)
for target in architectures)
cmd.extend("{}:{}".format(repo, tag) for repo in ADDITIONAL_MANIFEST_REPOS)
c.run(" ".join(cmd), pty=True)
c.run("docker manifest push --purge {}:{}".format(repository, tag),
pty=True)