feat: compose app

This commit is contained in:
Lorenzo Migliorero
2024-07-25 22:10:35 +02:00
parent 1f81ebd4fe
commit c681aa2e9f
10 changed files with 3122 additions and 208 deletions

View File

@@ -31,11 +31,6 @@ import {
removeDirectoryCode,
removeMonitoringDirectory,
} from "@/server/utils/filesystem/directory";
import {
generateSSHKey,
readSSHPublicKey,
removeSSHKey,
} from "@/server/utils/filesystem/ssh";
import {
readConfig,
removeTraefikConfig,
@@ -130,7 +125,6 @@ export const applicationRouter = createTRPCRouter({
async () => await removeMonitoringDirectory(application?.appName),
async () => await removeTraefikConfig(application?.appName),
async () => await removeService(application?.appName),
async () => await removeSSHKey(application?.appName),
];
for (const operation of cleanupOperations) {
@@ -240,32 +234,6 @@ export const applicationRouter = createTRPCRouter({
applicationStatus: "idle",
});
return true;
}),
generateSSHKey: protectedProcedure
.input(apiFindOneApplication)
.mutation(async ({ input }) => {
const application = await findApplicationById(input.applicationId);
try {
await generateSSHKey(application.appName);
const file = await readSSHPublicKey(application.appName);
// await updateApplication(input.applicationId, {
// customGitSSHKey: file,
// });
} catch (error) {}
return true;
}),
removeSSHKey: protectedProcedure
.input(apiFindOneApplication)
.mutation(async ({ input }) => {
const application = await findApplicationById(input.applicationId);
await removeSSHKey(application.appName);
// await updateApplication(input.applicationId, {
// customGitSSHKey: null,
// });
return true;
}),
markRunning: protectedProcedure

View File

@@ -16,11 +16,6 @@ import { myQueue } from "@/server/queues/queueSetup";
import { createCommand } from "@/server/utils/builders/compose";
import { randomizeComposeFile } from "@/server/utils/docker/compose";
import { removeComposeDirectory } from "@/server/utils/filesystem/directory";
import {
generateSSHKey,
readSSHPublicKey,
removeSSHKey,
} from "@/server/utils/filesystem/ssh";
import { templates } from "@/templates/templates";
import type { TemplatesKeys } from "@/templates/types/templates-data.type";
import {
@@ -102,7 +97,6 @@ export const composeRouter = createTRPCRouter({
async () => await removeCompose(composeResult),
async () => await removeDeploymentsByComposeId(composeResult),
async () => await removeComposeDirectory(composeResult.appName),
async () => await removeSSHKey(composeResult.appName),
];
for (const operation of cleanupOperations) {
@@ -181,38 +175,12 @@ export const composeRouter = createTRPCRouter({
const command = createCommand(compose);
return `docker ${command}`;
}),
generateSSHKey: protectedProcedure
.input(apiFindCompose)
.mutation(async ({ input }) => {
const compose = await findComposeById(input.composeId);
try {
await generateSSHKey(compose.appName);
const file = await readSSHPublicKey(compose.appName);
await updateCompose(input.composeId, {
customGitSSHKey: file,
});
} catch (error) {}
return true;
}),
refreshToken: protectedProcedure
.input(apiFindCompose)
.mutation(async ({ input }) => {
await updateCompose(input.composeId, {
refreshToken: nanoid(),
});
return true;
}),
removeSSHKey: protectedProcedure
.input(apiFindCompose)
.mutation(async ({ input }) => {
const compose = await findComposeById(input.composeId);
await removeSSHKey(compose.appName);
await updateCompose(input.composeId, {
customGitSSHKey: null,
});
return true;
}),
deployTemplate: protectedProcedure