-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.sh
49 lines (40 loc) · 1.44 KB
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
# List of images to ignore
IGNORE_IMAGES=("postgres" "mongodb")
# Function to check if an image should be ignored
should_ignore() {
local image=$1
for ignore in "${IGNORE_IMAGES[@]}"; do
if [[ $image == *$ignore* ]]; then
return 0 # true, should ignore
fi
done
return 1 # false, should not ignore
}
services=$(docker-compose config --services)
for service in $services; do
image=$(docker-compose config | grep "$service:" -A 2 | grep 'image:' | awk '{print $2}')
if [ -n "$image" ]; then
# Check if the image should be ignored
if should_ignore "$image"; then
echo "Skipping check for image: $image"
continue
fi
echo "Checking for updates for image: $image"
# Get local and remote digests
local_digest=$(docker image inspect $image --format '{{index .RepoDigests 0}}' | cut -d'@' -f2)
remote_digest=$(docker pull --quiet --disable-content-trust $image > /dev/null 2>&1 && docker image inspect $image --format '{{index .RepoDigests 0}}' | cut -d'@' -f2)
if [ "$local_digest" != "$remote_digest" ]; then
docker-compose pull
docker-compose up -d --force-recreate
docker image prune -f
docker pull ghcr.io/mathisburger/cc-images-java:latest
docker pull golang:1.19
cd web && docker-compose pull && docker-compose up -d --force-recreate
exit 0
else
echo "$image is up to date."
fi
fi
done
echo "No new images found."