2022-08-11 13:20:34 +00:00
|
|
|
import { executeDockerCmd, prisma } from "../common"
|
2022-08-11 16:17:07 +02:00
|
|
|
import { saveBuildLog } from "./common";
|
2022-08-11 13:20:34 +00:00
|
|
|
|
|
|
|
export default async function (data: any): Promise<void> {
|
2022-08-11 16:17:07 +02:00
|
|
|
try {
|
|
|
|
const { buildId, applicationId, tag, dockerId, debug, workdir } = data
|
|
|
|
await saveBuildLog({ line: `Building image started.`, buildId, applicationId });
|
|
|
|
const { stdout } = await executeDockerCmd({
|
|
|
|
dockerId,
|
|
|
|
command: `pack build -p ${workdir} ${applicationId}:${tag} --builder heroku/buildpacks:20`
|
|
|
|
})
|
2022-08-11 13:20:34 +00:00
|
|
|
|
2022-08-11 16:17:07 +02:00
|
|
|
if (debug) {
|
|
|
|
const array = stdout.split('\n')
|
|
|
|
for (const line of array) {
|
|
|
|
if (line !== '\n') {
|
|
|
|
await saveBuildLog({
|
|
|
|
line: `${line.replace('\n', '')}`,
|
|
|
|
buildId,
|
|
|
|
applicationId
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
await saveBuildLog({ line: `Building image successful.`, buildId, applicationId });
|
|
|
|
} catch (error) {
|
|
|
|
throw error;
|
|
|
|
}
|
2022-08-11 13:20:34 +00:00
|
|
|
}
|