This commit is contained in:
Thomas E Lackey 2024-02-23 18:01:44 -06:00
parent 2a34f43678
commit a408d24905
2 changed files with 8 additions and 4 deletions

View File

@ -32,9 +32,13 @@ def _image_needs_pushed(image: str):
def remote_image_exists(local_tag: str, remote_repo_url: str): def remote_image_exists(local_tag: str, remote_repo_url: str):
docker = DockerClient() docker = DockerClient()
try: 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 return True if result else False
except: # noqa: E722 except Exception as e: # noqa: E722
print(e)
return False return False

View File

@ -26,6 +26,7 @@ import click
from stack_orchestrator import constants from stack_orchestrator import constants
from stack_orchestrator.deploy.images import remote_image_exists 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 import deploy_webapp
from stack_orchestrator.deploy.webapp.util import (LaconicRegistryClient, from stack_orchestrator.deploy.webapp.util import (LaconicRegistryClient,
build_container_image, push_container_image, build_container_image, push_container_image,
@ -109,9 +110,8 @@ def process_app_deployment_request(
needs_k8s_deploy = False needs_k8s_deploy = False
# 6. build container (if needed) # 6. build container (if needed)
if not deployment_record or deployment_record.attributes.application != app.id: if not deployment_record or deployment_record.attributes.application != app.id:
print(ctx)
# check if the image already exists # 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 # TODO: pull from request
extra_build_args = [] extra_build_args = []
build_container_image(app, deployment_container_tag, extra_build_args, log_file) build_container_image(app, deployment_container_tag, extra_build_args, log_file)