This commit is contained in:
Andras Bacsai 2022-09-05 10:17:52 +02:00
parent a672f0f56c
commit 5305bc1ceb

View File

@ -212,21 +212,25 @@ export async function verifyRemoteDockerEngine(request: FastifyRequest<OnlyId>,
const { remoteIpAddress, remoteUser, network, isCoolifyProxyUsed } = await prisma.destinationDocker.findFirst({ where: { id } }) const { remoteIpAddress, remoteUser, network, isCoolifyProxyUsed } = await prisma.destinationDocker.findFirst({ where: { id } })
const host = `ssh://${remoteUser}@${remoteIpAddress}` const host = `ssh://${remoteUser}@${remoteIpAddress}`
console.log({ host })
const { stdout } = await asyncExecShell(`DOCKER_HOST=${host} docker network ls --filter 'name=${network}' --no-trunc --format "{{json .}}"`); const { stdout } = await asyncExecShell(`DOCKER_HOST=${host} docker network ls --filter 'name=${network}' --no-trunc --format "{{json .}}"`);
console.log({ stdout })
if (!stdout) { if (!stdout) {
await asyncExecShell(`DOCKER_HOST=${host} docker network create --attachable ${network}`); await asyncExecShell(`DOCKER_HOST=${host} docker network create --attachable ${network}`);
} }
const { stdout: coolifyNetwork } = await asyncExecShell(`DOCKER_HOST=${host} docker network ls --filter 'name=coolify-infra' --no-trunc --format "{{json .}}"`); const { stdout: coolifyNetwork } = await asyncExecShell(`DOCKER_HOST=${host} docker network ls --filter 'name=coolify-infra' --no-trunc --format "{{json .}}"`);
console.log({ coolifyNetwork })
if (!coolifyNetwork) { if (!coolifyNetwork) {
await asyncExecShell(`DOCKER_HOST=${host} docker network create --attachable coolify-infra`); await asyncExecShell(`DOCKER_HOST=${host} docker network create --attachable coolify-infra`);
} }
console.log({ isCoolifyProxyUsed })
if (isCoolifyProxyUsed) await startTraefikProxy(id); if (isCoolifyProxyUsed) await startTraefikProxy(id);
await prisma.destinationDocker.update({ where: { id }, data: { remoteVerified: true } }) await prisma.destinationDocker.update({ where: { id }, data: { remoteVerified: true } })
return reply.code(201).send() return reply.code(201).send()
} catch ({ status, message }) { } catch ({ status, message }) {
console.log({ status, message })
return errorHandler({ status, message }) return errorHandler({ status, message })
} }
} }