Skip to content

Commit

Permalink
Fix update checks
Browse files Browse the repository at this point in the history
Container started by docker compose does not have image checksum,
inspect image directly. Should work most of the time unless user
manually pull the up-to-date image without updating the deployment
  • Loading branch information
ranlu committed Jun 15, 2024
1 parent 385e6fa commit 623e393
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pipeline/init_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@
def get_image_info():
client = docker.APIClient(base_url='unix://var/run/docker.sock')
container_id = socket.gethostname()
info = client.inspect_container(container=container_id)
return info['Config']['Image'].split("@")
container_info = client.inspect_container(container=container_id)
image_info = container_info['Image'].split("@")
if len(image_info) == 2:
return image_info
elif len(image_info) == 1:
image_data = client.inspect_image(image=image_info[0])
image_sha256 = image_data['RepoDigests'][0].split("@")[1]
if len(image_info) == 2:
return image_info[0], image_sha256
return None


def parse_metadata():
Expand Down Expand Up @@ -98,7 +106,7 @@ def parse_metadata():

image_info = get_image_info()

if len(image_info) == 2:
if image_info and len(image_info) == 2:
Variable.set("image_info",
{
"name": image_info[0],
Expand Down

0 comments on commit 623e393

Please sign in to comment.