From c4d39aced298685853f7bcffa6b28f7093e9102a Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 16 Mar 2023 13:10:34 +0100 Subject: [PATCH] fix: revert from dockerhub if ghcr.io does not exists --- apps/api/src/routes/api/v1/handlers.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/api/src/routes/api/v1/handlers.ts b/apps/api/src/routes/api/v1/handlers.ts index 8dd0f3adb..5cb283137 100644 --- a/apps/api/src/routes/api/v1/handlers.ts +++ b/apps/api/src/routes/api/v1/handlers.ts @@ -156,14 +156,21 @@ export async function update(request: FastifyRequest) { try { if (!isDev) { const { isAutoUpdateEnabled } = await prisma.setting.findFirst(); - await executeCommand({ command: `docker pull ghcr.io/coollabsio/coolify:${latestVersion}` }); + let image = `ghcr.io/coollabsio/coolify:${latestVersion}`; + try { + await executeCommand({ command: `docker pull ${image}` }); + } catch (error) { + image = `coollabsio/coolify:${latestVersion}`; + await executeCommand({ command: `docker pull ${image}` }); + } + await executeCommand({ shell: true, command: `env | grep COOLIFY > .env` }); await executeCommand({ command: `sed -i '/COOLIFY_AUTO_UPDATE=/cCOOLIFY_AUTO_UPDATE=${isAutoUpdateEnabled}' .env` }); await executeCommand({ shell: true, - command: `docker run --rm -tid --env-file .env -v /var/run/docker.sock:/var/run/docker.sock -v coolify-db ghcr.io/coollabsio/coolify:${latestVersion} /bin/sh -c "env | grep COOLIFY > .env && echo 'TAG=${latestVersion}' >> .env && docker stop -t 0 coolify coolify-fluentbit && docker rm coolify coolify-fluentbit && docker compose pull && docker compose up -d --force-recreate"` + command: `docker run --rm -tid --env-file .env -v /var/run/docker.sock:/var/run/docker.sock -v coolify-db ${image} /bin/sh -c "env | grep COOLIFY > .env && echo 'TAG=${latestVersion}' >> .env && docker stop -t 0 coolify coolify-fluentbit && docker rm coolify coolify-fluentbit && docker compose pull && docker compose up -d --force-recreate"` }); return {}; } else {