fix: base directory & docker bp
This commit is contained in:
parent
6f57298cbb
commit
a1b49a3a6b
@ -383,7 +383,7 @@ export const setDefaultConfiguration = async (data: any) => {
|
|||||||
if (!publishDirectory) publishDirectory = template?.publishDirectory || null;
|
if (!publishDirectory) publishDirectory = template?.publishDirectory || null;
|
||||||
if (baseDirectory) {
|
if (baseDirectory) {
|
||||||
if (!baseDirectory.startsWith('/')) baseDirectory = `/${baseDirectory}`;
|
if (!baseDirectory.startsWith('/')) baseDirectory = `/${baseDirectory}`;
|
||||||
if (!baseDirectory.endsWith('/')) baseDirectory = `${baseDirectory}/`;
|
if (baseDirectory.endsWith('/') && baseDirectory !== '/') baseDirectory = baseDirectory.slice(0, -1);
|
||||||
}
|
}
|
||||||
if (dockerFileLocation) {
|
if (dockerFileLocation) {
|
||||||
if (!dockerFileLocation.startsWith('/')) dockerFileLocation = `/${dockerFileLocation}`;
|
if (!dockerFileLocation.startsWith('/')) dockerFileLocation = `/${dockerFileLocation}`;
|
||||||
|
@ -14,12 +14,8 @@ export default async function (data) {
|
|||||||
dockerFileLocation
|
dockerFileLocation
|
||||||
} = data
|
} = data
|
||||||
try {
|
try {
|
||||||
const file = `${workdir}${dockerFileLocation}`;
|
const file = `${workdir}${baseDirectory}${dockerFileLocation}`;
|
||||||
let dockerFileOut = `${workdir}`;
|
data.workdir = `${workdir}${baseDirectory}`;
|
||||||
if (baseDirectory) {
|
|
||||||
dockerFileOut = `${workdir}${baseDirectory}`;
|
|
||||||
workdir = `${workdir}${baseDirectory}`;
|
|
||||||
}
|
|
||||||
const Dockerfile: Array<string> = (await fs.readFile(`${file}`, 'utf8'))
|
const Dockerfile: Array<string> = (await fs.readFile(`${file}`, 'utf8'))
|
||||||
.toString()
|
.toString()
|
||||||
.trim()
|
.trim()
|
||||||
@ -28,7 +24,6 @@ export default async function (data) {
|
|||||||
if (secrets.length > 0) {
|
if (secrets.length > 0) {
|
||||||
secrets.forEach((secret) => {
|
secrets.forEach((secret) => {
|
||||||
if (secret.isBuildSecret) {
|
if (secret.isBuildSecret) {
|
||||||
// TODO: fix secrets
|
|
||||||
if (
|
if (
|
||||||
(pullmergeRequestId && secret.isPRMRSecret) ||
|
(pullmergeRequestId && secret.isPRMRSecret) ||
|
||||||
(!pullmergeRequestId && !secret.isPRMRSecret)
|
(!pullmergeRequestId && !secret.isPRMRSecret)
|
||||||
@ -45,7 +40,7 @@ export default async function (data) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await fs.writeFile(`${dockerFileOut}${dockerFileLocation}`, Dockerfile.join('\n'));
|
await fs.writeFile(`${workdir}${dockerFileLocation}`, Dockerfile.join('\n'));
|
||||||
await buildImage(data);
|
await buildImage(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
|
@ -88,39 +88,51 @@ export const asyncExecShellStream = async ({
|
|||||||
const subprocess = execaCommand(command, {
|
const subprocess = execaCommand(command, {
|
||||||
env: { DOCKER_BUILDKIT: '1', DOCKER_HOST: engine }
|
env: { DOCKER_BUILDKIT: '1', DOCKER_HOST: engine }
|
||||||
});
|
});
|
||||||
if (debug) {
|
const logs = [];
|
||||||
subprocess.stdout.on('data', async (data) => {
|
subprocess.stdout.on('data', async (data) => {
|
||||||
const stdout = data.toString();
|
const stdout = data.toString();
|
||||||
const array = stdout.split('\n');
|
const array = stdout.split('\n');
|
||||||
for (const line of array) {
|
for (const line of array) {
|
||||||
if (line !== '\n' && line !== '') {
|
if (line !== '\n' && line !== '') {
|
||||||
debug && await saveBuildLog({
|
const log = {
|
||||||
line: `${line.replace('\n', '')}`,
|
line: `${line.replace('\n', '')}`,
|
||||||
buildId,
|
buildId,
|
||||||
applicationId
|
applicationId
|
||||||
});
|
}
|
||||||
|
logs.push(log);
|
||||||
|
if (debug) {
|
||||||
|
await saveBuildLog(log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
subprocess.stderr.on('data', async (data) => {
|
});
|
||||||
const stderr = data.toString();
|
subprocess.stderr.on('data', async (data) => {
|
||||||
const array = stderr.split('\n');
|
const stderr = data.toString();
|
||||||
for (const line of array) {
|
const array = stderr.split('\n');
|
||||||
if (line !== '\n' && line !== '') {
|
for (const line of array) {
|
||||||
debug && await saveBuildLog({
|
if (line !== '\n' && line !== '') {
|
||||||
line: `${line.replace('\n', '')}`,
|
const log = {
|
||||||
buildId,
|
line: `${line.replace('\n', '')}`,
|
||||||
applicationId
|
buildId,
|
||||||
});
|
applicationId
|
||||||
|
}
|
||||||
|
logs.push(log);
|
||||||
|
if (debug) {
|
||||||
|
await saveBuildLog(log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
subprocess.on('exit', async (code) => {
|
subprocess.on('exit', async (code) => {
|
||||||
await asyncSleep(1000);
|
await asyncSleep(1000);
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
resolve(code);
|
resolve(code);
|
||||||
} else {
|
} else {
|
||||||
|
if (!debug) {
|
||||||
|
for (const log of logs) {
|
||||||
|
await saveBuildLog(log);
|
||||||
|
}
|
||||||
|
}
|
||||||
reject(code);
|
reject(code);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user