diff --git a/bin/wtl-services-build b/bin/wtl-services-build index 00f6b58..ef839fb 100755 --- a/bin/wtl-services-build +++ b/bin/wtl-services-build @@ -1,46 +1,37 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- import os,sys sys.path.insert(0, os.path.realpath(os.path.dirname(os.path.abspath(__file__)) + "/../pythonlibs/")) from basicsetup import * -for service_name in [ - "shared-services", - "courses-backend", - "chapters-backend", - "pages-backend", - "coursessecurity-backend", - "course-midtier", - "pwa-gateway", - "frontend", - ]: +for service_name in get_services_to_manage(): 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") if subprocess.call(docker_compose_command, cwd=service_path, env=os.environ.copy()) != 0: raise Exception("{} failed".format(docker_compose_command)) diff --git a/bin/wtl-services-run b/bin/wtl-services-run index aa2a755..e423b98 100755 --- a/bin/wtl-services-run +++ b/bin/wtl-services-run @@ -1,30 +1,21 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- import os,sys sys.path.insert(0, os.path.realpath(os.path.dirname(os.path.abspath(__file__)) + "/../pythonlibs/")) from basicsetup import * -for service_name in [ - "shared-services", - "courses-backend", - "chapters-backend", - "pages-backend", - "coursessecurity-backend", - "course-midtier", - "pwa-gateway", - "frontend", - ]: +for service_name in get_services_to_manage(): if service_name in config['repositories']: service_path = WTL_DEV_KIT_REPOS_PATH + "/" + service_name print("Run '{service_name}'".format(service_name=service_name)) 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("up") docker_compose_command.append("-d") subprocess.call(docker_compose_command, cwd=service_path) diff --git a/bin/wtl-services-stop b/bin/wtl-services-stop index 61c1df1..6842044 100755 --- a/bin/wtl-services-stop +++ b/bin/wtl-services-stop @@ -1,29 +1,20 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- import os,sys sys.path.insert(0, os.path.realpath(os.path.dirname(os.path.abspath(__file__)) + "/../pythonlibs/")) from basicsetup import * -for service_name in reversed([ - "shared-services", - "courses-backend", - "chapters-backend", - "pages-backend", - "coursessecurity-backend", - "course-midtier", - "pwa-gateway", - "frontend", - ]): +for service_name in reversed(get_services_to_manage()): if service_name in config['repositories']: service_path = WTL_DEV_KIT_REPOS_PATH + "/" + service_name print("Stop '{service_name}'".format(service_name=service_name)) 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("down") subprocess.call(docker_compose_command, cwd=service_path) diff --git a/config/repositories.example.yml b/config/repositories.example.yml index 3bd9070..cee657a 100644 --- a/config/repositories.example.yml +++ b/config/repositories.example.yml @@ -1,16 +1,18 @@ chapters-backend: git: kde:wikitolearn-chapters-backend.git course-midtier: git: kde:wikitolearn-course-midtier.git courses-backend: git: kde:wikitolearn-courses-backend.git coursessecurity-backend: git: kde:scratch/atundo/wikitolearn-coursessecurity-backend.git pages-backend: git: kde:wikitolearn-pages-backend.git pwa-gateway: git: kde:wikitolearn-pwa-gateway.git shared-services: git: kde:wikitolearn-shared-services.git frontend: git: kde:wikitolearn-frontend.git +pdf-backend: + git: kde:scratch/atundo/wikitolearn-pdf-backend.git diff --git a/pythonlibs/basicsetup.py b/pythonlibs/basicsetup.py index ae8e7e0..ef63220 100644 --- a/pythonlibs/basicsetup.py +++ b/pythonlibs/basicsetup.py @@ -1,41 +1,56 @@ from pprint import pprint import os import argcomplete, argparse import yaml import subprocess import requests import uuid import time 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") WTL_DEV_KIT_TMP_PATH = WTL_DEV_KIT_PATH + "/tmp/" 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) 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['COURSESSECURITY_BACKEND_URI'] = 'http://{host_ip}:10003'.format(host_ip=config['config']['host_ip']) +os.environ['PDF_BACKEND_BACKEND_URI'] = 'http://{host_ip}:10004'.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['MONGO_HOST'] = 'mongodb://{host_ip}:27017'.format(host_ip=config['config']['host_ip']) os.environ['PUBLIC_KEYCLOAK_URI'] = 'http://localhost:9080' os.environ['PUBLIC_PWA_GATEWAY_URI'] = 'http://localhost:12000' parser = argparse.ArgumentParser() argcomplete.autocomplete(parser) args = parser.parse_args() + +def get_services_to_manage(): + return [ + "shared-services", + "courses-backend", + "chapters-backend", + "pages-backend", + "coursessecurity-backend", + "pdf-backend", + "course-midtier", + "pwa-gateway", + "frontend", + ]