This repository has been archived by the owner on Aug 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
54 lines (44 loc) · 1.72 KB
/
build.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
import os
import argparse
# Init args
parser = argparse.ArgumentParser(description="This script builds a Docker image of Tags Drive")
parser.add_argument("--name",
type=str,
default="tags-drive",
help="name of a Docker image (default is 'tags-drive')")
parser.add_argument("--tag",
type=str,
default="latest",
help="tag of a Docker image (default is 'lastest')")
parser.add_argument("--backend-tag",
type=str,
default="master",
help="name of Git branch or tag of the repo with backend part of Tags Drive")
parser.add_argument("--frontend-tag",
type=str,
default="master",
help="name of Git branch or tag of the repo with frontend part of Tags Drive")
parser.add_argument("--no-cache",
default=False,
action="store_true",
help="use --no-cache for 'docker build' command")
# Parse args
args = parser.parse_args()
name = args.name
tag = args.tag
backendTag = args.backend_tag
frontendTag = args.frontend_tag
noCache = args.no_cache
# Display passed args
print(f"Name: {name}\nTag: {tag}\nBackend tag: {backendTag}\nFrontend tag: {frontendTag}\nUse '--no-cache': {noCache}")
if name == "" or tag == "" or backendTag == "" or frontendTag == "":
print("[ERR] name and tags must be provided")
exit(1)
# Build command
command = f"docker build -t {name}:{tag} "
if noCache:
command += "--no-cache "
command += (f"--build-arg BACKEND_TAG={backendTag} " +
f"--build-arg FRONTEND_TAG={frontendTag} " +
".")
os.system(command)