mirror of
https://github.com/ershisan99/coolify.git
synced 2025-12-17 12:33:06 +00:00
fix: docker compose generator
This commit is contained in:
@@ -306,7 +306,7 @@ async function initServer() {
|
||||
} catch (error) {}
|
||||
try {
|
||||
console.log('[003] Cleaning up old build sources under /tmp/build-sources/...');
|
||||
await fs.rm('/tmp/build-sources', { recursive: true, force: true });
|
||||
if (!isDev) await fs.rm('/tmp/build-sources', { recursive: true, force: true });
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ import * as buildpacks from '../lib/buildPacks';
|
||||
applicationId: application.id
|
||||
});
|
||||
}
|
||||
await fs.rm(workdir, { recursive: true, force: true });
|
||||
if (!isDev) await fs.rm(workdir, { recursive: true, force: true });
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@@ -263,7 +263,7 @@ import * as buildpacks from '../lib/buildPacks';
|
||||
await saveBuildLog({ line: error.stderr, buildId, applicationId });
|
||||
}
|
||||
} finally {
|
||||
await fs.rm(workdir, { recursive: true, force: true });
|
||||
if (!isDev) await fs.rm(workdir, { recursive: true, force: true });
|
||||
await prisma.build.update({
|
||||
where: { id: buildId },
|
||||
data: { status: 'success' }
|
||||
@@ -782,7 +782,7 @@ import * as buildpacks from '../lib/buildPacks';
|
||||
applicationId: application.id
|
||||
});
|
||||
}
|
||||
await fs.rm(workdir, { recursive: true, force: true });
|
||||
if (!isDev) await fs.rm(workdir, { recursive: true, force: true });
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@@ -803,7 +803,7 @@ import * as buildpacks from '../lib/buildPacks';
|
||||
await saveBuildLog({ line: error.stderr, buildId, applicationId });
|
||||
}
|
||||
} finally {
|
||||
await fs.rm(workdir, { recursive: true, force: true });
|
||||
if (!isDev) await fs.rm(workdir, { recursive: true, force: true });
|
||||
await prisma.build.update({ where: { id: buildId }, data: { status: 'success' } });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -47,7 +47,12 @@ export default async function (data) {
|
||||
for (let [key, value] of Object.entries(dockerComposeYaml.services)) {
|
||||
value['container_name'] = `${applicationId}-${key}`;
|
||||
|
||||
if (value['env_file']) {
|
||||
delete value['env_file'];
|
||||
}
|
||||
|
||||
let environment = typeof value['environment'] === 'undefined' ? [] : value['environment'];
|
||||
console.log({ key, environment });
|
||||
if (Object.keys(environment).length > 0) {
|
||||
environment = Object.entries(environment).map(([key, value]) => `${key}=${value}`);
|
||||
}
|
||||
@@ -60,7 +65,7 @@ export default async function (data) {
|
||||
const buildArgs = typeof build['args'] === 'undefined' ? [] : build['args'];
|
||||
let finalArgs = [...buildEnvs];
|
||||
if (Object.keys(buildArgs).length > 0) {
|
||||
for (const arg of buildArgs) {
|
||||
for (const arg of Object.keys(buildArgs)) {
|
||||
const [key, _] = arg.split('=');
|
||||
if (finalArgs.filter((env) => env.startsWith(key)).length === 0) {
|
||||
finalArgs.push(arg);
|
||||
@@ -87,7 +92,10 @@ export default async function (data) {
|
||||
v.startsWith('~') ||
|
||||
v.startsWith('$PWD')
|
||||
) {
|
||||
v = v.replace(/^\./, `~`).replace(/^\.\./, '~').replace(/^\$PWD/, '~');
|
||||
v = v
|
||||
.replace(/^\./, `~`)
|
||||
.replace(/^\.\./, '~')
|
||||
.replace(/^\$PWD/, '~');
|
||||
} else {
|
||||
if (!path) {
|
||||
path = v;
|
||||
@@ -110,10 +118,11 @@ export default async function (data) {
|
||||
source.startsWith('~') ||
|
||||
source.startsWith('$PWD')
|
||||
) {
|
||||
|
||||
source = source.replace(/^\./, `~`).replace(/^\.\./, '~').replace(/^\$PWD/, '~');
|
||||
console.log({source})
|
||||
|
||||
source = source
|
||||
.replace(/^\./, `~`)
|
||||
.replace(/^\.\./, '~')
|
||||
.replace(/^\$PWD/, '~');
|
||||
console.log({ source });
|
||||
} else {
|
||||
if (!target) {
|
||||
target = source;
|
||||
@@ -125,7 +134,6 @@ export default async function (data) {
|
||||
|
||||
return `${source}:${target}${mode ? ':' + mode : ''}`;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
if (volumes.length > 0) {
|
||||
@@ -136,16 +144,20 @@ export default async function (data) {
|
||||
if (dockerComposeConfiguration[key]?.port) {
|
||||
value['expose'] = [dockerComposeConfiguration[key].port];
|
||||
}
|
||||
if (value['networks']?.length > 0) {
|
||||
value['networks'].forEach((network) => {
|
||||
networks[network] = {
|
||||
name: network
|
||||
};
|
||||
});
|
||||
value['networks'] = [...(value['networks'] || ''), network];
|
||||
} else {
|
||||
value['networks'] = [network];
|
||||
value['networks'] = [network];
|
||||
if (value['build']?.network) {
|
||||
delete value['build']['network'];
|
||||
}
|
||||
// if (value['networks']?.length > 0) {
|
||||
// value['networks'].forEach((network) => {
|
||||
// networks[network] = {
|
||||
// name: network
|
||||
// };
|
||||
// });
|
||||
// value['networks'] = [...(value['networks'] || ''), network];
|
||||
// } else {
|
||||
// value['networks'] = [network];
|
||||
// }
|
||||
|
||||
dockerComposeYaml.services[key] = {
|
||||
...dockerComposeYaml.services[key],
|
||||
|
||||
@@ -19,7 +19,7 @@ import { saveBuildLog } from './buildPacks/common';
|
||||
import { scheduler } from './scheduler';
|
||||
import type { ExecaChildProcess } from 'execa';
|
||||
|
||||
export const version = '3.12.29';
|
||||
export const version = '3.12.30';
|
||||
export const isDev = process.env.NODE_ENV === 'development';
|
||||
export const proxyPort = process.env.COOLIFY_PROXY_PORT;
|
||||
export const proxySecurePort = process.env.COOLIFY_PROXY_SECURE_PORT;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "coolify",
|
||||
"description": "An open-source & self-hostable Heroku / Netlify alternative.",
|
||||
"version": "3.12.29",
|
||||
"version": "3.12.30",
|
||||
"license": "Apache-2.0",
|
||||
"repository": "github:coollabsio/coolify",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user