fix(builder): fixed issues on non-raw compose and external servers

This commit is contained in:
xenonwellz
2024-11-09 13:00:15 +01:00
parent dafed3096f
commit c9b570e469

View File

@@ -148,32 +148,22 @@ const sanitizeCommand = (command: string) => {
export const createCommand = (compose: ComposeNested) => { export const createCommand = (compose: ComposeNested) => {
const { composeType, appName, sourceType } = compose; const { composeType, appName, sourceType } = compose;
let path = ""; const path =
sourceType === "raw"
if (sourceType === "raw") { ? composeType === "stack"
path =
composeType === "stack"
? "docker-compose.processed.yml" ? "docker-compose.processed.yml"
: "docker-compose.yml"; : "docker-compose.yml"
} else { : composeType === "stack"
path = compose.composePath; ? "docker-compose.processed.yml"
} : compose.composePath;
let command = ""; const baseCommand =
composeType === "docker-compose"
if (composeType === "docker-compose") { ? `compose -p ${appName} -f ${path} up -d --build --remove-orphans`
command = `compose -p ${appName} -f ${path} up -d --build --remove-orphans`; : `stack deploy -c ${path} ${appName} --prune`;
} else if (composeType === "stack") {
command = `stack deploy -c ${path} ${appName} --prune`;
}
const customCommand = sanitizeCommand(compose.command); const customCommand = sanitizeCommand(compose.command);
return customCommand ? `${baseCommand} ${customCommand}` : baseCommand;
if (customCommand) {
command = `${command} ${customCommand}`;
}
return command;
}; };
const createEnvFile = (compose: ComposeNested) => { const createEnvFile = (compose: ComposeNested) => {
@@ -212,12 +202,16 @@ export const processComposeFile = async (compose: ComposeNested) => {
}; };
export const getProcessComposeFileCommand = (compose: ComposeNested) => { export const getProcessComposeFileCommand = (compose: ComposeNested) => {
const { composeType } = compose; const { composeType, sourceType } = compose;
const composePath =
sourceType === "raw" ? "docker-compose.yml" : compose.composePath;
let command = ""; let command = "";
if (composeType === "stack") { if (composeType === "stack") {
command = `export $(grep -v '^#' .env | xargs) && docker stack config -c docker-compose.yml > docker-compose.processed.yml`; command = [
"export $(grep -v '^#' .env | xargs)",
`docker stack config -c ${composePath} > docker-compose.processed.yml`,
].join(" && ");
} }
return command; return command;