Skip to content

Commit

Permalink
Merge pull request #188 from wiedehopf/beta
Browse files Browse the repository at this point in the history
running as app: carefully prune old images
  • Loading branch information
dirkhh authored May 3, 2024
2 parents cf0c4a3 + 1e0e233 commit 9a011d5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
1 change: 1 addition & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Changes since v2.0.0 include:
- app mode: carefully prune docker images (only prune images that are used by adsb.im)
- add option to set default tar1090 query arguments to the expert page
- minor updates to the image name, DietPi WiFi config issues, and unnecessary work being done (the latter to reduce load that causes some of the remaining RPi3 MLAT issues)
- more UI reshuffling: create system mgmt page and move things that should be under system to that page from the Expert page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,36 @@ echo "$(date -Iseconds): pulling new container images and restarting docker" >>
bash ./docker-pull.sh
bash /opt/adsb/docker-compose-start

# finally remove the images and files we no longer use - but only if this is the image we are running
# this would be rude to do on a system where we are one of many apps potentially using docker.
if [ -f os.adsb.feeder.image ]; then
docker system prune -f
# https://docs.docker.com/config/pruning/ says: A dangling image is one that isn't tagged, and isn't referenced by any container.
# pretty much all old images we have are tagged so they wouldn't be removed without -a
# but -a also removes current images of for example deactived feed containers
# thus we manually create a list of images that are neither running nor in docker.image.versions
# alert: the following code relies on non quoted bash expansion
# finally remove the images and files we no longer use

# https://docs.docker.com/config/pruning/ says: A dangling image is one that isn't tagged, and isn't referenced by any container.
# pretty much all old images we have are tagged so they wouldn't be removed without -a
# but -a also removes current images of for example deactived feed containers
# thus we manually create a list of images that are neither running nor in docker.image.versions
# alert: the following code relies on non quoted bash expansion
PRUNE_LIST=$( \
docker images -a --format "{{.Repository}}:{{.Tag}}" \
| grep -F -v \
$(docker ps -a --format '{{.Image}}' | while read line; do echo -n " -e $line"; done) \
$(cut -d= -f2 /opt/adsb/docker.image.versions | while read line; do echo -n " -e $line"; done) \
)
if ! [ -f os.adsb.feeder.image ]; then
# if running as an app, restrict pruned images to images used by adsb.im
PRUNE_LIST=$( \
docker images -a --format "{{.Repository}}:{{.Tag}}" \
| grep -v \
$(docker ps -a --format '{{.Image}}' | while read line; do echo -n " -e $line"; done) \
$(cut -d= -f2 /opt/adsb/docker.image.versions | while read line; do echo -n " -e $line"; done) \
grep -F -e dozzle -e alpine \
$(cut -d= -f2 /opt/adsb/docker.image.versions | cut -d: -f1 | while read line; do echo -n " -e $line"; done) \
<<< "$PRUNE_LIST" \
)
# then all images on this prune list are deleted
echo "PRUNING:"
echo "$PRUNE_LIST"
docker rmi $PRUNE_LIST # unquoted expansion required
echo "PRUNING DONE"
fi
# then all images on this prune list are deleted
echo "PRUNING:"
echo "$PRUNE_LIST"
exit
docker rmi $PRUNE_LIST # unquoted expansion required
echo "PRUNING DONE"
sed -i "s/CONTAINER_VERSION=.*/CONTAINER_VERSION=$TIME/" /opt/adsb/config/.env
echo "$(date -Iseconds): done" >> /opt/adsb/adsb-setup.log

0 comments on commit 9a011d5

Please sign in to comment.