feat: init heroku buildpacks

This commit is contained in:
Andras Bacsai 2022-08-11 16:17:07 +02:00
parent de4c195641
commit 3f7cd317d6
3 changed files with 34 additions and 19 deletions

View File

@ -192,8 +192,8 @@ import * as buildpacks from '../lib/buildPacks';
} catch (error) { } catch (error) {
// //
} }
// if (!imageFound || deployNeeded) { if (!imageFound || deployNeeded) {
if (true) { // if (true) {
await copyBaseConfigurationFiles(buildPack, workdir, buildId, applicationId, baseImage); await copyBaseConfigurationFiles(buildPack, workdir, buildId, applicationId, baseImage);
if (buildpacks[buildPack]) if (buildpacks[buildPack])
await buildpacks[buildPack]({ await buildpacks[buildPack]({
@ -303,6 +303,7 @@ import * as buildpacks from '../lib/buildPacks';
labels, labels,
depends_on: [], depends_on: [],
restart: 'always', restart: 'always',
expose: [port],
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}), ...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
// logging: { // logging: {
// driver: 'fluentd', // driver: 'fluentd',

View File

@ -1,15 +1,29 @@
import { executeDockerCmd, prisma } from "../common" import { executeDockerCmd, prisma } from "../common"
import { saveBuildLog } from "./common";
export default async function (data: any): Promise<void> { export default async function (data: any): Promise<void> {
// console.log(data) try {
const {applicationId, tag, dockerId} = data const { buildId, applicationId, tag, dockerId, debug, workdir } = data
// try { await saveBuildLog({ line: `Building image started.`, buildId, applicationId });
await executeDockerCmd({ const { stdout } = await executeDockerCmd({
dockerId, dockerId,
command: `pack build ${applicationId}:${tag} --builder heroku/buildpacks:20` command: `pack build -p ${workdir} ${applicationId}:${tag} --builder heroku/buildpacks:20`
}) })
// } catch (error) { if (debug) {
// throw error; 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;
}
} }

View File

@ -292,13 +292,13 @@ export const buildPacks = [
fancyName: 'Deno', fancyName: 'Deno',
hoverColor: 'hover:bg-green-700', hoverColor: 'hover:bg-green-700',
color: 'bg-green-700' color: 'bg-green-700'
}, // },
{ // {
name: 'heroku', // name: 'heroku',
fancyName: 'Heroku Buildpack', // fancyName: 'Heroku Buildpack',
hoverColor: 'hover:bg-indigo-700', // hoverColor: 'hover:bg-indigo-700',
color: 'bg-indigo-700' // color: 'bg-indigo-700'
} // }
]; ];
export const scanningTemplates = { export const scanningTemplates = {
'@sveltejs/kit': { '@sveltejs/kit': {