Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fixes

Andras Bacsaicf140ff4cfe1
diff --git a/TODO.md b/TODO.md
index 4cabd88fdd..be0d3d48f7 100644
--- a/TODO.md
+++ b/TODO.md
@@ -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?
\ No newline at end of file
+
+
+# Low
+- Create previews model in Coolify DB
\ No newline at end of file
diff --git a/apps/api/src/lib/docker.ts b/apps/api/src/lib/docker.ts
index f80526cd38..db2dbc3e73 100644
--- a/apps/api/src/lib/docker.ts
+++ b/apps/api/src/lib/docker.ts
@@ -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 {
diff --git a/apps/api/src/routes/api/v1/applications/handlers.ts b/apps/api/src/routes/api/v1/applications/handlers.ts
index 4b37b071b1..dfdfa53897 100644
--- a/apps/api/src/routes/api/v1/applications/handlers.ts
+++ b/apps/api/src/routes/api/v1/applications/handlers.ts
@@ -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())