Add regctl to docker image
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
# Init image
|
||||
FROM python:slim
|
||||
FROM python:3
|
||||
WORKDIR /app
|
||||
|
||||
# Install requirements
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
RUN wget -O /usr/bin/regctl https://github.com/regclient/regclient/releases/latest/download/regctl-linux-amd64
|
||||
RUN chmod 755 /usr/bin/regctl
|
||||
|
||||
# Import app
|
||||
COPY dockup .
|
||||
|
||||
39
dockup
39
dockup
@@ -80,22 +80,29 @@ def get_local_tags(images):
|
||||
|
||||
def get_remote_tags(images):
|
||||
for img in images:
|
||||
result = subprocess.run(
|
||||
["regctl", "tag", "ls", img.repo],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
tags = result.stdout.strip().splitlines()
|
||||
clean_tags = []
|
||||
for tag in tags:
|
||||
try:
|
||||
clean_tags.append(Version(tag))
|
||||
except InvalidVersion:
|
||||
continue
|
||||
tags = sorted(clean_tags, reverse=True)
|
||||
img.remote_tag = str(tags[0])
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["regctl", "tag", "ls", img.repo],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
check=True
|
||||
)
|
||||
tags = result.stdout.strip().splitlines()
|
||||
clean_tags = []
|
||||
for tag in tags:
|
||||
try:
|
||||
clean_tags.append(Version(tag))
|
||||
except InvalidVersion:
|
||||
continue
|
||||
if clean_tags:
|
||||
sorted_tags = sorted(clean_tags, reverse=True)
|
||||
img.remote_tag = str(sorted_tags[0])
|
||||
else:
|
||||
img.remote_tag = None
|
||||
except Exception as e:
|
||||
logging.error(f"Error checking {img.repo}: {str(e)}")
|
||||
img.remote_tag = None
|
||||
return images
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user