From a54e9c43a0d8792a07f87b77620c768ad81d279b Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Fri, 23 Feb 2024 19:52:57 -0600 Subject: [PATCH] push-images will only use the compose-defined tag --- .../webapp/deploy_webapp_from_registry.py | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py b/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py index de920273..babfa547 100644 --- a/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py +++ b/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py @@ -108,27 +108,28 @@ def process_app_deployment_request( shutil.copyfile(env_filename, deployment_config_file) needs_k8s_deploy = False - built_images = False # 6. build container (if needed) if not deployment_record or deployment_record.attributes.application != app.id: + needs_k8s_deploy = True + # check if the image already exists - if force_rebuild or not remote_image_exists(image_registry, app_image_shared_tag): + shared_tag_exists = remote_image_exists(image_registry, app_image_shared_tag) + if shared_tag_exists and not force_rebuild: + # simply add our unique tag to the existing image and we are done + add_tags_to_image(image_registry, app_image_shared_tag, deployment_container_unique_tag) + else: # TODO: pull from request extra_build_args = [] - build_container_image(app, app_image_shared_tag, extra_build_args, log_file) + build_container_image(app, deployment_container_unique_tag, extra_build_args, log_file) push_container_image(deployment_dir, log_file) - built_images = True - needs_k8s_deploy = True + # The build/push commands above will use the unique deployment tag, so now we need to add the shared tag. + add_tags_to_image(image_registry, deployment_container_unique_tag, app_image_shared_tag) - # 7. Add tags (as needed) - if built_images or not remote_image_exists(image_registry, deployment_container_unique_tag): - add_tags_to_image(image_registry, app_image_shared_tag, deployment_container_unique_tag) - - # 8. update config (if needed) + # 7. update config (if needed) if not deployment_record or file_hash(deployment_config_file) != deployment_record.attributes.meta.config: needs_k8s_deploy = True - # 9. update k8s deployment + # 8. update k8s deployment if needs_k8s_deploy: print("Deploying to k8s") deploy_to_k8s(