This commit is contained in:
Andras Bacsai 2022-07-25 18:43:53 +00:00
parent 9168cd1dc6
commit cf140ff4cf
3 changed files with 21 additions and 18 deletions

View File

@ -1,3 +1,6 @@
- RDE Application DNS check not working
- Check DNS configurations for app/service/coolify with RDE and local engines
- Refactor PR deployments (/apps/api/src/routes/api/v1/applications/handlers.ts#L744) and create previews model inside coolify db?
# Low
- Create previews model in Coolify DB

View File

@ -1,4 +1,18 @@
import { executeDockerCmd } from './common';
export function formatLabelsOnDocker(data) {
return data.trim().split('\n').map(a => JSON.parse(a)).map((container) => {
const labels = container.Labels.split(',')
let jsonLabels = {}
labels.forEach(l => {
const name = l.split('=')[0]
const value = l.split('=')[1]
jsonLabels = { ...jsonLabels, ...{ [name]: value } }
})
container.Labels = jsonLabels;
return container
})
}
export async function checkContainer({ dockerId, container, remove = false }: { dockerId: string, container: string, remove?: boolean }): Promise<boolean> {
let containerFound = false;
try {

View File

@ -6,7 +6,7 @@ import { FastifyReply } from 'fastify';
import { day } from '../../../../lib/dayjs';
import { setDefaultBaseImage, setDefaultConfiguration } from '../../../../lib/buildPacks/common';
import { checkDomainsIsValidInDNS, checkDoubleBranch, decrypt, encrypt, errorHandler, executeDockerCmd, generateSshKeyPair, getContainerUsage, getDomain, getFreeExposedPort, isDev, isDomainConfigured, prisma, stopBuild, uniqueName } from '../../../../lib/common';
import { checkContainer, isContainerExited, removeContainer } from '../../../../lib/docker';
import { checkContainer, formatLabelsOnDocker, isContainerExited, removeContainer } from '../../../../lib/docker';
import { scheduler } from '../../../../lib/scheduler';
import type { FastifyRequest } from 'fastify';
@ -741,22 +741,8 @@ export async function getPreviews(request: FastifyRequest<OnlyId>) {
PRMRSecrets: []
}
}
const out = stdout.trim().split('\n')
const jsonStdout = out.map(a => JSON.parse(a))
const containers = jsonStdout.filter((container) => {
const labels = container.Labels.split(',')
let jsonLabels = {}
labels.forEach(l => {
const name = l.split('=')[0]
const value = l.split('=')[1]
jsonLabels = { ...jsonLabels, ...{ [name]: value } }
})
container.Labels = jsonLabels;
return (
jsonLabels['coolify.configuration'] &&
jsonLabels['coolify.type'] === 'standalone-application'
);
});
const containers = formatLabelsOnDocker(stdout).filter(container => container.Labels['coolify.configuration'] && container.Labels['coolify.type'] === 'standalone-application')
const jsonContainers = containers
.map((container) =>
JSON.parse(Buffer.from(container.Labels['coolify.configuration'], 'base64').toString())