mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: lint
This commit is contained in:
@@ -14,8 +14,8 @@ import { useForm } from "react-hook-form";
|
|||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { validateAndFormatYAML } from "../../application/advanced/traefik/update-traefik-config";
|
import { validateAndFormatYAML } from "../../application/advanced/traefik/update-traefik-config";
|
||||||
import { RandomizeCompose } from "./randomize-compose";
|
|
||||||
import { RandomizeDeployable } from "./isolated-deployment";
|
import { RandomizeDeployable } from "./isolated-deployment";
|
||||||
|
import { RandomizeCompose } from "./randomize-compose";
|
||||||
import { ShowUtilities } from "./show-utilities";
|
import { ShowUtilities } from "./show-utilities";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Button } from "@/components/ui/button";
|
||||||
import { IsolatedDeployment } from "./isolated-deployment";
|
|
||||||
import { RandomizeCompose } from "./randomize-compose";
|
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
@@ -9,8 +7,10 @@ import {
|
|||||||
DialogTitle,
|
DialogTitle,
|
||||||
DialogTrigger,
|
DialogTrigger,
|
||||||
} from "@/components/ui/dialog";
|
} from "@/components/ui/dialog";
|
||||||
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { IsolatedDeployment } from "./isolated-deployment";
|
||||||
|
import { RandomizeCompose } from "./randomize-compose";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
composeId: string;
|
composeId: string;
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ export const composeRouter = createTRPCRouter({
|
|||||||
}
|
}
|
||||||
return await randomizeIsolatedDeploymentComposeFile(
|
return await randomizeIsolatedDeploymentComposeFile(
|
||||||
input.composeId,
|
input.composeId,
|
||||||
input.suffix
|
input.suffix,
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
getConvertedCompose: protectedProcedure
|
getConvertedCompose: protectedProcedure
|
||||||
@@ -280,7 +280,7 @@ export const composeRouter = createTRPCRouter({
|
|||||||
{
|
{
|
||||||
removeOnComplete: true,
|
removeOnComplete: true,
|
||||||
removeOnFail: true,
|
removeOnFail: true,
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
redeploy: protectedProcedure
|
redeploy: protectedProcedure
|
||||||
@@ -312,7 +312,7 @@ export const composeRouter = createTRPCRouter({
|
|||||||
{
|
{
|
||||||
removeOnComplete: true,
|
removeOnComplete: true,
|
||||||
removeOnFail: true,
|
removeOnFail: true,
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
stop: protectedProcedure
|
stop: protectedProcedure
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export const compose = pgTable("compose", {
|
|||||||
() => sshKeys.sshKeyId,
|
() => sshKeys.sshKeyId,
|
||||||
{
|
{
|
||||||
onDelete: "set null",
|
onDelete: "set null",
|
||||||
}
|
},
|
||||||
),
|
),
|
||||||
command: text("command").notNull().default(""),
|
command: text("command").notNull().default(""),
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export const buildCompose = async (compose: ComposeNested, logPath: string) => {
|
|||||||
|
|
||||||
if (compose.isolatedDeployment) {
|
if (compose.isolatedDeployment) {
|
||||||
await execAsync(
|
await execAsync(
|
||||||
`docker network inspect ${compose.appName} >/dev/null 2>&1 || docker network create --attachable ${compose.appName}`
|
`docker network inspect ${compose.appName} >/dev/null 2>&1 || docker network create --attachable ${compose.appName}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,12 +76,12 @@ export const buildCompose = async (compose: ComposeNested, logPath: string) => {
|
|||||||
...getEnviromentVariablesObject(compose.env, compose.project.env),
|
...getEnviromentVariablesObject(compose.env, compose.project.env),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (compose.isolatedDeployment) {
|
if (compose.isolatedDeployment) {
|
||||||
await execAsync(
|
await execAsync(
|
||||||
`docker network connect ${compose.appName} $(docker ps --filter "name=dokploy-traefik" -q) >/dev/null 2>&1`
|
`docker network connect ${compose.appName} $(docker ps --filter "name=dokploy-traefik" -q) >/dev/null 2>&1`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ export const buildCompose = async (compose: ComposeNested, logPath: string) => {
|
|||||||
|
|
||||||
export const getBuildComposeCommand = async (
|
export const getBuildComposeCommand = async (
|
||||||
compose: ComposeNested,
|
compose: ComposeNested,
|
||||||
logPath: string
|
logPath: string,
|
||||||
) => {
|
) => {
|
||||||
const { COMPOSE_PATH } = paths(true);
|
const { COMPOSE_PATH } = paths(true);
|
||||||
const { sourceType, appName, mounts, composeType, domains, composePath } =
|
const { sourceType, appName, mounts, composeType, domains, composePath } =
|
||||||
@@ -109,7 +109,7 @@ export const getBuildComposeCommand = async (
|
|||||||
const newCompose = await writeDomainsToComposeRemote(
|
const newCompose = await writeDomainsToComposeRemote(
|
||||||
compose,
|
compose,
|
||||||
domains,
|
domains,
|
||||||
logPath
|
logPath,
|
||||||
);
|
);
|
||||||
const logContent = `
|
const logContent = `
|
||||||
App Name: ${appName}
|
App Name: ${appName}
|
||||||
@@ -203,7 +203,7 @@ const createEnvFile = (compose: ComposeNested) => {
|
|||||||
|
|
||||||
const envFileContent = prepareEnvironmentVariables(
|
const envFileContent = prepareEnvironmentVariables(
|
||||||
envContent,
|
envContent,
|
||||||
compose.project.env
|
compose.project.env,
|
||||||
).join("\n");
|
).join("\n");
|
||||||
|
|
||||||
if (!existsSync(dirname(envFilePath))) {
|
if (!existsSync(dirname(envFilePath))) {
|
||||||
@@ -232,7 +232,7 @@ export const getCreateEnvFileCommand = (compose: ComposeNested) => {
|
|||||||
|
|
||||||
const envFileContent = prepareEnvironmentVariables(
|
const envFileContent = prepareEnvironmentVariables(
|
||||||
envContent,
|
envContent,
|
||||||
compose.project.env
|
compose.project.env,
|
||||||
).join("\n");
|
).join("\n");
|
||||||
|
|
||||||
const encodedContent = encodeBase64(envFileContent);
|
const encodedContent = encodeBase64(envFileContent);
|
||||||
@@ -247,7 +247,7 @@ const getExportEnvCommand = (compose: ComposeNested) => {
|
|||||||
|
|
||||||
const envVars = getEnviromentVariablesObject(
|
const envVars = getEnviromentVariablesObject(
|
||||||
compose.env,
|
compose.env,
|
||||||
compose.project.env
|
compose.project.env,
|
||||||
);
|
);
|
||||||
const exports = Object.entries(envVars)
|
const exports = Object.entries(envVars)
|
||||||
.map(([key, value]) => `export ${key}=${JSON.stringify(value)}`)
|
.map(([key, value]) => `export ${key}=${JSON.stringify(value)}`)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import type { ComposeSpecification } from "./types";
|
|||||||
|
|
||||||
export const addAppNameToPreventCollision = (
|
export const addAppNameToPreventCollision = (
|
||||||
composeData: ComposeSpecification,
|
composeData: ComposeSpecification,
|
||||||
appName: string
|
appName: string,
|
||||||
): ComposeSpecification => {
|
): ComposeSpecification => {
|
||||||
let updatedComposeData = { ...composeData };
|
let updatedComposeData = { ...composeData };
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ export const addAppNameToPreventCollision = (
|
|||||||
|
|
||||||
export const randomizeIsolatedDeploymentComposeFile = async (
|
export const randomizeIsolatedDeploymentComposeFile = async (
|
||||||
composeId: string,
|
composeId: string,
|
||||||
suffix?: string
|
suffix?: string,
|
||||||
) => {
|
) => {
|
||||||
const compose = await findComposeById(composeId);
|
const compose = await findComposeById(composeId);
|
||||||
const composeFile = compose.composeFile;
|
const composeFile = compose.composeFile;
|
||||||
@@ -28,7 +28,7 @@ export const randomizeIsolatedDeploymentComposeFile = async (
|
|||||||
|
|
||||||
const newComposeFile = addAppNameToPreventCollision(
|
const newComposeFile = addAppNameToPreventCollision(
|
||||||
composeData,
|
composeData,
|
||||||
randomSuffix
|
randomSuffix,
|
||||||
);
|
);
|
||||||
|
|
||||||
return dump(newComposeFile);
|
return dump(newComposeFile);
|
||||||
@@ -36,7 +36,7 @@ export const randomizeIsolatedDeploymentComposeFile = async (
|
|||||||
|
|
||||||
export const randomizeDeployableSpecificationFile = (
|
export const randomizeDeployableSpecificationFile = (
|
||||||
composeSpec: ComposeSpecification,
|
composeSpec: ComposeSpecification,
|
||||||
suffix?: string
|
suffix?: string,
|
||||||
) => {
|
) => {
|
||||||
if (!suffix) {
|
if (!suffix) {
|
||||||
return composeSpec;
|
return composeSpec;
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ export const getComposePath = (compose: Compose) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const loadDockerCompose = async (
|
export const loadDockerCompose = async (
|
||||||
compose: Compose
|
compose: Compose,
|
||||||
): Promise<ComposeSpecification | null> => {
|
): Promise<ComposeSpecification | null> => {
|
||||||
const path = getComposePath(compose);
|
const path = getComposePath(compose);
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ export const loadDockerCompose = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const loadDockerComposeRemote = async (
|
export const loadDockerComposeRemote = async (
|
||||||
compose: Compose
|
compose: Compose,
|
||||||
): Promise<ComposeSpecification | null> => {
|
): Promise<ComposeSpecification | null> => {
|
||||||
const path = getComposePath(compose);
|
const path = getComposePath(compose);
|
||||||
try {
|
try {
|
||||||
@@ -100,7 +100,7 @@ export const loadDockerComposeRemote = async (
|
|||||||
}
|
}
|
||||||
const { stdout, stderr } = await execAsyncRemote(
|
const { stdout, stderr } = await execAsyncRemote(
|
||||||
compose.serverId,
|
compose.serverId,
|
||||||
`cat ${path}`
|
`cat ${path}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (stderr) {
|
if (stderr) {
|
||||||
@@ -125,7 +125,7 @@ export const readComposeFile = async (compose: Compose) => {
|
|||||||
|
|
||||||
export const writeDomainsToCompose = async (
|
export const writeDomainsToCompose = async (
|
||||||
compose: Compose,
|
compose: Compose,
|
||||||
domains: Domain[]
|
domains: Domain[],
|
||||||
) => {
|
) => {
|
||||||
if (!domains.length) {
|
if (!domains.length) {
|
||||||
return;
|
return;
|
||||||
@@ -144,7 +144,7 @@ export const writeDomainsToCompose = async (
|
|||||||
export const writeDomainsToComposeRemote = async (
|
export const writeDomainsToComposeRemote = async (
|
||||||
compose: Compose,
|
compose: Compose,
|
||||||
domains: Domain[],
|
domains: Domain[],
|
||||||
logPath: string
|
logPath: string,
|
||||||
) => {
|
) => {
|
||||||
if (!domains.length) {
|
if (!domains.length) {
|
||||||
return "";
|
return "";
|
||||||
@@ -175,7 +175,7 @@ exit 1;
|
|||||||
// (node:59875) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGTERM listeners added to [process]. Use emitter.setMaxListeners() to increase limit
|
// (node:59875) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGTERM listeners added to [process]. Use emitter.setMaxListeners() to increase limit
|
||||||
export const addDomainToCompose = async (
|
export const addDomainToCompose = async (
|
||||||
compose: Compose,
|
compose: Compose,
|
||||||
domains: Domain[]
|
domains: Domain[],
|
||||||
) => {
|
) => {
|
||||||
const { appName } = compose;
|
const { appName } = compose;
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ export const addDomainToCompose = async (
|
|||||||
if (compose.isolatedDeployment) {
|
if (compose.isolatedDeployment) {
|
||||||
const randomized = randomizeDeployableSpecificationFile(
|
const randomized = randomizeDeployableSpecificationFile(
|
||||||
result,
|
result,
|
||||||
compose.suffix || compose.appName
|
compose.suffix || compose.appName,
|
||||||
);
|
);
|
||||||
result = randomized;
|
result = randomized;
|
||||||
} else if (compose.randomize) {
|
} else if (compose.randomize) {
|
||||||
@@ -216,7 +216,7 @@ export const addDomainToCompose = async (
|
|||||||
const httpsLabels = await createDomainLabels(
|
const httpsLabels = await createDomainLabels(
|
||||||
appName,
|
appName,
|
||||||
domain,
|
domain,
|
||||||
"websecure"
|
"websecure",
|
||||||
);
|
);
|
||||||
httpLabels.push(...httpsLabels);
|
httpLabels.push(...httpsLabels);
|
||||||
}
|
}
|
||||||
@@ -250,7 +250,7 @@ export const addDomainToCompose = async (
|
|||||||
if (!compose.isolatedDeployment) {
|
if (!compose.isolatedDeployment) {
|
||||||
// Add the dokploy-network to the service
|
// Add the dokploy-network to the service
|
||||||
result.services[serviceName].networks = addDokployNetworkToService(
|
result.services[serviceName].networks = addDokployNetworkToService(
|
||||||
result.services[serviceName].networks
|
result.services[serviceName].networks,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -265,7 +265,7 @@ export const addDomainToCompose = async (
|
|||||||
|
|
||||||
export const writeComposeFile = async (
|
export const writeComposeFile = async (
|
||||||
compose: Compose,
|
compose: Compose,
|
||||||
composeSpec: ComposeSpecification
|
composeSpec: ComposeSpecification,
|
||||||
) => {
|
) => {
|
||||||
const path = getComposePath(compose);
|
const path = getComposePath(compose);
|
||||||
|
|
||||||
@@ -282,7 +282,7 @@ export const writeComposeFile = async (
|
|||||||
export const createDomainLabels = async (
|
export const createDomainLabels = async (
|
||||||
appName: string,
|
appName: string,
|
||||||
domain: Domain,
|
domain: Domain,
|
||||||
entrypoint: "web" | "websecure"
|
entrypoint: "web" | "websecure",
|
||||||
) => {
|
) => {
|
||||||
const { host, port, https, uniqueConfigKey, certificateType, path } = domain;
|
const { host, port, https, uniqueConfigKey, certificateType, path } = domain;
|
||||||
const routerName = `${appName}-${uniqueConfigKey}-${entrypoint}`;
|
const routerName = `${appName}-${uniqueConfigKey}-${entrypoint}`;
|
||||||
@@ -295,14 +295,14 @@ export const createDomainLabels = async (
|
|||||||
|
|
||||||
if (entrypoint === "web" && https) {
|
if (entrypoint === "web" && https) {
|
||||||
labels.push(
|
labels.push(
|
||||||
`traefik.http.routers.${routerName}.middlewares=redirect-to-https@file`
|
`traefik.http.routers.${routerName}.middlewares=redirect-to-https@file`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entrypoint === "websecure") {
|
if (entrypoint === "websecure") {
|
||||||
if (certificateType === "letsencrypt") {
|
if (certificateType === "letsencrypt") {
|
||||||
labels.push(
|
labels.push(
|
||||||
`traefik.http.routers.${routerName}.tls.certresolver=letsencrypt`
|
`traefik.http.routers.${routerName}.tls.certresolver=letsencrypt`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -311,7 +311,7 @@ export const createDomainLabels = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const addDokployNetworkToService = (
|
export const addDokployNetworkToService = (
|
||||||
networkService: DefinitionsService["networks"]
|
networkService: DefinitionsService["networks"],
|
||||||
) => {
|
) => {
|
||||||
let networks = networkService;
|
let networks = networkService;
|
||||||
const network = "dokploy-network";
|
const network = "dokploy-network";
|
||||||
@@ -333,7 +333,7 @@ export const addDokployNetworkToService = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const addDokployNetworkToRoot = (
|
export const addDokployNetworkToRoot = (
|
||||||
networkRoot: PropertiesNetworks | undefined
|
networkRoot: PropertiesNetworks | undefined,
|
||||||
) => {
|
) => {
|
||||||
let networks = networkRoot;
|
let networks = networkRoot;
|
||||||
const network = "dokploy-network";
|
const network = "dokploy-network";
|
||||||
|
|||||||
Reference in New Issue
Block a user