mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: update
This commit is contained in:
@@ -221,9 +221,7 @@ const Service = (
|
|||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<TabsTrigger value="general">General</TabsTrigger>
|
<TabsTrigger value="general">General</TabsTrigger>
|
||||||
{/* {data?.composeType === "docker-compose" && ( */}
|
|
||||||
<TabsTrigger value="environment">Environment</TabsTrigger>
|
<TabsTrigger value="environment">Environment</TabsTrigger>
|
||||||
{/* )} */}
|
|
||||||
{!data?.serverId && (
|
{!data?.serverId && (
|
||||||
<TabsTrigger value="monitoring">Monitoring</TabsTrigger>
|
<TabsTrigger value="monitoring">Monitoring</TabsTrigger>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ export const buildCompose = async (compose: ComposeNested, logPath: string) => {
|
|||||||
...getEnviromentVariablesObject(compose.env, compose.project.env),
|
...getEnviromentVariablesObject(compose.env, compose.project.env),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
writeStream.write("Docker Compose Deployed: ✅");
|
writeStream.write("Docker Compose Deployed: ✅");
|
||||||
@@ -84,7 +84,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 } =
|
||||||
@@ -97,7 +97,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}
|
||||||
@@ -189,7 +189,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))) {
|
||||||
@@ -218,7 +218,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);
|
||||||
@@ -231,7 +231,10 @@ echo "${encodedContent}" | base64 -d > "${envFilePath}";
|
|||||||
const getExportEnvCommand = (compose: ComposeNested) => {
|
const getExportEnvCommand = (compose: ComposeNested) => {
|
||||||
if (compose.composeType !== "stack") return "";
|
if (compose.composeType !== "stack") return "";
|
||||||
|
|
||||||
const envVars = getEnviromentVariablesObject(compose.env, compose.project.env);
|
const envVars = getEnviromentVariablesObject(
|
||||||
|
compose.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)}`)
|
||||||
.join("\n");
|
.join("\n");
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ interface RegistryAuth {
|
|||||||
export const pullImage = async (
|
export const pullImage = async (
|
||||||
dockerImage: string,
|
dockerImage: string,
|
||||||
onData?: (data: any) => void,
|
onData?: (data: any) => void,
|
||||||
authConfig?: Partial<RegistryAuth>
|
authConfig?: Partial<RegistryAuth>,
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
if (!dockerImage) {
|
if (!dockerImage) {
|
||||||
@@ -41,7 +41,7 @@ export const pullImage = async (
|
|||||||
"-p",
|
"-p",
|
||||||
authConfig.password,
|
authConfig.password,
|
||||||
],
|
],
|
||||||
onData
|
onData,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
await spawnAsync("docker", ["pull", dockerImage], onData);
|
await spawnAsync("docker", ["pull", dockerImage], onData);
|
||||||
@@ -54,7 +54,7 @@ export const pullRemoteImage = async (
|
|||||||
dockerImage: string,
|
dockerImage: string,
|
||||||
serverId: string,
|
serverId: string,
|
||||||
onData?: (data: any) => void,
|
onData?: (data: any) => void,
|
||||||
authConfig?: Partial<RegistryAuth>
|
authConfig?: Partial<RegistryAuth>,
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
if (!dockerImage) {
|
if (!dockerImage) {
|
||||||
@@ -85,9 +85,9 @@ export const pullRemoteImage = async (
|
|||||||
},
|
},
|
||||||
(event) => {
|
(event) => {
|
||||||
onData?.(event);
|
onData?.(event);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -188,7 +188,7 @@ export const cleanUpInactiveContainers = async () => {
|
|||||||
try {
|
try {
|
||||||
const containers = await docker.listContainers({ all: true });
|
const containers = await docker.listContainers({ all: true });
|
||||||
const inactiveContainers = containers.filter(
|
const inactiveContainers = containers.filter(
|
||||||
(container) => container.State !== "running"
|
(container) => container.State !== "running",
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const container of inactiveContainers) {
|
for (const container of inactiveContainers) {
|
||||||
@@ -240,7 +240,7 @@ export const startServiceRemote = async (serverId: string, appName: string) => {
|
|||||||
export const removeService = async (
|
export const removeService = async (
|
||||||
appName: string,
|
appName: string,
|
||||||
serverId?: string | null,
|
serverId?: string | null,
|
||||||
deleteVolumes = false
|
deleteVolumes = false,
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const command = `docker service rm ${appName}`;
|
const command = `docker service rm ${appName}`;
|
||||||
@@ -257,7 +257,7 @@ export const removeService = async (
|
|||||||
|
|
||||||
export const prepareEnvironmentVariables = (
|
export const prepareEnvironmentVariables = (
|
||||||
serviceEnv: string | null,
|
serviceEnv: string | null,
|
||||||
projectEnv?: string | null
|
projectEnv?: string | null,
|
||||||
) => {
|
) => {
|
||||||
const projectVars = parse(projectEnv ?? "");
|
const projectVars = parse(projectEnv ?? "");
|
||||||
const serviceVars = parse(serviceEnv ?? "");
|
const serviceVars = parse(serviceEnv ?? "");
|
||||||
@@ -280,7 +280,7 @@ export const prepareEnvironmentVariables = (
|
|||||||
|
|
||||||
export const getEnviromentVariablesObject = (
|
export const getEnviromentVariablesObject = (
|
||||||
input: string | null,
|
input: string | null,
|
||||||
projectEnv?: string | null
|
projectEnv?: string | null,
|
||||||
) => {
|
) => {
|
||||||
const envs = prepareEnvironmentVariables(input, projectEnv);
|
const envs = prepareEnvironmentVariables(input, projectEnv);
|
||||||
|
|
||||||
@@ -430,7 +430,7 @@ export const generateFileMounts = (
|
|||||||
| MariadbNested
|
| MariadbNested
|
||||||
| MysqlNested
|
| MysqlNested
|
||||||
| PostgresNested
|
| PostgresNested
|
||||||
| RedisNested
|
| RedisNested,
|
||||||
) => {
|
) => {
|
||||||
const { mounts } = service;
|
const { mounts } = service;
|
||||||
const { APPLICATIONS_PATH } = paths(!!service.serverId);
|
const { APPLICATIONS_PATH } = paths(!!service.serverId);
|
||||||
@@ -456,7 +456,7 @@ export const generateFileMounts = (
|
|||||||
export const createFile = async (
|
export const createFile = async (
|
||||||
outputPath: string,
|
outputPath: string,
|
||||||
filePath: string,
|
filePath: string,
|
||||||
content: string
|
content: string,
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const fullPath = path.join(outputPath, filePath);
|
const fullPath = path.join(outputPath, filePath);
|
||||||
@@ -478,7 +478,7 @@ export const encodeBase64 = (content: string) =>
|
|||||||
export const getCreateFileCommand = (
|
export const getCreateFileCommand = (
|
||||||
outputPath: string,
|
outputPath: string,
|
||||||
filePath: string,
|
filePath: string,
|
||||||
content: string
|
content: string,
|
||||||
) => {
|
) => {
|
||||||
const fullPath = path.join(outputPath, filePath);
|
const fullPath = path.join(outputPath, filePath);
|
||||||
if (fullPath.endsWith(path.sep) || filePath.endsWith("/")) {
|
if (fullPath.endsWith(path.sep) || filePath.endsWith("/")) {
|
||||||
@@ -518,7 +518,7 @@ export const getServiceContainer = async (appName: string) => {
|
|||||||
|
|
||||||
export const getRemoteServiceContainer = async (
|
export const getRemoteServiceContainer = async (
|
||||||
serverId: string,
|
serverId: string,
|
||||||
appName: string
|
appName: string,
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const filter = {
|
const filter = {
|
||||||
|
|||||||
Reference in New Issue
Block a user