feat(database): add isolatedDeploymentsVolume column to compose table

- Introduced a new boolean column "isolatedDeploymentsVolume" to the "compose" table with a default value of false.
- Updated existing records to set "isolatedDeploymentsVolume" to true.
- Modified related functions to handle the new column for improved deployment isolation management.
This commit is contained in:
Mauricio Siu
2025-07-06 18:46:36 -06:00
parent e050c218e2
commit 76603f598c
6 changed files with 6156 additions and 1 deletions
@@ -0,0 +1,3 @@
ALTER TABLE "compose" ADD COLUMN "isolatedDeploymentsVolume" boolean DEFAULT false NOT NULL;
UPDATE "compose" SET "isolatedDeploymentsVolume" = true;
File diff suppressed because it is too large Load Diff
+7
View File
@@ -715,6 +715,13 @@
"when": 1751751631943, "when": 1751751631943,
"tag": "0101_moaning_blazing_skull", "tag": "0101_moaning_blazing_skull",
"breakpoints": true "breakpoints": true
},
{
"idx": 102,
"version": "7",
"when": 1751848685503,
"tag": "0102_opposite_grandmaster",
"breakpoints": true
} }
] ]
} }
+4
View File
@@ -79,6 +79,10 @@ export const compose = pgTable("compose", {
suffix: text("suffix").notNull().default(""), suffix: text("suffix").notNull().default(""),
randomize: boolean("randomize").notNull().default(false), randomize: boolean("randomize").notNull().default(false),
isolatedDeployment: boolean("isolatedDeployment").notNull().default(false), isolatedDeployment: boolean("isolatedDeployment").notNull().default(false),
// Keep this for backward compatibility since we will not add the prefix anymore to volumes
isolatedDeploymentsVolume: boolean("isolatedDeploymentsVolume")
.notNull()
.default(false),
triggerType: triggerType("triggerType").default("push"), triggerType: triggerType("triggerType").default("push"),
composeStatus: applicationStatus("composeStatus").notNull().default("idle"), composeStatus: applicationStatus("composeStatus").notNull().default("idle"),
projectId: text("projectId") projectId: text("projectId")
+12 -1
View File
@@ -1,16 +1,21 @@
import { findComposeById } from "@dokploy/server/services/compose"; import { findComposeById } from "@dokploy/server/services/compose";
import { dump, load } from "js-yaml"; import { dump, load } from "js-yaml";
import { addAppNameToAllServiceNames } from "./collision/root-network"; import { addAppNameToAllServiceNames } from "./collision/root-network";
import { addSuffixToAllVolumes } from "./compose/volume";
import { generateRandomHash } from "./compose"; import { generateRandomHash } from "./compose";
import type { ComposeSpecification } from "./types"; import type { ComposeSpecification } from "./types";
export const addAppNameToPreventCollision = ( export const addAppNameToPreventCollision = (
composeData: ComposeSpecification, composeData: ComposeSpecification,
appName: string, appName: string,
isolatedDeploymentsVolume: boolean,
): ComposeSpecification => { ): ComposeSpecification => {
let updatedComposeData = { ...composeData }; let updatedComposeData = { ...composeData };
updatedComposeData = addAppNameToAllServiceNames(updatedComposeData, appName); updatedComposeData = addAppNameToAllServiceNames(updatedComposeData, appName);
if (isolatedDeploymentsVolume) {
updatedComposeData = addSuffixToAllVolumes(updatedComposeData, appName);
}
return updatedComposeData; return updatedComposeData;
}; };
@@ -27,6 +32,7 @@ export const randomizeIsolatedDeploymentComposeFile = async (
const newComposeFile = addAppNameToPreventCollision( const newComposeFile = addAppNameToPreventCollision(
composeData, composeData,
randomSuffix, randomSuffix,
compose.isolatedDeploymentsVolume,
); );
return dump(newComposeFile); return dump(newComposeFile);
@@ -34,11 +40,16 @@ export const randomizeIsolatedDeploymentComposeFile = async (
export const randomizeDeployableSpecificationFile = ( export const randomizeDeployableSpecificationFile = (
composeSpec: ComposeSpecification, composeSpec: ComposeSpecification,
isolatedDeploymentsVolume: boolean,
suffix?: string, suffix?: string,
) => { ) => {
if (!suffix) { if (!suffix) {
return composeSpec; return composeSpec;
} }
const newComposeFile = addAppNameToPreventCollision(composeSpec, suffix); const newComposeFile = addAppNameToPreventCollision(
composeSpec,
suffix,
isolatedDeploymentsVolume,
);
return newComposeFile; return newComposeFile;
}; };
@@ -202,6 +202,7 @@ export const addDomainToCompose = async (
if (compose.isolatedDeployment) { if (compose.isolatedDeployment) {
const randomized = randomizeDeployableSpecificationFile( const randomized = randomizeDeployableSpecificationFile(
result, result,
compose.isolatedDeploymentsVolume,
compose.suffix || compose.appName, compose.suffix || compose.appName,
); );
result = randomized; result = randomized;