From c49b74943b79e2e4d68f2b286db1b629155c991b Mon Sep 17 00:00:00 2001 From: Eric Torres Date: Sun, 21 Jul 2024 22:31:42 -0700 Subject: [PATCH] Revert "Remove dockerupdate command" This reverts commit 1b7955fb8f2d787b94cb2e7312a77766a3daf6c2. --- zsh/.config/zsh/dockerupdate.zsh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 zsh/.config/zsh/dockerupdate.zsh diff --git a/zsh/.config/zsh/dockerupdate.zsh b/zsh/.config/zsh/dockerupdate.zsh new file mode 100644 index 0000000..031cd2f --- /dev/null +++ b/zsh/.config/zsh/dockerupdate.zsh @@ -0,0 +1,19 @@ +# Update a docker container using docker compose +# +# Run this command safely by: +# - Ensuring the docker binary exists +# - The docker-compose.(yml|yaml) file is readable +# - Waiting 5 seconds between docker compose pulls to avoid being rate limited +dockerupdate() { + # If either docker is not installed or docker-compose file is missing, do not run + if [[ ! -x "$(which docker)" ]] && ([[ ! -r docker-compose.yml ]] || [[ ! -r docker-compose.yaml ]]); then + return 1 + else + until docker compose pull; do + docker compose pull + # Do not run this command too often + sleep 5 + done + docker compose up -d + fi +}