Check for existing tag in remote repo before building. #764
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user