This commit is contained in:
Andras Bacsai 2022-11-29 09:19:10 +01:00
parent 3f078517a0
commit 513c4f9e29
5 changed files with 41 additions and 21 deletions

View File

@ -0,0 +1,31 @@
-- 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,
"proxyDefaultRedirect" TEXT,
"doNotTrack" BOOLEAN NOT NULL DEFAULT false,
"sentryDSN" TEXT,
"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", "proxyDefaultRedirect", "sentryDSN", "updatedAt") SELECT coalesce("DNSServers", '1.1.1.1,8.8.8.8') AS "DNSServers", "applicationStoragePathMigrationFinished", "arch", "concurrentBuilds", "createdAt", "doNotTrack", "dualCerts", "fqdn", "id", "ipv4", "ipv6", "isAPIDebuggingEnabled", "isAutoUpdateEnabled", "isDNSCheckEnabled", "isRegistrationEnabled", "isTraefikUsed", "maxPort", "minPort", "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;

View File

@ -24,7 +24,7 @@ model Setting {
dualCerts Boolean @default(false) dualCerts Boolean @default(false)
minPort Int @default(9000) minPort Int @default(9000)
maxPort Int @default(9100) maxPort Int @default(9100)
DNSServers String? DNSServers String @default("1.1.1.1,8.8.8.8")
ipv4 String? ipv4 String?
ipv6 String? ipv6 String?
arch String? arch String?
@ -34,7 +34,7 @@ model Setting {
doNotTrack Boolean @default(false) doNotTrack Boolean @default(false)
sentryDSN String? sentryDSN String?
isAPIDebuggingEnabled Boolean @default(false) isAPIDebuggingEnabled Boolean @default(false)
isRegistrationEnabled Boolean @default(false) isRegistrationEnabled Boolean @default(true)
isAutoUpdateEnabled Boolean @default(false) isAutoUpdateEnabled Boolean @default(false)
isDNSCheckEnabled Boolean @default(true) isDNSCheckEnabled Boolean @default(true)
isTraefikUsed Boolean @default(true) isTraefikUsed Boolean @default(true)

View File

@ -12,9 +12,7 @@ async function main() {
await prisma.setting.create({ await prisma.setting.create({
data: { data: {
id: '0', id: '0',
isRegistrationEnabled: true,
arch: process.arch, arch: process.arch,
DNSServers: '1.1.1.1,8.8.8.8'
} }
}); });
} else { } else {
@ -23,11 +21,11 @@ async function main() {
id: settingsFound.id id: settingsFound.id
}, },
data: { data: {
id: '0', id: '0'
isTraefikUsed: true,
} }
}); });
} }
// Create local docker engine
const localDocker = await prisma.destinationDocker.findFirst({ const localDocker = await prisma.destinationDocker.findFirst({
where: { engine: '/var/run/docker.sock' } where: { engine: '/var/run/docker.sock' }
}); });
@ -52,12 +50,10 @@ async function main() {
isAutoUpdateEnabled isAutoUpdateEnabled
} }
}); });
// Create public github source
const github = await prisma.gitSource.findFirst({ const github = await prisma.gitSource.findFirst({
where: { htmlUrl: 'https://github.com', forPublic: true } where: { htmlUrl: 'https://github.com', forPublic: true }
}); });
const gitlab = await prisma.gitSource.findFirst({
where: { htmlUrl: 'https://gitlab.com', forPublic: true }
});
if (!github) { if (!github) {
await prisma.gitSource.create({ await prisma.gitSource.create({
data: { data: {
@ -69,6 +65,10 @@ async function main() {
} }
}); });
} }
// Create public gitlab source
const gitlab = await prisma.gitSource.findFirst({
where: { htmlUrl: 'https://gitlab.com', forPublic: true }
});
if (!gitlab) { if (!gitlab) {
await prisma.gitSource.create({ await prisma.gitSource.create({
data: { data: {

View File

@ -240,14 +240,6 @@ async function getTagsTemplates() {
async function initServer() { async function initServer() {
const appId = process.env['COOLIFY_APP_ID']; const appId = process.env['COOLIFY_APP_ID'];
const settings = await prisma.setting.findUnique({ where: { id: '0' } }) const settings = await prisma.setting.findUnique({ where: { id: '0' } })
try {
let doNotTrack = false
if (appId === '') doNotTrack = true
doNotTrack = settings.doNotTrack
await prisma.setting.update({ where: { id: '0' }, data: { doNotTrack } })
} catch (error) {
console.log(error)
}
try { try {
if (settings.doNotTrack === true) { if (settings.doNotTrack === true) {
console.log('[000] Telemetry disabled...') console.log('[000] Telemetry disabled...')
@ -258,14 +250,12 @@ async function initServer() {
} }
// Initialize Sentry // Initialize Sentry
Sentry.init({ Sentry.init({
debug: true,
dsn: sentryDSN, dsn: sentryDSN,
environment: isDev ? 'development' : 'production', environment: isDev ? 'development' : 'production',
release: version release: version
}); });
console.log('[000] Sentry initialized...') console.log('[000] Sentry initialized...')
} }
} catch (error) { } catch (error) {
console.error(error) console.error(error)
} }
@ -274,7 +264,7 @@ async function initServer() {
await asyncExecShell(`docker network create --attachable coolify`); await asyncExecShell(`docker network create --attachable coolify`);
} catch (error) { } } catch (error) { }
try { try {
console.log(`[002] Set stuck builds to failed...`); console.log(`[002] Cleanup stucked builds...`);
const isOlder = compareVersions('3.8.1', version); const isOlder = compareVersions('3.8.1', version);
if (isOlder === 1) { if (isOlder === 1) {
await prisma.build.updateMany({ where: { status: { in: ['running', 'queued'] } }, data: { status: 'failed' } }); await prisma.build.updateMany({ where: { status: { in: ['running', 'queued'] } }, data: { status: 'failed' } });

View File

@ -80,7 +80,6 @@ export async function saveSettings(request: FastifyRequest<SaveSettings>, reply:
} }
if (doNotTrack === false) { if (doNotTrack === false) {
Sentry.init({ Sentry.init({
debug: true,
dsn: sentryDSN, dsn: sentryDSN,
environment: isDev ? 'development' : 'production', environment: isDev ? 'development' : 'production',
release: version release: version