-
Notifications
You must be signed in to change notification settings - Fork 879
/
Copy pathdocker_nightly.py
59 lines (51 loc) · 1.78 KB
/
docker_nightly.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
import argparse
import os
import sys
# To help discover local modules
REPO_ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../..")
sys.path.append(REPO_ROOT)
from setup import get_nightly_version
from ts_scripts.utils import try_and_handle
if __name__ == "__main__":
failed_commands = []
parser = argparse.ArgumentParser()
parser.add_argument(
"--organization",
type=str,
default="pytorch",
help="The name of the Dockerhub organization where the images will be pushed",
)
parser.add_argument(
"--dry_run",
action="store_true",
help="dry_run will print the commands that will be run without running them",
)
parser.add_argument(
"--cleanup",
action="store_true",
help="Delete all built docker images",
)
args = parser.parse_args()
dry_run = args.dry_run
organization = args.organization
project = "torchserve-kfs-nightly"
cpu_version = f"{project}:cpu-{get_nightly_version()}"
gpu_version = f"{project}:gpu-{get_nightly_version()}"
# Build Nightly images and append the date in the name
try_and_handle(f"./build_image.sh -m -n -t {organization}/{cpu_version}", dry_run)
try_and_handle(
f"./build_image.sh -g -n -t {organization}/{gpu_version}",
dry_run,
)
# Tag nightly images with latest
try_and_handle(
f"docker buildx imagetools create --tag {organization}/{project}:latest-cpu {organization}/{cpu_version}",
dry_run,
)
try_and_handle(
f"docker buildx imagetools create --tag {organization}/{project}:latest-gpu {organization}/{gpu_version}",
dry_run,
)
# Cleanup built images
if args.cleanup:
try_and_handle(f"docker system prune --all --volumes -f", dry_run)