diff --git a/bin/wtl-services-build b/bin/wtl-services-build index 8808e43..6d31dd7 100755 --- a/bin/wtl-services-build +++ b/bin/wtl-services-build @@ -1,77 +1,78 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- import os import argcomplete, argparse import yaml import subprocess from pprint import pprint WTL_DEV_KIT_PATH = os.environ.get("WTL_DEV_KIT_PATH") WTL_DEV_KIT_REPOS_PATH = os.environ.get("WTL_DEV_KIT_REPOS_PATH") WTL_DEV_KIT_BIN_PATH = os.environ.get("WTL_DEV_KIT_BIN_PATH") config = {} with open(WTL_DEV_KIT_PATH + "/config/config.yml") as fh: config['config'] = yaml.load(fh) if os.path.isfile(WTL_DEV_KIT_PATH + "/config/repositories.yml"): with open(WTL_DEV_KIT_PATH + "/config/repositories.yml") as fh: config['repositories'] = yaml.load(fh) else: with open(WTL_DEV_KIT_PATH + "/config/repositories.example.yml") as fh: config['repositories'] = yaml.load(fh) parser = argparse.ArgumentParser() argcomplete.autocomplete(parser) args = parser.parse_args() os.environ['KEYCLOAK_URI'] = 'http://{host_ip}:9080'.format(host_ip=config['config']['host_ip']) os.environ['COURSES_BACKEND_URI'] = 'http://{host_ip}:10000'.format(host_ip=config['config']['host_ip']) os.environ['CHAPTERS_BACKEND_URI'] = 'http://{host_ip}:10001'.format(host_ip=config['config']['host_ip']) os.environ['PAGES_BACKEND_URI'] = 'http://{host_ip}:10002'.format(host_ip=config['config']['host_ip']) os.environ['COURSE_MIDTIER_URI'] = 'http://{host_ip}:11000'.format(host_ip=config['config']['host_ip']) os.environ['PWA_GATEWAY_URI'] = 'http://{host_ip}:12000'.format(host_ip=config['config']['host_ip']) os.environ['PUBLIC_KEYCLOAK_URI'] = 'http://{host_ip}:9080'.format(host_ip=config['config']['host_ip']) os.environ['PUBLIC_PWA_GATEWAY_URI'] = 'http://{host_ip}:12000'.format(host_ip=config['config']['host_ip']) for service_name in [ "shared-services", "courses-backend", "chapters-backend", "pages-backend", "coursessecurity-backend", "course-midtier", "pwa-gateway", "frontend", ]: if service_name in config['repositories']: service_path = WTL_DEV_KIT_REPOS_PATH + "/" + service_name print("Build '{service_name}'".format(service_name=service_name)) if not os.path.isdir(service_path): clone_cmd = [ "git", "clone", config['repositories'][service_name]['git'], service_path ] if 'git_branch' in config['repositories'][service_name]: clone_cmd.append("-b") clone_cmd.append(config['repositories'][service_name]['git_branch']) subprocess.call(clone_cmd) subprocess.call([ "git", "pull", ], cwd=service_path) docker_compose_command = [ "docker-compose", "-f","docker-compose.yml", ] if os.path.isfile(service_path + "/" + "docker-compose-dev-deps.yml"): docker_compose_command.append("-f") docker_compose_command.append("docker-compose-dev-deps.yml") docker_compose_command.append("build") - subprocess.call(docker_compose_command, cwd=service_path, env=os.environ.copy()) + if subprocess.call(docker_compose_command, cwd=service_path, env=os.environ.copy()) != 0: + raise Exception("{} failed".format(docker_compose_command))