Created
January 31, 2019 14:56
-
-
Save Clement-TS/6fad07d014fb759e436d7c6b82971cf5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# author: Clément Désiles aka Jokester | |
# date: 2019-09-30 | |
# | |
# requires: lstags, jq and yq | |
# install hints: | |
# $ sudo apt install -qqy jq && pip install yq | |
# $ wget -O /tmp/lstags.tar.gz https://github.com/ivanilves/lstags/releases/download/v1.1.2/lstags-linux-v1.1.2.tar.gz | |
# $ tar -xvf /tmp/lstags.tar.gz && rm -f /tmp/lstags.tar.gz | |
# $ mv lstags $HOME/.local/bin | |
# | |
# usage: check-missing-images.sh /path/to/docker-compose.yml | |
set -e | |
error () { echo -e -n "\033[1;31m$1\033[0m\n"; } | |
DOCKER_COMPOSE=$1 | |
if [ ! -f $DOCKER_COMPOSE ]; then error "docker-compose file not found!"; fi | |
# env file to eval eventual vars in images | |
WD=$(dirname $DOCKER_COMPOSE) | |
if [ -f "$WD/env" ]; then . $WD/env; fi | |
if [ -f "$WD/.env" ]; then . $WD/.env; fi | |
IMAGES=$(echo $(eval echo $(yq -r '.services[].image' "$DOCKER_COMPOSE" | tr '\n' ' '))) | |
NOT_FOUND_IMAGES=$(lstags $IMAGES 2>/dev/null | grep ASSUMED | awk '{print $NF}') | |
if [ -z "$NOT_FOUND_IMAGES" ]; then | |
echo "This docker-compose contains all images" | |
exit 0 | |
else | |
error "These images could no be found:" | |
echo "$NOT_FOUND_IMAGES" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment