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.

feat: save doNotTrackData to db

Andras Bacsai72844e4edcb8
diff --git a/apps/api/prisma/migrations/20221128104158_do_not_track/migration.sql b/apps/api/prisma/migrations/20221128104158_do_not_track/migration.sql
new file mode 100644
index 0000000000..9cf26d8a80
--- /dev/null
+++ b/apps/api/prisma/migrations/20221128104158_do_not_track/migration.sql
@@ -0,0 +1,30 @@
+-- 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,
+ "ipv4" TEXT,
+ "ipv6" TEXT,
+ "arch" TEXT,
+ "concurrentBuilds" INTEGER NOT NULL DEFAULT 1,
+ "applicationStoragePathMigrationFinished" BOOLEAN NOT NULL DEFAULT false,
+ "proxyDefaultRedirect" TEXT,
+ "doNotTrack" BOOLEAN NOT NULL DEFAULT false,
+ "isAPIDebuggingEnabled" BOOLEAN DEFAULT false,
+ "isRegistrationEnabled" BOOLEAN NOT NULL DEFAULT false,
+ "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", "dualCerts", "fqdn", "id", "ipv4", "ipv6", "isAPIDebuggingEnabled", "isAutoUpdateEnabled", "isDNSCheckEnabled", "isRegistrationEnabled", "isTraefikUsed", "maxPort", "minPort", "proxyDefaultRedirect", "updatedAt") SELECT "DNSServers", "applicationStoragePathMigrationFinished", "arch", "concurrentBuilds", "createdAt", "dualCerts", "fqdn", "id", "ipv4", "ipv6", "isAPIDebuggingEnabled", "isAutoUpdateEnabled", "isDNSCheckEnabled", "isRegistrationEnabled", "isTraefikUsed", "maxPort", "minPort", "proxyDefaultRedirect", "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/migrations/20221128104718_fix_defaults/migration.sql b/apps/api/prisma/migrations/20221128104718_fix_defaults/migration.sql
new file mode 100644
index 0000000000..c1152cdc35
--- /dev/null
+++ b/apps/api/prisma/migrations/20221128104718_fix_defaults/migration.sql
@@ -0,0 +1,60 @@
+-- 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,
+ "ipv4" TEXT,
+ "ipv6" TEXT,
+ "arch" TEXT,
+ "concurrentBuilds" INTEGER NOT NULL DEFAULT 1,
+ "applicationStoragePathMigrationFinished" BOOLEAN NOT NULL DEFAULT false,
+ "proxyDefaultRedirect" TEXT,
+ "doNotTrack" BOOLEAN NOT NULL DEFAULT false,
+ "isAPIDebuggingEnabled" BOOLEAN NOT NULL DEFAULT false,
+ "isRegistrationEnabled" BOOLEAN NOT NULL DEFAULT false,
+ "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", "proxyDefaultRedirect", "updatedAt") SELECT "DNSServers", "applicationStoragePathMigrationFinished", "arch", "concurrentBuilds", "createdAt", "doNotTrack", "dualCerts", "fqdn", "id", "ipv4", "ipv6", coalesce("isAPIDebuggingEnabled", false) AS "isAPIDebuggingEnabled", "isAutoUpdateEnabled", "isDNSCheckEnabled", "isRegistrationEnabled", "isTraefikUsed", "maxPort", "minPort", "proxyDefaultRedirect", "updatedAt" FROM "Setting";
+DROP TABLE "Setting";
+ALTER TABLE "new_Setting" RENAME TO "Setting";
+CREATE UNIQUE INDEX "Setting_fqdn_key" ON "Setting"("fqdn");
+CREATE TABLE "new_GlitchTip" (
+ "id" TEXT NOT NULL PRIMARY KEY,
+ "postgresqlUser" TEXT NOT NULL,
+ "postgresqlPassword" TEXT NOT NULL,
+ "postgresqlDatabase" TEXT NOT NULL,
+ "postgresqlPublicPort" INTEGER,
+ "secretKeyBase" TEXT,
+ "defaultEmail" TEXT NOT NULL,
+ "defaultUsername" TEXT NOT NULL,
+ "defaultPassword" TEXT NOT NULL,
+ "defaultEmailFrom" TEXT NOT NULL DEFAULT '[email protected]',
+ "emailSmtpHost" TEXT DEFAULT 'domain.tdl',
+ "emailSmtpPort" INTEGER DEFAULT 25,
+ "emailSmtpUser" TEXT,
+ "emailSmtpPassword" TEXT,
+ "emailSmtpUseTls" BOOLEAN NOT NULL DEFAULT false,
+ "emailSmtpUseSsl" BOOLEAN NOT NULL DEFAULT false,
+ "emailBackend" TEXT,
+ "mailgunApiKey" TEXT,
+ "sendgridApiKey" TEXT,
+ "enableOpenUserRegistration" BOOLEAN NOT NULL DEFAULT true,
+ "serviceId" TEXT NOT NULL,
+ "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "updatedAt" DATETIME NOT NULL,
+ CONSTRAINT "GlitchTip_serviceId_fkey" FOREIGN KEY ("serviceId") REFERENCES "Service" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
+);
+INSERT INTO "new_GlitchTip" ("createdAt", "defaultEmail", "defaultEmailFrom", "defaultPassword", "defaultUsername", "emailBackend", "emailSmtpHost", "emailSmtpPassword", "emailSmtpPort", "emailSmtpUseSsl", "emailSmtpUseTls", "emailSmtpUser", "enableOpenUserRegistration", "id", "mailgunApiKey", "postgresqlDatabase", "postgresqlPassword", "postgresqlPublicPort", "postgresqlUser", "secretKeyBase", "sendgridApiKey", "serviceId", "updatedAt") SELECT "createdAt", "defaultEmail", "defaultEmailFrom", "defaultPassword", "defaultUsername", "emailBackend", "emailSmtpHost", "emailSmtpPassword", "emailSmtpPort", coalesce("emailSmtpUseSsl", false) AS "emailSmtpUseSsl", coalesce("emailSmtpUseTls", false) AS "emailSmtpUseTls", "emailSmtpUser", "enableOpenUserRegistration", "id", "mailgunApiKey", "postgresqlDatabase", "postgresqlPassword", "postgresqlPublicPort", "postgresqlUser", "secretKeyBase", "sendgridApiKey", "serviceId", "updatedAt" FROM "GlitchTip";
+DROP TABLE "GlitchTip";
+ALTER TABLE "new_GlitchTip" RENAME TO "GlitchTip";
+CREATE UNIQUE INDEX "GlitchTip_serviceId_key" ON "GlitchTip"("serviceId");
+PRAGMA foreign_key_check;
+PRAGMA foreign_keys=ON;
diff --git a/apps/api/prisma/schema.prisma b/apps/api/prisma/schema.prisma
index ef843f694e..a1bef0b5f2 100644
--- a/apps/api/prisma/schema.prisma
+++ b/apps/api/prisma/schema.prisma
@@ -31,7 +31,8 @@ model Setting {
concurrentBuilds Int @default(1)
applicationStoragePathMigrationFinished Boolean @default(false)
proxyDefaultRedirect String?
- isAPIDebuggingEnabled Boolean? @default(false)
+ doNotTrack Boolean @default(false)
+ isAPIDebuggingEnabled Boolean @default(false)
isRegistrationEnabled Boolean @default(false)
isAutoUpdateEnabled Boolean @default(false)
isDNSCheckEnabled Boolean @default(true)
@@ -640,8 +641,8 @@ model GlitchTip {
emailSmtpPort Int? @default(25)
emailSmtpUser String?
emailSmtpPassword String?
- emailSmtpUseTls Boolean? @default(false)
- emailSmtpUseSsl Boolean? @default(false)
+ emailSmtpUseTls Boolean @default(false)
+ emailSmtpUseSsl Boolean @default(false)
emailBackend String?
mailgunApiKey String?
sendgridApiKey String?
diff --git a/apps/api/prisma/seed.js b/apps/api/prisma/seed.js
index dddbf3e281..28017e7cec 100644
--- a/apps/api/prisma/seed.js
+++ b/apps/api/prisma/seed.js
@@ -11,6 +11,7 @@ async function main() {
if (!settingsFound) {
await prisma.setting.create({
data: {
+ id: '0',
isRegistrationEnabled: true,
arch: process.arch,
DNSServers: '1.1.1.1,8.8.8.8'
@@ -22,6 +23,7 @@ async function main() {
id: settingsFound.id
},
data: {
+ id: '0',
isTraefikUsed: true,
}
});
@@ -42,11 +44,10 @@ async function main() {
// Set auto-update based on env variable
const isAutoUpdateEnabled = process.env['COOLIFY_AUTO_UPDATE'] === 'true';
- const settings = await prisma.setting.findFirst({});
if (settings) {
await prisma.setting.update({
where: {
- id: settings.id
+ id: '0'
},
data: {
isAutoUpdateEnabled
diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts
index b5fab46db6..fa4ca15eea 100644
--- a/apps/api/src/index.ts
+++ b/apps/api/src/index.ts
@@ -238,6 +238,16 @@ async function getTagsTemplates() {
}
}
async function initServer() {
+ try {
+ const appId = process.env['COOLIFY_APP_ID'];
+ let doNotTrack = false
+ if (appId === '') {
+ doNotTrack = true
+ }
+ await prisma.setting.update({ where: { id: '0' }, data: { doNotTrack } })
+ } catch (error) {
+ console.log(error)
+ }
try {
console.log(`[001] Initializing server...`);
await asyncExecShell(`docker network create --attachable coolify`);