docker appupdate?
This commit is contained in:
parent
f7e6544885
commit
6098673a46
1 changed files with 26 additions and 1 deletions
27
.zshrc
27
.zshrc
|
@ -173,7 +173,32 @@ __docker__() {
|
|||
alias dcs="docker compose ps -a --format 'table {{.Name}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}'"
|
||||
alias dl="docker compose logs -f"
|
||||
alias dc="docker compose"
|
||||
alias appupdate="docker compose pull && docker compose up -d --force-recreate"
|
||||
check_for_updates() {
|
||||
local updated=false
|
||||
local images=$(docker compose config | grep 'image:' | awk '{print $2}')
|
||||
|
||||
for image in $images; do
|
||||
echo -e "${CYAN}Checking for updates for image: ${YELLOW}$image${NC}"
|
||||
local local_digest=$(docker image inspect "$image" --format '{{index .RepoDigests 0}}' 2>/dev/null)
|
||||
local remote_digest=$(docker pull --quiet --dry-run "$image" 2>/dev/null | grep 'Digest:' | awk '{print $2}')
|
||||
|
||||
if [[ "$local_digest" != "$remote_digest" ]]; then
|
||||
echo -e "${GREEN}Update available for $image${NC}"
|
||||
updated=true
|
||||
else
|
||||
echo -e "${YELLOW}No update available for $image${NC}"
|
||||
fi
|
||||
done
|
||||
|
||||
if $updated; then
|
||||
echo -e "${CYAN}Pulling updates and recreating containers...${NC}"
|
||||
docker compose pull && docker compose up -d --force-recreate
|
||||
else
|
||||
echo -e "${GREEN}All images are up to date. No action needed.${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
alias appupdate="check_for_updates"
|
||||
}
|
||||
|
||||
__git__() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue