Check for existing tag in remote repo before building. #764

Merged
telackey merged 14 commits from telackey/remotetag into main 2024-02-24 03:22:51 +00:00
Showing only changes of commit 3194ebf8a6 - Show all commits

View File

@ -95,7 +95,7 @@ def process_app_deployment_request(
deployment_config_file = os.path.join(deployment_dir, "config.env")
# TODO: Is there any reason not to simplify the hash input to the app_deployment_crn?
deployment_container_unique_tag = "laconic-webapp/%s:local" % hashlib.md5(deployment_dir.encode()).hexdigest()
deployment_container_shared_tag = f"laconic-webapp/{app.id}:local"
app_image_shared_tag = f"laconic-webapp/{app.id}:local"
# b. check for deployment directory (create if necessary)
if not os.path.exists(deployment_dir):
if deployment_record:
@ -112,17 +112,17 @@ def process_app_deployment_request(
# 6. build container (if needed)
if not deployment_record or deployment_record.attributes.application != app.id:
# check if the image already exists
if force_rebuild or not remote_image_exists(image_registry, deployment_container_shared_tag):
if force_rebuild or not remote_image_exists(image_registry, app_image_shared_tag):
# TODO: pull from request
extra_build_args = []
build_container_image(app, deployment_container_shared_tag, extra_build_args, log_file)
build_container_image(app, app_image_shared_tag, extra_build_args, log_file)
push_container_image(deployment_dir, log_file)
built_images = True
needs_k8s_deploy = True
# 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, deployment_container_shared_tag, deployment_container_unique_tag)
add_tags_to_image(image_registry, app_image_shared_tag, deployment_container_unique_tag)
# 8. update config (if needed)
if not deployment_record or file_hash(deployment_config_file) != deployment_record.attributes.meta.config: