Skip to content

Commit

Permalink
Remove old images when updating
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulh committed Jan 11, 2024
1 parent 95c0d22 commit 07318d4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions scripts/pull_calaos_image
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,22 @@ fi
# Read the URL from the source file
source "$url"

echo " > Pulling image $IMAGE_SRC"
podman pull "$IMAGE_SRC"
image_base=$(echo "$IMAGE_SRC" | cut -d: -f 1)
image_tag=$(echo "$IMAGE_SRC" | cut -d: -f 2)

echo " > Removing old container image"
for i in $(podman images | grep "$image_base" | awk '{print $3}')
do
podman rmi "$i"
done

# Clean old remaining container images
echo " > Cleaning old images"
podman image prune -f

echo " > Pulling new image $IMAGE_SRC"
podman pull "$IMAGE_SRC"

# Remove old tags if they exist
if podman image exists "localhost/var/lib/cache/containers/$pkgname"; then
podman rmi "localhost/var/lib/cache/containers/$pkgname"
Expand Down

0 comments on commit 07318d4

Please sign in to comment.