lorawan-stack icon indicating copy to clipboard operation
lorawan-stack copied to clipboard

Clean Up Old Docker Snapshots

Open htdvisser opened this issue 5 years ago • 4 comments

Summary

We should periodically clean up old Docker snapshots

Why do we need this?

Because we don't need to keep every snapshot forever

What is already there? What do you see now?

Every merge to a minor branch (such as v3.10) triggers a snapshot build, and pushes an image to lorawan-stack-dev:<git hash>. These tags accumulate over time.

What is missing? What do you want to see?

We should periodically run a script to delete snapshot tags older than a couple of weeks.

How do you propose to implement this?

On Docker Hub:

  • List images (https://docs.docker.com/registry/spec/api/#listing-image-tags)
  • Delete images (https://docs.docker.com/registry/spec/api/#deleting-an-image)

GitHub Container Registry currently does not support deleting images through the API (https://docs.github.com/en/free-pro-team@latest/packages/managing-container-images-with-github-container-registry/deleting-a-container-image#about-package-deletion), but I assume that will be supported in the future.

htdvisser avatar Nov 30 '20 13:11 htdvisser

Just did another manual cleanup (but this time from Retool): https://thethingsindustries.retool.com/apps/Docker%20Images

Perhaps we can take that as a starting point for the cleanup tool.

htdvisser avatar Apr 01 '21 13:04 htdvisser

In the meantime this has become a bit easier to do on Docker Hub.

First, we have to install hub-tool:

go install github.com/docker/hub-tool@latest

Then we can clean up old open source development images:

hub-tool tag ls thethingsnetwork/lorawan-stack-dev --all --format json --sort updated=asc \
  | jq -r '.[] | select(.LastUpdated < "2022-05-01") | .Name' \
  | while read -r name
do
  hub-tool tag rm -f $name
done

And the same for enterprise development images (excluding AWS and RC images):

hub-tool tag ls thethingsindustries/lorawan-stack-dev --all --format json --sort updated=asc \
  | jq -r '.[] | select(.LastUpdated < "2022-05-01") | select(.Name | contains("-aws") | not) | select(.Name | contains("-rc") | not) | .Name' \
  | while read -r name
do
 hub-tool tag rm -f $name
done

htdvisser avatar Jun 29 '22 09:06 htdvisser

This may be a nice one for @happyRip to pick up, perhaps with help from @KrishnaIyer or @adriansmares.

htdvisser avatar Jul 28 '22 10:07 htdvisser

The workflow seems pretty simple. You see this as a shell or go tool?

happyRip avatar Jul 28 '22 18:07 happyRip

Moved to infrastructure;

KrishnaIyer avatar Jul 04 '23 12:07 KrishnaIyer