From 9ab5e13e8fb612aae90a372717ad60ca46fec29a Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 5 Sep 2022 10:01:49 +0200 Subject: [PATCH] fix: remote verification --- apps/api/src/routes/api/v1/destinations/handlers.ts | 4 ++-- apps/api/src/routes/api/v1/destinations/index.ts | 2 +- apps/ui/src/routes/destinations/[id]/_RemoteDocker.svelte | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/api/src/routes/api/v1/destinations/handlers.ts b/apps/api/src/routes/api/v1/destinations/handlers.ts index 88b8d3c51..effd1e8f0 100644 --- a/apps/api/src/routes/api/v1/destinations/handlers.ts +++ b/apps/api/src/routes/api/v1/destinations/handlers.ts @@ -222,7 +222,7 @@ export async function verifyRemoteDockerEngine(request: FastifyRequest, if (!coolifyNetwork) { await asyncExecShell(`DOCKER_HOST=${host} docker network create --attachable coolify-infra`); } - + if (isCoolifyProxyUsed) await startTraefikProxy(id); await prisma.destinationDocker.update({ where: { id }, data: { remoteVerified: true } }) return reply.code(201).send() @@ -235,7 +235,7 @@ export async function getDestinationStatus(request: FastifyRequest) { try { const { id } = request.params const destination = await prisma.destinationDocker.findUnique({ where: { id } }) - const isRunning = await checkContainer({ dockerId: destination.id, container: 'coolify-proxy' }) + const isRunning = await checkContainer({ dockerId: destination.id, container: 'coolify-proxy', remove: true }) return { isRunning } diff --git a/apps/api/src/routes/api/v1/destinations/index.ts b/apps/api/src/routes/api/v1/destinations/index.ts index 007242695..774afa285 100644 --- a/apps/api/src/routes/api/v1/destinations/index.ts +++ b/apps/api/src/routes/api/v1/destinations/index.ts @@ -23,7 +23,7 @@ const root: FastifyPluginAsync = async (fastify): Promise => { fastify.post('/:id/configuration/sshKey', async (request) => await assignSSHKey(request)); - fastify.post('/:id/verify', async (request, reply) => await verifyRemoteDockerEngine(request, reply)); + fastify.post('/:id/verify', async (request, reply) => await verifyRemoteDockerEngine(request, reply)); }; export default root; diff --git a/apps/ui/src/routes/destinations/[id]/_RemoteDocker.svelte b/apps/ui/src/routes/destinations/[id]/_RemoteDocker.svelte index 368b51816..c72433ad7 100644 --- a/apps/ui/src/routes/destinations/[id]/_RemoteDocker.svelte +++ b/apps/ui/src/routes/destinations/[id]/_RemoteDocker.svelte @@ -38,8 +38,8 @@ } } onMount(async () => { - loading.proxy = true; if (destination.remoteEngine && destination.remoteVerified) { + loading.proxy = true; const { isRunning } = await get(`/destinations/${id}/status`); if (isRunning === false && destination.isCoolifyProxyUsed === true) { destination.isCoolifyProxyUsed = !destination.isCoolifyProxyUsed; @@ -69,6 +69,7 @@ loading.proxy = false; }); async function changeProxySetting() { + if (!destination.remoteVerified) return loading.proxy = true; if (!cannotDisable) { const isProxyActivated = destination.isCoolifyProxyUsed; @@ -262,7 +263,7 @@