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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat: custom previewseparator
Andras Bacsaic6273e91774a
diff --git a/apps/api/prisma/migrations/20221129121702_preview_separator/migration.sql b/apps/api/prisma/migrations/20221129121702_preview_separator/migration.sqlnew file mode 100644index 0000000000..2fdff0eca5--- /dev/null+++ b/apps/api/prisma/migrations/20221129121702_preview_separator/migration.sql@@ -0,0 +1,33 @@+-- RedefineTables+PRAGMA foreign_keys=OFF;+CREATE TABLE "new_Setting" (+ "id" TEXT NOT NULL PRIMARY KEY,+ "fqdn" TEXT,+ "dualCerts" BOOLEAN NOT NULL DEFAULT false,+ "minPort" INTEGER NOT NULL DEFAULT 9000,+ "maxPort" INTEGER NOT NULL DEFAULT 9100,+ "DNSServers" TEXT NOT NULL DEFAULT '1.1.1.1,8.8.8.8',+ "ipv4" TEXT,+ "ipv6" TEXT,+ "arch" TEXT,+ "concurrentBuilds" INTEGER NOT NULL DEFAULT 1,+ "applicationStoragePathMigrationFinished" BOOLEAN NOT NULL DEFAULT false,+ "numberOfDockerImagesKeptLocally" INTEGER NOT NULL DEFAULT 3,+ "proxyDefaultRedirect" TEXT,+ "doNotTrack" BOOLEAN NOT NULL DEFAULT false,+ "sentryDSN" TEXT,+ "previewSeparator" TEXT NOT NULL DEFAULT '.',+ "isAPIDebuggingEnabled" BOOLEAN NOT NULL DEFAULT false,+ "isRegistrationEnabled" BOOLEAN NOT NULL DEFAULT true,+ "isAutoUpdateEnabled" BOOLEAN NOT NULL DEFAULT false,+ "isDNSCheckEnabled" BOOLEAN NOT NULL DEFAULT true,+ "isTraefikUsed" BOOLEAN NOT NULL DEFAULT true,+ "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,+ "updatedAt" DATETIME NOT NULL+);+INSERT INTO "new_Setting" ("DNSServers", "applicationStoragePathMigrationFinished", "arch", "concurrentBuilds", "createdAt", "doNotTrack", "dualCerts", "fqdn", "id", "ipv4", "ipv6", "isAPIDebuggingEnabled", "isAutoUpdateEnabled", "isDNSCheckEnabled", "isRegistrationEnabled", "isTraefikUsed", "maxPort", "minPort", "numberOfDockerImagesKeptLocally", "proxyDefaultRedirect", "sentryDSN", "updatedAt") SELECT "DNSServers", "applicationStoragePathMigrationFinished", "arch", "concurrentBuilds", "createdAt", "doNotTrack", "dualCerts", "fqdn", "id", "ipv4", "ipv6", "isAPIDebuggingEnabled", "isAutoUpdateEnabled", "isDNSCheckEnabled", "isRegistrationEnabled", "isTraefikUsed", "maxPort", "minPort", "numberOfDockerImagesKeptLocally", "proxyDefaultRedirect", "sentryDSN", "updatedAt" FROM "Setting";+DROP TABLE "Setting";+ALTER TABLE "new_Setting" RENAME TO "Setting";+CREATE UNIQUE INDEX "Setting_fqdn_key" ON "Setting"("fqdn");+PRAGMA foreign_key_check;+PRAGMA foreign_keys=ON;diff --git a/apps/api/prisma/schema.prisma b/apps/api/prisma/schema.prismaindex 3deb42c60e..75c516a9b6 100644--- a/apps/api/prisma/schema.prisma+++ b/apps/api/prisma/schema.prisma@@ -34,6 +34,7 @@ model Setting {proxyDefaultRedirect String?doNotTrack Boolean @default(false)sentryDSN String?+ previewSeparator String @default(".")isAPIDebuggingEnabled Boolean @default(false)isRegistrationEnabled Boolean @default(true)isAutoUpdateEnabled Boolean @default(false)diff --git a/apps/api/src/routes/api/v1/settings/handlers.ts b/apps/api/src/routes/api/v1/settings/handlers.tsindex 91f2703a10..f35c8f968e 100644--- a/apps/api/src/routes/api/v1/settings/handlers.ts+++ b/apps/api/src/routes/api/v1/settings/handlers.ts@@ -54,6 +54,7 @@ export async function listAllSettings(request: FastifyRequest) {export async function saveSettings(request: FastifyRequest<SaveSettings>, reply: FastifyReply) {try {let {+ previewSeparator,numberOfDockerImagesKeptLocally,doNotTrack,fqdn,@@ -73,7 +74,7 @@ export async function saveSettings(request: FastifyRequest<SaveSettings>, reply:}await prisma.setting.update({where: { id },- data: { numberOfDockerImagesKeptLocally, doNotTrack, isRegistrationEnabled, dualCerts, isAutoUpdateEnabled, isDNSCheckEnabled, DNSServers, isAPIDebuggingEnabled, }+ data: { previewSeparator, numberOfDockerImagesKeptLocally, doNotTrack, isRegistrationEnabled, dualCerts, isAutoUpdateEnabled, isDNSCheckEnabled, DNSServers, isAPIDebuggingEnabled }});if (fqdn) {await prisma.setting.update({ where: { id }, data: { fqdn } });diff --git a/apps/api/src/routes/api/v1/settings/types.ts b/apps/api/src/routes/api/v1/settings/types.tsindex 76212f158a..6f858f0a58 100644--- a/apps/api/src/routes/api/v1/settings/types.ts+++ b/apps/api/src/routes/api/v1/settings/types.ts@@ -2,6 +2,7 @@ import { OnlyId } from "../../../../types"export interface SaveSettings {Body: {+ previewSeparator: string,numberOfDockerImagesKeptLocally: number,doNotTrack: boolean,fqdn: string,diff --git a/apps/api/src/routes/webhooks/github/handlers.ts b/apps/api/src/routes/webhooks/github/handlers.tsindex d9345c04d3..bfb3f3db8e 100644--- a/apps/api/src/routes/webhooks/github/handlers.ts+++ b/apps/api/src/routes/webhooks/github/handlers.ts@@ -92,6 +92,7 @@ export async function gitHubEvents(request: FastifyRequest<GitHubEvents>): Promithrow { status: 500, message: 'Cannot parse projectId or branch from the webhook?!' }}const applicationsFound = await getApplicationFromDBWebhook(projectId, branch);+ const settings = await prisma.setting.findUnique({ where: { id: '0' } });if (applicationsFound && applicationsFound.length > 0) {for (const application of applicationsFound) {const buildId = cuid();@@ -192,7 +193,7 @@ export async function gitHubEvents(request: FastifyRequest<GitHubEvents>): Promidata: {pullmergeRequestId,sourceBranch,- customDomain: `${protocol}${pullmergeRequestId}.${getDomain(application.fqdn)}`,+ customDomain: `${protocol}${pullmergeRequestId}${settings.previewSeparator}${getDomain(application.fqdn)}`,application: { connect: { id: application.id } }}})diff --git a/apps/api/src/routes/webhooks/gitlab/handlers.ts b/apps/api/src/routes/webhooks/gitlab/handlers.tsindex d3a1a47b3d..52bc2fda22 100644--- a/apps/api/src/routes/webhooks/gitlab/handlers.ts+++ b/apps/api/src/routes/webhooks/gitlab/handlers.ts@@ -46,6 +46,7 @@ export async function gitLabEvents(request: FastifyRequest<GitLabEvents>) {if (!webhookToken && !isDev) {throw { status: 500, message: 'Invalid webhookToken.' }}+ const settings = await prisma.setting.findUnique({ where: { id: '0' } });if (objectKind === 'push') {const projectId = Number(project_id);const branch = ref.split('/')[2];@@ -140,7 +141,7 @@ export async function gitLabEvents(request: FastifyRequest<GitLabEvents>) {data: {pullmergeRequestId,sourceBranch,- customDomain: `${protocol}${pullmergeRequestId}.${getDomain(application.fqdn)}`,+ customDomain: `${protocol}${pullmergeRequestId}${settings.previewSeparator}${getDomain(application.fqdn)}`,application: { connect: { id: application.id } }}})diff --git a/apps/ui/src/routes/settings/coolify.svelte b/apps/ui/src/routes/settings/coolify.svelteindex 58e0756dc9..5356849b76 100644--- a/apps/ui/src/routes/settings/coolify.svelte+++ b/apps/ui/src/routes/settings/coolify.svelte@@ -37,6 +37,7 @@let proxyDefaultRedirect = settings.proxyDefaultRedirect;let doNotTrack = settings.doNotTrack;let numberOfDockerImagesKeptLocally = settings.numberOfDockerImagesKeptLocally;+ let previewSeparator = settings.previewSeparator;let forceSave = false;let fqdn = settings.fqdn;@@ -169,6 +170,9 @@if (numberOfDockerImagesKeptLocally !== settings.numberOfDockerImagesKeptLocally) {await post(`/settings`, { numberOfDockerImagesKeptLocally });}+ if (previewSeparator !== settings.previewSeparator) {+ await post(`/settings`, { previewSeparator });+ }if (minPort !== settings.minPort || maxPort !== settings.maxPort) {await post(`/settings`, { minPort, maxPort });settings.minPort = minPort;@@ -376,7 +380,7 @@<div class="grid grid-cols-4 items-center"><div class="col-span-2">- Rollback to a specific version+ Rollback Coolify to a specific version<Explainerposition="dropdown-bottom"explanation="You can rollback to a specific version of Coolify. This will not affect your current running resources.<br><br><a href='https://github.com/coollabsio/coolify/releases' target='_blank'>See available versions</a>"@@ -416,6 +420,24 @@placeholder="default: 3"/></div>+ <div class="grid grid-cols-2 items-center">+ <div>+ Preview Domain Seprator+ <Explainer+ position="dropdown-bottom"+ explanation="The separator used in the PR/MR previews.<br><br>For example if you set it to: <span class='text-yellow-400 font-bold'>-</span><br> the preview domain will be like this: <br><br><span class='text-yellow-400 font-bold'>PRMRNumber-yourdomain.com</span><br><br>The default is: <span class='text-yellow-400 font-bold'>.</span><br>so the preview domain will be like this: <br><br><span class='text-yellow-400 font-bold'>PRMRNumber.yourdomain.com</span>"+ />+ </div>+ <input+ class="w-full"+ bind:value={previewSeparator}+ readonly={!$appSession.isAdmin}+ disabled={!$appSession.isAdmin}+ name="previewSeparator"+ id="previewSeparator"+ placeholder="default: ."+ />+ </div><div class="grid grid-cols-2 items-center"><div>{$t('forms.public_port_range')}