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
2 changed files with 8 additions and 4 deletions
Showing only changes of commit a408d24905 - Show all commits

View File

@ -32,9 +32,13 @@ def _image_needs_pushed(image: str):
def remote_image_exists(local_tag: str, remote_repo_url: str):
docker = DockerClient()
try:
result = docker.manifest.inspect(remote_tag_for_image(local_tag, remote_repo_url))
remote_tag = remote_tag_for_image(local_tag, remote_repo_url)
print(f"local tag: {local_tag} ; remote tag: {remote_tag}")
result = docker.manifest.inspect(remote_tag)
print(result)
return True if result else False
except: # noqa: E722
except Exception as e: # noqa: E722
print(e)
return False

View File

@ -26,6 +26,7 @@ import click
from stack_orchestrator import constants
from stack_orchestrator.deploy.images import remote_image_exists
from stack_orchestrator.deploy.spec import Spec
from stack_orchestrator.deploy.webapp import deploy_webapp
from stack_orchestrator.deploy.webapp.util import (LaconicRegistryClient,
build_container_image, push_container_image,
@ -109,9 +110,8 @@ 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:
print(ctx)
# check if the image already exists
if force_rebuild or not remote_image_exists(deployment_container_tag, ctx.spec[constants.image_registry_key]):
if force_rebuild or not remote_image_exists(deployment_container_tag, image_registry):
# TODO: pull from request
extra_build_args = []
build_container_image(app, deployment_container_tag, extra_build_args, log_file)