fix: Deno configurations
This commit is contained in:
parent
14d79031c1
commit
7f8428cd17
@ -92,7 +92,8 @@ export const setDefaultConfiguration = async (data) => {
|
||||
buildCommand,
|
||||
publishDirectory,
|
||||
baseDirectory,
|
||||
dockerFileLocation
|
||||
dockerFileLocation,
|
||||
denoMainFile
|
||||
} = data;
|
||||
const template = scanningTemplates[buildPack];
|
||||
if (!port) {
|
||||
@ -103,9 +104,11 @@ export const setDefaultConfiguration = async (data) => {
|
||||
else if (buildPack === 'php') port = 80;
|
||||
else if (buildPack === 'python') port = 8000;
|
||||
}
|
||||
if (!installCommand) installCommand = template?.installCommand || 'yarn install';
|
||||
if (!startCommand) startCommand = template?.startCommand || 'yarn start';
|
||||
if (!buildCommand) buildCommand = template?.buildCommand || null;
|
||||
if (!installCommand && buildPack !== 'static')
|
||||
installCommand = template?.installCommand || 'yarn install';
|
||||
if (!startCommand && buildPack !== 'static')
|
||||
startCommand = template?.startCommand || 'yarn start';
|
||||
if (!buildCommand && buildPack !== 'static') buildCommand = template?.buildCommand || null;
|
||||
if (!publishDirectory) publishDirectory = template?.publishDirectory || null;
|
||||
if (baseDirectory) {
|
||||
if (!baseDirectory.startsWith('/')) baseDirectory = `/${baseDirectory}`;
|
||||
@ -117,6 +120,9 @@ export const setDefaultConfiguration = async (data) => {
|
||||
} else {
|
||||
dockerFileLocation = '/Dockerfile';
|
||||
}
|
||||
if (!denoMainFile) {
|
||||
denoMainFile = 'main.ts';
|
||||
}
|
||||
|
||||
return {
|
||||
buildPack,
|
||||
@ -126,7 +132,8 @@ export const setDefaultConfiguration = async (data) => {
|
||||
buildCommand,
|
||||
publishDirectory,
|
||||
baseDirectory,
|
||||
dockerFileLocation
|
||||
dockerFileLocation,
|
||||
denoMainFile
|
||||
};
|
||||
};
|
||||
|
||||
@ -192,7 +199,11 @@ export async function copyBaseConfigurationFiles(buildPack, workdir, buildId, ap
|
||||
}
|
||||
`
|
||||
);
|
||||
await saveBuildLog({ line: 'Copied default configuration file.', buildId, applicationId });
|
||||
await saveBuildLog({
|
||||
line: 'Copied default configuration file for Nginx.',
|
||||
buildId,
|
||||
applicationId
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
@ -2,9 +2,16 @@ import { buildImage } from '$lib/docker';
|
||||
import { promises as fs } from 'fs';
|
||||
|
||||
const createDockerfile = async (data, image): Promise<void> => {
|
||||
const { workdir, port, startCommand, baseDirectory, secrets, pullmergeRequestId } = data;
|
||||
const { workdir, port, baseDirectory, secrets, pullmergeRequestId, denoMainFile, denoOptions } =
|
||||
data;
|
||||
const Dockerfile: Array<string> = [];
|
||||
|
||||
let depsFound = false;
|
||||
try {
|
||||
await fs.readFile(`${workdir}${baseDirectory || ''}/deps.ts`);
|
||||
depsFound = true;
|
||||
} catch (error) {}
|
||||
|
||||
Dockerfile.push(`FROM ${image}`);
|
||||
Dockerfile.push('WORKDIR /app');
|
||||
Dockerfile.push(`LABEL coolify.image=true`);
|
||||
@ -23,10 +30,17 @@ const createDockerfile = async (data, image): Promise<void> => {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (depsFound) {
|
||||
Dockerfile.push(`COPY .${baseDirectory || ''}/deps.ts /app`);
|
||||
Dockerfile.push(`RUN deno cache deps.ts`);
|
||||
}
|
||||
console.log(denoOptions && denoOptions.split());
|
||||
Dockerfile.push(`COPY ${denoMainFile} /app`);
|
||||
Dockerfile.push(`RUN deno cache ${denoMainFile}`);
|
||||
Dockerfile.push(`COPY .${baseDirectory || ''} ./`);
|
||||
Dockerfile.push(`ENV NO_COLOR true`);
|
||||
Dockerfile.push(`EXPOSE ${port}`);
|
||||
Dockerfile.push(`CMD ${startCommand}`);
|
||||
Dockerfile.push(`CMD deno run ${denoOptions ? denoOptions.split(' ') : ''} ${denoMainFile}`);
|
||||
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile.join('\n'));
|
||||
};
|
||||
|
||||
|
@ -156,11 +156,11 @@ export function findBuildPack(pack, packageManager = 'npm') {
|
||||
if (pack === 'deno') {
|
||||
return {
|
||||
...metaData,
|
||||
installCommand: `yarn install`,
|
||||
buildCommand: `yarn build`,
|
||||
installCommand: null,
|
||||
buildCommand: null,
|
||||
startCommand: null,
|
||||
publishDirectory: `_site`,
|
||||
port: 80
|
||||
publishDirectory: null,
|
||||
port: 8000
|
||||
};
|
||||
}
|
||||
return {
|
||||
|
@ -264,7 +264,9 @@ export async function configureApplication({
|
||||
pythonWSGI,
|
||||
pythonModule,
|
||||
pythonVariable,
|
||||
dockerFileLocation
|
||||
dockerFileLocation,
|
||||
denoMainFile,
|
||||
denoOptions
|
||||
}: {
|
||||
id: string;
|
||||
buildPack: string;
|
||||
@ -280,6 +282,8 @@ export async function configureApplication({
|
||||
pythonModule: string;
|
||||
pythonVariable: string;
|
||||
dockerFileLocation: string;
|
||||
denoMainFile: string;
|
||||
denoOptions: string;
|
||||
}): Promise<Application> {
|
||||
return await prisma.application.update({
|
||||
where: { id },
|
||||
@ -296,7 +300,9 @@ export async function configureApplication({
|
||||
pythonWSGI,
|
||||
pythonModule,
|
||||
pythonVariable,
|
||||
dockerFileLocation
|
||||
dockerFileLocation,
|
||||
denoMainFile,
|
||||
denoOptions
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -46,7 +46,8 @@ export default async function (job: Job<BuilderJob, void, string>): Promise<void
|
||||
persistentStorage,
|
||||
pythonWSGI,
|
||||
pythonModule,
|
||||
pythonVariable
|
||||
pythonVariable,
|
||||
denoOptions
|
||||
} = job.data;
|
||||
let {
|
||||
branch,
|
||||
@ -57,7 +58,8 @@ export default async function (job: Job<BuilderJob, void, string>): Promise<void
|
||||
startCommand,
|
||||
baseDirectory,
|
||||
publishDirectory,
|
||||
dockerFileLocation
|
||||
dockerFileLocation,
|
||||
denoMainFile
|
||||
} = job.data;
|
||||
const { debug } = settings;
|
||||
|
||||
@ -109,6 +111,7 @@ export default async function (job: Job<BuilderJob, void, string>): Promise<void
|
||||
publishDirectory = configuration.publishDirectory;
|
||||
baseDirectory = configuration.baseDirectory;
|
||||
dockerFileLocation = configuration.dockerFileLocation;
|
||||
denoMainFile = configuration.denoMainFile;
|
||||
|
||||
const commit = await importers[gitSource.type]({
|
||||
applicationId,
|
||||
@ -212,7 +215,9 @@ export default async function (job: Job<BuilderJob, void, string>): Promise<void
|
||||
pythonWSGI,
|
||||
pythonModule,
|
||||
pythonVariable,
|
||||
dockerFileLocation
|
||||
dockerFileLocation,
|
||||
denoMainFile,
|
||||
denoOptions
|
||||
});
|
||||
else {
|
||||
await saveBuildLog({ line: `Build pack ${buildPack} not found`, buildId, applicationId });
|
||||
|
@ -22,6 +22,8 @@ export type BuilderJob = {
|
||||
pythonModule: string;
|
||||
pythonVariable: string;
|
||||
dockerFileLocation: string;
|
||||
denoMainFile: string;
|
||||
denoOptions: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
destinationDockerId: string;
|
||||
|
Loading…
x
Reference in New Issue
Block a user