WIP: Base image selector
This commit is contained in:
@@ -105,6 +105,7 @@ model Application {
|
|||||||
gitSource GitSource? @relation(fields: [gitSourceId], references: [id])
|
gitSource GitSource? @relation(fields: [gitSourceId], references: [id])
|
||||||
secrets Secret[]
|
secrets Secret[]
|
||||||
persistentStorage ApplicationPersistentStorage[]
|
persistentStorage ApplicationPersistentStorage[]
|
||||||
|
baseImage String?
|
||||||
}
|
}
|
||||||
|
|
||||||
model ApplicationSettings {
|
model ApplicationSettings {
|
||||||
|
|||||||
@@ -12,6 +12,17 @@ import type {
|
|||||||
Application,
|
Application,
|
||||||
ApplicationPersistentStorage
|
ApplicationPersistentStorage
|
||||||
} from '@prisma/client';
|
} from '@prisma/client';
|
||||||
|
const nodeBased = [
|
||||||
|
'react',
|
||||||
|
'vuejs',
|
||||||
|
'static',
|
||||||
|
'svelte',
|
||||||
|
'gatsby',
|
||||||
|
'php',
|
||||||
|
'astro',
|
||||||
|
'eleventy',
|
||||||
|
'node'
|
||||||
|
];
|
||||||
|
|
||||||
export async function listApplications(teamId: string): Promise<Application[]> {
|
export async function listApplications(teamId: string): Promise<Application[]> {
|
||||||
if (teamId === '0') {
|
if (teamId === '0') {
|
||||||
@@ -195,6 +206,24 @@ export async function getApplication({ id, teamId }: { id: string; teamId: strin
|
|||||||
return s;
|
return s;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// Set default build images
|
||||||
|
if (!body.baseImage) {
|
||||||
|
if (nodeBased.includes(body.buildPack)) {
|
||||||
|
body.baseImage = 'node:lts';
|
||||||
|
}
|
||||||
|
if (body.buildPack === 'python') {
|
||||||
|
body.baseImage = 'python:3-alpine';
|
||||||
|
}
|
||||||
|
if (body.buildPack === 'rust') {
|
||||||
|
body.baseImage = 'rust:latest';
|
||||||
|
}
|
||||||
|
if (body.buildPack === 'deno') {
|
||||||
|
body.baseImage = 'denoland/deno:latest';
|
||||||
|
}
|
||||||
|
if (body.buildPack === 'php') {
|
||||||
|
body.baseImage = 'webdevops/php-apache:8.0-alpine';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return { ...body };
|
return { ...body };
|
||||||
}
|
}
|
||||||
@@ -266,7 +295,8 @@ export async function configureApplication({
|
|||||||
pythonVariable,
|
pythonVariable,
|
||||||
dockerFileLocation,
|
dockerFileLocation,
|
||||||
denoMainFile,
|
denoMainFile,
|
||||||
denoOptions
|
denoOptions,
|
||||||
|
baseImage
|
||||||
}: {
|
}: {
|
||||||
id: string;
|
id: string;
|
||||||
buildPack: string;
|
buildPack: string;
|
||||||
@@ -284,6 +314,7 @@ export async function configureApplication({
|
|||||||
dockerFileLocation: string;
|
dockerFileLocation: string;
|
||||||
denoMainFile: string;
|
denoMainFile: string;
|
||||||
denoOptions: string;
|
denoOptions: string;
|
||||||
|
baseImage: string;
|
||||||
}): Promise<Application> {
|
}): Promise<Application> {
|
||||||
return await prisma.application.update({
|
return await prisma.application.update({
|
||||||
where: { id },
|
where: { id },
|
||||||
@@ -302,7 +333,8 @@ export async function configureApplication({
|
|||||||
pythonVariable,
|
pythonVariable,
|
||||||
dockerFileLocation,
|
dockerFileLocation,
|
||||||
denoMainFile,
|
denoMainFile,
|
||||||
denoOptions
|
denoOptions,
|
||||||
|
baseImage
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,10 +41,11 @@ export async function buildCacheImageWithNode(data, imageForBuild) {
|
|||||||
Dockerfile.push('RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm');
|
Dockerfile.push('RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm');
|
||||||
Dockerfile.push('RUN pnpm add -g pnpm');
|
Dockerfile.push('RUN pnpm add -g pnpm');
|
||||||
}
|
}
|
||||||
Dockerfile.push(`COPY .${baseDirectory || ''} ./`);
|
|
||||||
if (installCommand) {
|
if (installCommand) {
|
||||||
|
Dockerfile.push(`COPY .${baseDirectory || ''}/package.json ./`);
|
||||||
Dockerfile.push(`RUN ${installCommand}`);
|
Dockerfile.push(`RUN ${installCommand}`);
|
||||||
}
|
}
|
||||||
|
Dockerfile.push(`COPY .${baseDirectory || ''} ./`);
|
||||||
Dockerfile.push(`RUN ${buildCommand}`);
|
Dockerfile.push(`RUN ${buildCommand}`);
|
||||||
await fs.writeFile(`${workdir}/Dockerfile-cache`, Dockerfile.join('\n'));
|
await fs.writeFile(`${workdir}/Dockerfile-cache`, Dockerfile.join('\n'));
|
||||||
await buildImage({ applicationId, tag, workdir, docker, buildId, isCache: true, debug });
|
await buildImage({ applicationId, tag, workdir, docker, buildId, isCache: true, debug });
|
||||||
|
|||||||
@@ -124,7 +124,7 @@
|
|||||||
"no_branches_found": "No branches found",
|
"no_branches_found": "No branches found",
|
||||||
"configure_build_pack": "Configure Build Pack",
|
"configure_build_pack": "Configure Build Pack",
|
||||||
"scanning_repository_suggest_build_pack": "Scanning repository to suggest a build pack for you...",
|
"scanning_repository_suggest_build_pack": "Scanning repository to suggest a build pack for you...",
|
||||||
"found_lock_file": "Found lock file for <span class=\"font-bold text-orange-500 pl-1\">{{packageManager}}</span>. Using it for predefined commands commands.",
|
"found_lock_file": "Found lock file for <span class=\"font-bold text-orange-500 px-1\"> {{packageManager}}</span>.Using it for predefined commands commands.",
|
||||||
"configure_destination": "Configure Destination",
|
"configure_destination": "Configure Destination",
|
||||||
"no_configurable_destination": "No configurable Destination found",
|
"no_configurable_destination": "No configurable Destination found",
|
||||||
"select_a_repository_project": "Select a Repository / Project",
|
"select_a_repository_project": "Select a Repository / Project",
|
||||||
@@ -184,6 +184,7 @@
|
|||||||
"git_source": "Git Source",
|
"git_source": "Git Source",
|
||||||
"git_repository": "Git Repository",
|
"git_repository": "Git Repository",
|
||||||
"build_pack": "Build Pack",
|
"build_pack": "Build Pack",
|
||||||
|
"base_image": "Base Image",
|
||||||
"destination": "Destination",
|
"destination": "Destination",
|
||||||
"application": "Application",
|
"application": "Application",
|
||||||
"url_fqdn": "URL (FQDN)",
|
"url_fqdn": "URL (FQDN)",
|
||||||
|
|||||||
@@ -225,7 +225,7 @@
|
|||||||
<div class="max-w-7xl mx-auto flex flex-wrap justify-center">
|
<div class="max-w-7xl mx-auto flex flex-wrap justify-center">
|
||||||
{#each buildPacks as buildPack}
|
{#each buildPacks as buildPack}
|
||||||
<div class="p-2">
|
<div class="p-2">
|
||||||
<BuildPack {buildPack} {scanning} bind:foundConfig />
|
<BuildPack {packageManager} {buildPack} {scanning} bind:foundConfig />
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ export const post: RequestHandler = async (event) => {
|
|||||||
pythonVariable,
|
pythonVariable,
|
||||||
dockerFileLocation,
|
dockerFileLocation,
|
||||||
denoMainFile,
|
denoMainFile,
|
||||||
denoOptions
|
denoOptions,
|
||||||
|
baseImage
|
||||||
} = await event.request.json();
|
} = await event.request.json();
|
||||||
if (port) port = Number(port);
|
if (port) port = Number(port);
|
||||||
if (denoOptions) denoOptions = denoOptions.trim();
|
if (denoOptions) denoOptions = denoOptions.trim();
|
||||||
@@ -96,6 +97,7 @@ export const post: RequestHandler = async (event) => {
|
|||||||
dockerFileLocation,
|
dockerFileLocation,
|
||||||
denoMainFile,
|
denoMainFile,
|
||||||
denoOptions,
|
denoOptions,
|
||||||
|
baseImage,
|
||||||
...defaultConfiguration
|
...defaultConfiguration
|
||||||
});
|
});
|
||||||
return { status: 201 };
|
return { status: 201 };
|
||||||
|
|||||||
@@ -310,6 +310,14 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="grid grid-cols-2 items-center pb-8">
|
||||||
|
<label for="baseImage" class="text-base font-bold text-stone-100"
|
||||||
|
>{$t('application.base_image')}</label
|
||||||
|
>
|
||||||
|
<div class="no-underline">
|
||||||
|
<input value={application.baseImage} id="baseImage" disabled class="bg-transparent " />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex space-x-1 py-5 font-bold">
|
<div class="flex space-x-1 py-5 font-bold">
|
||||||
<div class="title">{$t('application.application')}</div>
|
<div class="title">{$t('application.application')}</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user