mirror of
https://github.com/ershisan99/coolify.git
synced 2025-12-27 20:49:32 +00:00
v1.0.13 (#46)
This commit is contained in:
@@ -44,7 +44,7 @@ export async function post(request: Request) {
|
||||
return {
|
||||
status: 500,
|
||||
body: {
|
||||
error
|
||||
error: error.message || error
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,9 +1,25 @@
|
||||
import { docker } from '$lib/api/docker';
|
||||
import Configuration from '$models/Configuration';
|
||||
import type { Request } from '@sveltejs/kit';
|
||||
|
||||
export async function post(request: Request) {
|
||||
const { name, organization, branch }: any = request.body || {};
|
||||
if (name && organization && branch) {
|
||||
const configurationFound = await Configuration.findOne({
|
||||
'repository.name': name,
|
||||
'repository.organization': organization,
|
||||
'repository.branch': branch,
|
||||
}).lean()
|
||||
if (configurationFound) {
|
||||
return {
|
||||
status: 200,
|
||||
body: {
|
||||
success: true,
|
||||
...configurationFound
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const services = await docker.engine.listServices();
|
||||
const applications = services.filter(
|
||||
(r) => r.Spec.Labels.managedBy === 'coolify' && r.Spec.Labels.type === 'application'
|
||||
@@ -38,13 +54,12 @@ export async function post(request: Request) {
|
||||
...JSON.parse(found.Spec.Labels.configuration)
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
status: 500,
|
||||
body: {
|
||||
error: 'No configuration found.'
|
||||
}
|
||||
};
|
||||
}
|
||||
return {
|
||||
status: 500,
|
||||
body: {
|
||||
error: 'No configuration found.'
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import type { Request } from '@sveltejs/kit';
|
||||
import Deployment from '$models/Logs/Deployment';
|
||||
import Deployment from '$models/Deployment';
|
||||
import { docker } from '$lib/api/docker';
|
||||
import { precheckDeployment, setDefaultConfiguration } from '$lib/api/applications/configuration';
|
||||
import cloneRepository from '$lib/api/applications/cloneRepository';
|
||||
import { cleanupTmp } from '$lib/api/common';
|
||||
import queueAndBuild from '$lib/api/applications/queueAndBuild';
|
||||
import Configuration from '$models/Configuration';
|
||||
export async function post(request: Request) {
|
||||
let configuration;
|
||||
try {
|
||||
@@ -53,6 +54,27 @@ export async function post(request: Request) {
|
||||
}
|
||||
};
|
||||
}
|
||||
const { id, organization, name, branch } = configuration.repository;
|
||||
const { domain } = configuration.publish;
|
||||
const { deployId, nickname } = configuration.general;
|
||||
await new Deployment({
|
||||
repoId: id,
|
||||
branch,
|
||||
deployId,
|
||||
domain,
|
||||
organization,
|
||||
name,
|
||||
nickname
|
||||
}).save();
|
||||
await Configuration.findOneAndUpdate({
|
||||
'repository.id': id,
|
||||
'repository.organization': organization,
|
||||
'repository.name': name,
|
||||
'repository.branch': branch,
|
||||
},
|
||||
{ ...configuration },
|
||||
{ upsert: true, new: true })
|
||||
|
||||
queueAndBuild(configuration, imageChanged);
|
||||
return {
|
||||
status: 200,
|
||||
@@ -70,20 +92,21 @@ export async function post(request: Request) {
|
||||
branch: configuration.repository.branch,
|
||||
organization: configuration.repository.organization,
|
||||
name: configuration.repository.name,
|
||||
domain: configuration.publish.domain,
|
||||
domain: configuration.publish.domain
|
||||
},
|
||||
{
|
||||
repoId: configuration.repository.id,
|
||||
branch: configuration.repository.branch,
|
||||
organization: configuration.repository.organization,
|
||||
name: configuration.repository.name,
|
||||
domain: configuration.publish.domain, progress: 'failed'
|
||||
domain: configuration.publish.domain,
|
||||
progress: 'failed'
|
||||
}
|
||||
);
|
||||
return {
|
||||
status: 500,
|
||||
body: {
|
||||
error
|
||||
error: error.message || error
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Request } from '@sveltejs/kit';
|
||||
import ApplicationLog from '$models/Logs/Application';
|
||||
import Deployment from '$models/Logs/Deployment';
|
||||
import ApplicationLog from '$models/ApplicationLog';
|
||||
import Deployment from '$models/Deployment';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export async function get(request: Request) {
|
||||
@@ -24,11 +24,11 @@ export async function get(request: Request) {
|
||||
...finalLogs
|
||||
}
|
||||
};
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
return {
|
||||
status: 500,
|
||||
body: {
|
||||
error: e
|
||||
error: error.message || error
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { Request } from '@sveltejs/kit';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc.js';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime.js';
|
||||
import Deployment from '$models/Logs/Deployment';
|
||||
import Deployment from '$models/Deployment';
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(relativeTime);
|
||||
export async function get(request: Request) {
|
||||
@@ -10,7 +10,6 @@ export async function get(request: Request) {
|
||||
const repoId = request.query.get('repoId');
|
||||
const branch = request.query.get('branch');
|
||||
const page = request.query.get('page');
|
||||
|
||||
const onePage = 5;
|
||||
const show = Number(page) * onePage || 5;
|
||||
const deploy: any = await Deployment.find({ repoId, branch })
|
||||
@@ -20,12 +19,9 @@ export async function get(request: Request) {
|
||||
|
||||
const finalLogs = deploy.map((d) => {
|
||||
const finalLogs = { ...d._doc };
|
||||
|
||||
const updatedAt = dayjs(d.updatedAt).utc();
|
||||
|
||||
finalLogs.took = updatedAt.diff(dayjs(d.createdAt)) / 1000;
|
||||
finalLogs.since = updatedAt.fromNow();
|
||||
|
||||
return finalLogs;
|
||||
});
|
||||
return {
|
||||
@@ -36,11 +32,10 @@ export async function get(request: Request) {
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return {
|
||||
status: 500,
|
||||
body: {
|
||||
error
|
||||
error: error.message || error
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -16,11 +16,12 @@ export async function get(request: Request) {
|
||||
body: { success: true, logs }
|
||||
};
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
await saveServerLog(error);
|
||||
return {
|
||||
status: 500,
|
||||
body: {
|
||||
error
|
||||
error: 'No such service. Is it under deployment?'
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { purgeImagesContainers } from '$lib/api/applications/cleanup';
|
||||
import { docker } from '$lib/api/docker';
|
||||
import Deployment from '$models/Logs/Deployment';
|
||||
import ApplicationLog from '$models/Logs/Application';
|
||||
import Deployment from '$models/Deployment';
|
||||
import ApplicationLog from '$models/ApplicationLog';
|
||||
import { delay, execShellAsync } from '$lib/api/common';
|
||||
import Configuration from '$models/Configuration';
|
||||
|
||||
async function call(found) {
|
||||
await delay(10000);
|
||||
@@ -26,6 +27,11 @@ export async function post(request: Request) {
|
||||
return null;
|
||||
});
|
||||
if (found) {
|
||||
await Configuration.findOneAndRemove({
|
||||
'repository.name': name,
|
||||
'repository.organization': organization,
|
||||
'repository.branch': branch,
|
||||
})
|
||||
const deploys = await Deployment.find({ organization, branch, name });
|
||||
for (const deploy of deploys) {
|
||||
await ApplicationLog.deleteMany({ deployId: deploy.deployId });
|
||||
|
||||
Reference in New Issue
Block a user