Skip to content

Commit a7bde65

Browse files
authored
Merge pull request #2289 from Dokploy/2282-custom-compose-path-not-being-used-when-manually-restarting-service
refactor(compose): reorganize imports and simplify command execution …
2 parents b5b63ea + 295b6df commit a7bde65

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

packages/server/src/services/compose.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import { join } from "node:path";
22
import { paths } from "@dokploy/server/constants";
33
import { db } from "@dokploy/server/db";
4-
import { type apiCreateCompose, compose } from "@dokploy/server/db/schema";
5-
import { buildAppName, cleanAppName } from "@dokploy/server/db/schema";
4+
import {
5+
type apiCreateCompose,
6+
buildAppName,
7+
cleanAppName,
8+
compose,
9+
} from "@dokploy/server/db/schema";
610
import {
711
buildCompose,
812
getBuildComposeCommand,
@@ -516,19 +520,20 @@ export const startCompose = async (composeId: string) => {
516520
const compose = await findComposeById(composeId);
517521
try {
518522
const { COMPOSE_PATH } = paths(!!compose.serverId);
523+
524+
const projectPath = join(COMPOSE_PATH, compose.appName, "code");
525+
const path =
526+
compose.sourceType === "raw" ? "docker-compose.yml" : compose.composePath;
527+
const baseCommand = `docker compose -p ${compose.appName} -f ${path} up -d`;
519528
if (compose.composeType === "docker-compose") {
520529
if (compose.serverId) {
521530
await execAsyncRemote(
522531
compose.serverId,
523-
`cd ${join(
524-
COMPOSE_PATH,
525-
compose.appName,
526-
"code",
527-
)} && docker compose -p ${compose.appName} up -d`,
532+
`cd ${projectPath} && ${baseCommand}`,
528533
);
529534
} else {
530-
await execAsync(`docker compose -p ${compose.appName} up -d`, {
531-
cwd: join(COMPOSE_PATH, compose.appName, "code"),
535+
await execAsync(baseCommand, {
536+
cwd: projectPath,
532537
});
533538
}
534539
}

0 commit comments

Comments
 (0)