feat(traefik-setup): check for existing image before pulling to optimize image management

This commit is contained in:
s1nyx
2025-06-11 08:12:00 +02:00
parent 9f146d7d80
commit 9fb6ca2b3b

View File

@@ -124,7 +124,12 @@ export const initializeTraefik = async ({
console.log("No existing container to remove"); console.log("No existing container to remove");
} }
console.log(`Pulling image ${imageName}...`); try {
await docker.getImage(imageName).inspect();
console.log(`Image ${imageName} already exists locally.`);
} catch (error: any) {
if (error?.statusCode === 404) {
console.log(`Image ${imageName} not found, pulling...`);
const stream = await docker.pull(imageName); const stream = await docker.pull(imageName);
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -134,6 +139,10 @@ export const initializeTraefik = async ({
); );
}); });
console.log(`Image ${imageName} pulled successfully.`); console.log(`Image ${imageName} pulled successfully.`);
} else {
throw error;
}
}
// Create and start the new container // Create and start the new container
try { try {