diff --git a/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py b/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py index ad439812..02731992 100644 --- a/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py +++ b/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py @@ -1,5 +1,4 @@ # Copyright ©2023 Vulcanize - # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or @@ -13,6 +12,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +import hashlib import json import os import shlex @@ -51,7 +51,6 @@ def process_app_deployment_request( raise Exception("Only unqualified hostnames allowed at this time.") fqdn = f"{requested_name}.{dns_suffix}" - container_tag = "%s:local" % app.attributes.name.replace("@", "") # 3. check ownership of existing dnsrecord vs this request # TODO: Support foreign DNS @@ -94,13 +93,14 @@ def process_app_deployment_request( deployment_record = laconic.get_record(app_deployment_crn) deployment_dir = os.path.join(deployment_parent_dir, fqdn) deployment_config_file = os.path.join(deployment_dir, "config.env") + deployment_container_tag = "laconic-webapp/%s:local" % hashlib.md5(deployment_dir.encode()).hexdigest() # b. check for deployment directory (create if necessary) if not os.path.exists(deployment_dir): if deployment_record: - raise ("Deployment record %s exists, but not deployment dir %s. Please remove name." % - (app_deployment_crn, deployment_dir)) + raise Exception("Deployment record %s exists, but not deployment dir %s. Please remove name." % + (app_deployment_crn, deployment_dir)) print("deploy_webapp", deployment_dir) - deploy_webapp.create_deployment(ctx, deployment_dir, container_tag, + deploy_webapp.create_deployment(ctx, deployment_dir, deployment_container_tag, f"https://{fqdn}", kube_config, image_registry, env_filename) elif env_filename: shutil.copyfile(env_filename, deployment_config_file) @@ -108,7 +108,7 @@ def process_app_deployment_request( needs_k8s_deploy = False # 6. build container (if needed) if not deployment_record or deployment_record.attributes.application != app.id: - build_container_image(app, container_tag) + build_container_image(app, deployment_container_tag) push_container_image(deployment_dir) needs_k8s_deploy = True @@ -262,7 +262,7 @@ def command(ctx, kube_config, laconic_config, image_registry, deployment_parent_ record_namespace_deployments, record_namespace_dns, dns_suffix, - deployment_parent_dir, + os.path.abspath(deployment_parent_dir), kube_config, image_registry )