mirror of
https://github.com/cupcakearmy/coolify.git
synced 2024-10-23 00:24:15 +02:00
fix: Add git lfs while deploying
This commit is contained in:
parent
3ef093c7e6
commit
32020fd336
@ -11,7 +11,7 @@ WORKDIR /app
|
|||||||
|
|
||||||
LABEL coolify.managed true
|
LABEL coolify.managed true
|
||||||
|
|
||||||
RUN apk add --no-cache git openssh-client curl jq cmake sqlite
|
RUN apk add --no-cache git git-lfs openssh-client curl jq cmake sqlite
|
||||||
|
|
||||||
RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6
|
RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6
|
||||||
RUN pnpm add -g pnpm
|
RUN pnpm add -g pnpm
|
||||||
|
@ -46,11 +46,30 @@ const customConfig: Config = {
|
|||||||
export const version = currentVersion;
|
export const version = currentVersion;
|
||||||
export const asyncExecShell = util.promisify(child.exec);
|
export const asyncExecShell = util.promisify(child.exec);
|
||||||
export const asyncSleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay));
|
export const asyncSleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay));
|
||||||
|
export const asyncUntil = (condition, delay, maxIterations) => {
|
||||||
|
return new Promise<void>(async (resolve, reject) => {
|
||||||
|
let iterations = 0;
|
||||||
|
while (!condition()) {
|
||||||
|
if (maxIterations && iterations >= maxIterations) {
|
||||||
|
reject(new Error('Max iterations reached.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await asyncSleep(delay);
|
||||||
|
iterations++;
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export const sentry = Sentry;
|
export const sentry = Sentry;
|
||||||
|
|
||||||
export const uniqueName = () => uniqueNamesGenerator(customConfig);
|
export const uniqueName = () => uniqueNamesGenerator(customConfig);
|
||||||
|
|
||||||
export const saveBuildLog = async ({ line, buildId, applicationId }) => {
|
export const saveBuildLog = async ({ line, buildId, applicationId }) => {
|
||||||
|
if (line.includes('ghs_')) {
|
||||||
|
const regex = /ghs_.*@/g;
|
||||||
|
line = line.replace(regex, '<SENSITIVE_DATA_DELETED>@');
|
||||||
|
}
|
||||||
const addTimestamp = `${generateTimestamp()} ${line}`;
|
const addTimestamp = `${generateTimestamp()} ${line}`;
|
||||||
return await buildLogQueue.add(buildId, { buildId, line: addTimestamp, applicationId });
|
return await buildLogQueue.add(buildId, { buildId, line: addTimestamp, applicationId });
|
||||||
};
|
};
|
||||||
|
@ -15,7 +15,6 @@ export default async function ({
|
|||||||
branch,
|
branch,
|
||||||
buildId
|
buildId
|
||||||
}): Promise<any> {
|
}): Promise<any> {
|
||||||
try {
|
|
||||||
const url = htmlUrl.replace('https://', '').replace('http://', '');
|
const url = htmlUrl.replace('https://', '').replace('http://', '');
|
||||||
await saveBuildLog({ line: 'GitHub importer started.', buildId, applicationId });
|
await saveBuildLog({ line: 'GitHub importer started.', buildId, applicationId });
|
||||||
const { privateKey, appId, installationId } = await db.getUniqueGithubApp({ githubAppId });
|
const { privateKey, appId, installationId } = await db.getUniqueGithubApp({ githubAppId });
|
||||||
@ -43,12 +42,8 @@ export default async function ({
|
|||||||
applicationId
|
applicationId
|
||||||
});
|
});
|
||||||
await asyncExecShell(
|
await asyncExecShell(
|
||||||
`git clone -q -b ${branch} https://x-access-token:${token}@${url}/${repository}.git ${workdir}/ && cd ${workdir} && git submodule update --init --recursive && cd ..`
|
`git clone -q -b ${branch} https://x-access-token:${token}@${url}/${repository}.git ${workdir}/ && cd ${workdir} && git submodule update --init --recursive && git lfs pull && cd .. `
|
||||||
);
|
);
|
||||||
const { stdout: commit } = await asyncExecShell(`cd ${workdir}/ && git rev-parse HEAD`);
|
const { stdout: commit } = await asyncExecShell(`cd ${workdir}/ && git rev-parse HEAD`);
|
||||||
return commit.replace('\n', '');
|
return commit.replace('\n', '');
|
||||||
} catch (error) {
|
|
||||||
console.log({ error });
|
|
||||||
return ErrorHandler(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ export default async function ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
await asyncExecShell(
|
await asyncExecShell(
|
||||||
`git clone -q -b ${branch} git@${url}:${repository}.git --config core.sshCommand="ssh -q -i ${repodir}id.rsa -o StrictHostKeyChecking=no" ${workdir}/ && cd ${workdir}/ && git submodule update --init --recursive && cd ..`
|
`git clone -q -b ${branch} git@${url}:${repository}.git --config core.sshCommand="ssh -q -i ${repodir}id.rsa -o StrictHostKeyChecking=no" ${workdir}/ && cd ${workdir}/ && git submodule update --init --recursive && git lfs pull && cd .. `
|
||||||
);
|
);
|
||||||
const { stdout: commit } = await asyncExecShell(`cd ${workdir}/ && git rev-parse HEAD`);
|
const { stdout: commit } = await asyncExecShell(`cd ${workdir}/ && git rev-parse HEAD`);
|
||||||
return commit.replace('\n', '');
|
return commit.replace('\n', '');
|
||||||
|
@ -11,7 +11,7 @@ import proxy from './proxy';
|
|||||||
import ssl from './ssl';
|
import ssl from './ssl';
|
||||||
import sslrenewal from './sslrenewal';
|
import sslrenewal from './sslrenewal';
|
||||||
|
|
||||||
import { asyncExecShell, saveBuildLog } from '$lib/common';
|
import { asyncExecShell, asyncUntil, saveBuildLog } from '$lib/common';
|
||||||
|
|
||||||
let { Queue, Worker } = Bullmq;
|
let { Queue, Worker } = Bullmq;
|
||||||
let redisHost = 'localhost';
|
let redisHost = 'localhost';
|
||||||
@ -128,7 +128,22 @@ buildWorker.on('completed', async (job: Bullmq.Job) => {
|
|||||||
|
|
||||||
buildWorker.on('failed', async (job: Bullmq.Job, failedReason) => {
|
buildWorker.on('failed', async (job: Bullmq.Job, failedReason) => {
|
||||||
try {
|
try {
|
||||||
await prisma.build.update({ where: { id: job.data.build_id }, data: { status: 'failed' } });
|
await asyncUntil(
|
||||||
|
async () => {
|
||||||
|
const found = await prisma.build.findFirst({
|
||||||
|
where: { id: job.data.build_id, status: 'failed' }
|
||||||
|
});
|
||||||
|
if (!found) {
|
||||||
|
return await prisma.build.update({
|
||||||
|
where: { id: job.data.build_id },
|
||||||
|
data: { status: 'failed' }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
200,
|
||||||
|
5
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
Reference in New Issue
Block a user