mirror of
https://github.com/tiennm99/coolify.git
synced 2026-05-03 20:21:22 +00:00
460ae85226
Just v2
30 lines
895 B
TypeScript
30 lines
895 B
TypeScript
import { buildCacheImageWithNode, buildImage } from '$lib/docker';
|
|
import { promises as fs } from 'fs';
|
|
|
|
const createDockerfile = async (data, image): Promise<void> => {
|
|
const { applicationId, tag, port, startCommand, workdir, baseDirectory } = data;
|
|
const Dockerfile: Array<string> = [];
|
|
|
|
Dockerfile.push(`FROM ${image}`);
|
|
Dockerfile.push('WORKDIR /usr/src/app');
|
|
Dockerfile.push(
|
|
`COPY --from=${applicationId}:${tag}-cache /usr/src/app/${baseDirectory || ''} ./`
|
|
);
|
|
Dockerfile.push(`EXPOSE ${port}`);
|
|
Dockerfile.push(`CMD ${startCommand}`);
|
|
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
|
};
|
|
|
|
export default async function (data) {
|
|
try {
|
|
const image = 'node:lts';
|
|
const imageForBuild = 'node:lts';
|
|
|
|
await buildCacheImageWithNode(data, imageForBuild);
|
|
await createDockerfile(data, image);
|
|
await buildImage(data);
|
|
} catch (error) {
|
|
throw error;
|
|
}
|
|
}
|