-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathdocker.py
36 lines (26 loc) · 868 Bytes
/
docker.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
"""Build and push images"""
from nboost import __version__, PKG_PATH
from nboost.logger import set_logger
from nboost.maps import IMAGE_MAP
import subprocess
REGISTRY = 'koursaros/nboost'
VERSION_TAG = '%s:%s-{image}' % (REGISTRY, __version__.__doc__)
LATEST_TAG = '%s:latest-{image}' % REGISTRY
BUILD = 'docker build -t %s -t %s {path}' % (VERSION_TAG, LATEST_TAG)
PUSH = 'docker push %s' % REGISTRY
def execute(command: str):
"""Execute command in subprocess"""
logger = set_logger('RELEASE')
logger.info(command)
subprocess.call(command, shell=True)
def build():
"""Build dockerfiles"""
for image, path in IMAGE_MAP.items():
path = PKG_PATH.joinpath(path).absolute()
execute(BUILD.format(image=image, path=path))
def push():
"""Push images"""
execute(PUSH)
if __name__ == "__main__":
build()
push()