Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

WIP: Base image selector

Andras Bacsai5998212b8223
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 82ba9baa8b..77f2e1297a 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -105,6 +105,7 @@ model Application {
gitSource GitSource? @relation(fields: [gitSourceId], references: [id])
secrets Secret[]
persistentStorage ApplicationPersistentStorage[]
+ baseImage String?
}
model ApplicationSettings {
diff --git a/src/lib/database/applications.ts b/src/lib/database/applications.ts
index d57e3f3e59..f02300bd25 100644
--- a/src/lib/database/applications.ts
+++ b/src/lib/database/applications.ts
@@ -12,6 +12,17 @@ import type {
Application,
ApplicationPersistentStorage
} from '@prisma/client';
+const nodeBased = [
+ 'react',
+ 'vuejs',
+ 'static',
+ 'svelte',
+ 'gatsby',
+ 'php',
+ 'astro',
+ 'eleventy',
+ 'node'
+];
export async function listApplications(teamId: string): Promise<Application[]> {
if (teamId === '0') {
@@ -195,6 +206,24 @@ export async function getApplication({ id, teamId }: { id: string; teamId: strin
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 };
}
@@ -266,7 +295,8 @@ export async function configureApplication({
pythonVariable,
dockerFileLocation,
denoMainFile,
- denoOptions
+ denoOptions,
+ baseImage
}: {
id: string;
buildPack: string;
@@ -284,6 +314,7 @@ export async function configureApplication({
dockerFileLocation: string;
denoMainFile: string;
denoOptions: string;
+ baseImage: string;
}): Promise<Application> {
return await prisma.application.update({
where: { id },
@@ -302,7 +333,8 @@ export async function configureApplication({
pythonVariable,
dockerFileLocation,
denoMainFile,
- denoOptions
+ denoOptions,
+ baseImage
}
});
}
diff --git a/src/lib/docker.ts b/src/lib/docker.ts
index d3c040c6a3..196ee33402 100644
--- a/src/lib/docker.ts
+++ b/src/lib/docker.ts
@@ -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 pnpm add -g pnpm');
}
- Dockerfile.push(`COPY .${baseDirectory || ''} ./`);
if (installCommand) {
+ Dockerfile.push(`COPY .${baseDirectory || ''}/package.json ./`);
Dockerfile.push(`RUN ${installCommand}`);
}
+ Dockerfile.push(`COPY .${baseDirectory || ''} ./`);
Dockerfile.push(`RUN ${buildCommand}`);
await fs.writeFile(`${workdir}/Dockerfile-cache`, Dockerfile.join('\n'));
await buildImage({ applicationId, tag, workdir, docker, buildId, isCache: true, debug });
diff --git a/src/lib/locales/en.json b/src/lib/locales/en.json
index d77d2a1c1e..17f210b521 100644
--- a/src/lib/locales/en.json
+++ b/src/lib/locales/en.json
@@ -124,7 +124,7 @@
"no_branches_found": "No branches found",
"configure_build_pack": "Configure Build Pack",
"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",
"no_configurable_destination": "No configurable Destination found",
"select_a_repository_project": "Select a Repository / Project",
@@ -184,6 +184,7 @@
"git_source": "Git Source",
"git_repository": "Git Repository",
"build_pack": "Build Pack",
+ "base_image": "Base Image",
"destination": "Destination",
"application": "Application",
"url_fqdn": "URL (FQDN)",
diff --git a/src/routes/applications/[id]/configuration/baseimage.svelte b/src/routes/applications/[id]/configuration/baseimage.svelte
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/src/routes/applications/[id]/configuration/buildpack.svelte b/src/routes/applications/[id]/configuration/buildpack.svelte
index 437c65cfac..13e6f8e10f 100644
--- a/src/routes/applications/[id]/configuration/buildpack.svelte
+++ b/src/routes/applications/[id]/configuration/buildpack.svelte
@@ -225,7 +225,7 @@
<div class="max-w-7xl mx-auto flex flex-wrap justify-center">
{#each buildPacks as buildPack}
<div class="p-2">
- <BuildPack {buildPack} {scanning} bind:foundConfig />
+ <BuildPack {packageManager} {buildPack} {scanning} bind:foundConfig />
</div>
{/each}
</div>
diff --git a/src/routes/applications/[id]/index.json.ts b/src/routes/applications/[id]/index.json.ts
index ef9f57dcb9..ed7dc9b076 100644
--- a/src/routes/applications/[id]/index.json.ts
+++ b/src/routes/applications/[id]/index.json.ts
@@ -62,7 +62,8 @@ export const post: RequestHandler = async (event) => {
pythonVariable,
dockerFileLocation,
denoMainFile,
- denoOptions
+ denoOptions,
+ baseImage
} = await event.request.json();
if (port) port = Number(port);
if (denoOptions) denoOptions = denoOptions.trim();
@@ -96,6 +97,7 @@ export const post: RequestHandler = async (event) => {
dockerFileLocation,
denoMainFile,
denoOptions,
+ baseImage,
...defaultConfiguration
});
return { status: 201 };
diff --git a/src/routes/applications/[id]/index.svelte b/src/routes/applications/[id]/index.svelte
index 359cdc5a36..f5d9f8c97d 100644
--- a/src/routes/applications/[id]/index.svelte
+++ b/src/routes/applications/[id]/index.svelte
@@ -310,6 +310,14 @@
/>
</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 class="flex space-x-1 py-5 font-bold">
<div class="title">{$t('application.application')}</div>