This commit is contained in:
Andras Bacsai 2022-12-06 10:29:14 +01:00
parent b45ad19732
commit dcb29a80fe

View File

@ -335,19 +335,21 @@ export async function proxyConfiguration(request: FastifyRequest<OnlyId>, remote
traefik.http.services = { ...traefik.http.services, ...generateServices(serviceId, id, port) } traefik.http.services = { ...traefik.http.services, ...generateServices(serviceId, id, port) }
if (previews) { if (previews) {
const { stdout } = await executeCommand({ dockerId, command: `docker container ls --filter="status=running" --filter="network=${network}" --filter="name=${id}-" --format="{{json .Names}}"` }) const { stdout } = await executeCommand({ dockerId, command: `docker container ls --filter="status=running" --filter="network=${network}" --filter="name=${id}-" --format="{{json .Names}}"` })
const containers = stdout if (stdout) {
.trim() const containers = stdout
.split('\n') .trim()
.filter((a) => a) .split('\n')
.map((c) => c.replace(/"/g, '')); .filter((a) => a)
if (containers.length > 0) { .map((c) => c.replace(/"/g, ''));
for (const container of containers) { if (containers.length > 0) {
const previewDomain = `${container.split('-')[1]}${coolifySettings.previewSeparator}${domain}`; for (const container of containers) {
const nakedDomain = previewDomain.replace(/^www\./, ''); const previewDomain = `${container.split('-')[1]}${coolifySettings.previewSeparator}${domain}`;
const pathPrefix = '/' const nakedDomain = previewDomain.replace(/^www\./, '');
const serviceId = `${container}-${port || 'default'}` const pathPrefix = '/'
traefik.http.routers = { ...traefik.http.routers, ...generateRouters(serviceId, previewDomain, nakedDomain, pathPrefix, isHttps, isWWW, dualCerts, isCustomSSL) } const serviceId = `${container}-${port || 'default'}`
traefik.http.services = { ...traefik.http.services, ...generateServices(serviceId, container, port) } traefik.http.routers = { ...traefik.http.routers, ...generateRouters(serviceId, previewDomain, nakedDomain, pathPrefix, isHttps, isWWW, dualCerts, isCustomSSL) }
traefik.http.services = { ...traefik.http.services, ...generateServices(serviceId, container, port) }
}
} }
} }
} }
@ -362,9 +364,11 @@ export async function proxyConfiguration(request: FastifyRequest<OnlyId>, remote
services.forEach((app) => dockerIds.add(app.destinationDocker.id)); services.forEach((app) => dockerIds.add(app.destinationDocker.id));
for (const dockerId of dockerIds) { for (const dockerId of dockerIds) {
const { stdout: container } = await executeCommand({ dockerId, command: `docker container ls --filter 'label=coolify.managed=true' --format '{{ .Names}}'` }) const { stdout: container } = await executeCommand({ dockerId, command: `docker container ls --filter 'label=coolify.managed=true' --format '{{ .Names}}'` })
const containersArray = container.trim().split('\n'); if (container) {
if (containersArray.length > 0) { const containersArray = container.trim().split('\n');
runningContainers[dockerId] = containersArray if (containersArray.length > 0) {
runningContainers[dockerId] = containersArray
}
} }
} }
for (const service of services) { for (const service of services) {