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