From 8b18a16446016a85b7c968aeb209bcbb976bdb5e Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Sun, 8 Mar 2026 21:48:22 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20chore:=20Remove=20Docke?= =?UTF-8?q?r=20Images=20by=20Named=20Tag=20in=20`deployed-update.js`=20(#1?= =?UTF-8?q?2138)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: remove docker images by named tag instead of image ID * refactor: Simplify rebase logic and enhance error handling in deployed-update script - Removed unnecessary condition for rebasing, streamlining the update process. - Renamed variable for clarity when fetching Docker image tags. - Added error handling to catch and log failures during the update process, ensuring better visibility of issues. --- config/deployed-update.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/config/deployed-update.js b/config/deployed-update.js index 7b2a3bc594..7ce6eb106d 100644 --- a/config/deployed-update.js +++ b/config/deployed-update.js @@ -29,7 +29,7 @@ const shouldRebase = process.argv.includes('--rebase'); execSync('git checkout main', { stdio: 'inherit' }); console.purple('Pulling the latest code from main...'); execSync('git pull origin main', { stdio: 'inherit' }); - } else if (shouldRebase) { + } else { const currentBranch = getCurrentBranch(); console.purple(`Rebasing ${currentBranch} onto main...`); execSync('git rebase origin/main', { stdio: 'inherit' }); @@ -43,11 +43,14 @@ const shouldRebase = process.argv.includes('--rebase'); console.purple('Removing all tags for LibreChat `deployed` images...'); const repositories = ['registry.librechat.ai/danny-avila/librechat-dev-api', 'librechat-client']; repositories.forEach((repo) => { - const tags = execSync(`sudo docker images ${repo} -q`, { encoding: 'utf8' }) + const imageRefs = execSync(`sudo docker images ${repo} --format "{{.Repository}}:{{.Tag}}"`, { + encoding: 'utf8', + }) .split('\n') - .filter(Boolean); - tags.forEach((tag) => { - const removeImageCommand = `sudo docker rmi ${tag}`; + .filter(Boolean) + .filter((ref) => !ref.includes('')); + imageRefs.forEach((imageRef) => { + const removeImageCommand = `sudo docker rmi ${imageRef}`; console.orange(removeImageCommand); execSync(removeImageCommand, { stdio: 'inherit' }); }); @@ -58,11 +61,14 @@ const shouldRebase = process.argv.includes('--rebase'); console.orange(pullCommand); execSync(pullCommand, { stdio: 'inherit' }); - let startCommand = 'sudo docker compose -f ./deploy-compose.yml up -d'; + const startCommand = 'sudo docker compose -f ./deploy-compose.yml up -d'; console.green('Your LibreChat app is now up to date! Start the app with the following command:'); console.purple(startCommand); console.orange( "Note: it's also recommended to clear your browser cookies and localStorage for LibreChat to assure a fully clean installation.", ); console.orange("Also: Don't worry, your data is safe :)"); -})(); +})().catch((err) => { + console.error('Update script failed:', err.message); + process.exit(1); +});