Compare commits

...

56 Commits

Author SHA1 Message Date
Andras Bacsai
c471eed808 Merge pull request #568 from coollabsio/next
v3.8.3
2022-08-26 18:01:55 +02:00
Andras Bacsai
35450dfc8f fix: secrets decryption 2022-08-26 16:00:36 +00:00
Andras Bacsai
5360c60f3d Merge pull request #565 from coollabsio/next
v3.8.2
2022-08-26 15:22:27 +02:00
Andras Bacsai
f60c640dc6 ui: fix 2022-08-26 13:28:54 +02:00
Andras Bacsai
91bb323e84 ui fixes 2022-08-26 13:22:43 +02:00
Andras Bacsai
cf9e122bd2 ui: fixes 2022-08-26 13:17:35 +02:00
Andras Bacsai
7528ca18d8 ui: fixes
feat: restart coolify button
2022-08-26 12:46:20 +02:00
Andras Bacsai
05ee35b6bc typo 2022-08-26 12:07:21 +02:00
Andras Bacsai
0e8b069781 ui: fine-tune 2022-08-26 10:29:45 +02:00
Andras Bacsai
3b95d7278d ui: dashboard fine-tunes 2022-08-26 10:22:50 +02:00
Andras Bacsai
7691706295 fix lockfile 2022-08-26 10:00:48 +02:00
Andras Bacsai
2af65ee946 Merge pull request #563 from kaname-png/rework-home
feat(ui): rework home UI and with responsive design
2022-08-26 10:00:06 +02:00
Andras Bacsai
279e1fd9c5 Merge branch 'next' into rework-home 2022-08-26 09:58:52 +02:00
Andras Bacsai
0f8f33e9fe remove unnecessary things 2022-08-26 09:49:17 +02:00
Andras Bacsai
12e91f1c6b fix 2022-08-26 09:33:50 +02:00
Andras Bacsai
f4f605867b hm 2022-08-26 09:09:41 +02:00
Andras Bacsai
ac40abba2e Update README.md 2022-08-26 09:05:26 +02:00
Andras Bacsai
224604f2e7 fixes 2022-08-26 09:01:48 +02:00
Andras Bacsai
ee4360de3a fix: better worker system 2022-08-26 06:29:06 +00:00
Kaname
0af59b9602 Merge remote-tracking branch 'upstream/next' into rework-home 2022-08-26 02:39:55 +00:00
Kaname
ff8fe68f14 feat(ui): rework home UI and with responsive design 2022-08-26 01:40:46 +00:00
Andras Bacsai
71c15e0ff5 fix: worker 2022-08-25 12:49:09 +00:00
Andras Bacsai
6be1fbacde Merge branch 'main' of https://github.com/coollabsio/coolify into next 2022-08-25 12:02:30 +00:00
Andras Bacsai
be594dd49e revert test 2022-08-25 12:44:04 +02:00
Andras Bacsai
6b65d435fb hmn 2022-08-25 12:32:50 +02:00
Andras Bacsai
0dc5212066 Revert things 2022-08-25 12:25:46 +02:00
Andras Bacsai
7c8ffd510e asd 2022-08-25 11:59:56 +02:00
Andras Bacsai
8e6423e873 hmm 2022-08-25 11:54:23 +02:00
Andras Bacsai
c99f74b351 debug 2022-08-25 11:49:19 +02:00
Andras Bacsai
57b462223c test 2022-08-25 11:09:38 +02:00
Andras Bacsai
055db97273 hm 2022-08-25 10:53:04 +02:00
Andras Bacsai
c80ebf73ee hmm 2022-08-25 10:47:58 +02:00
Andras Bacsai
9b613294ae debug cpu usage 2022-08-25 10:43:01 +02:00
Andras Bacsai
8cb73e1680 hmm 2022-08-25 10:37:21 +02:00
Andras Bacsai
27dfa24cfb remove debug 2022-08-25 10:29:08 +02:00
Andras Bacsai
c53f0dbb30 fix: high cpu usage 2022-08-25 10:28:32 +02:00
Andras Bacsai
db16a357e8 debug cpu usage 2022-08-25 10:17:07 +02:00
Andras Bacsai
01e71958b2 fix: build queue system 2022-08-25 10:04:46 +02:00
Andras Bacsai
f379519d40 chore: version++ 2022-08-24 14:50:34 +02:00
Andras Bacsai
54a09958d5 fix: never stop deplyo queue 2022-08-24 11:16:49 +02:00
Andras Bacsai
3421de06d5 Merge pull request #558 from coollabsio/next
v3.8.1
2022-08-24 10:54:53 +02:00
Andras Bacsai
e44eb01396 fix: dashboard for admins 2022-08-24 10:45:58 +02:00
Andras Bacsai
313143586b fix: cancelling jobs 2022-08-24 10:35:28 +02:00
Andras Bacsai
c8ae72893a fix: clear queue on cancelling jobs 2022-08-24 09:39:24 +02:00
Andras Bacsai
cbc3735ca0 fix: ui buttons 2022-08-23 13:03:01 +02:00
Andras Bacsai
31fdbdf8c9 Merge pull request #554 from coollabsio/next
v3.8.0
2022-08-23 11:41:52 +02:00
Andras Bacsai
2741d0ab2a fix: show build log start/end 2022-08-23 11:36:14 +02:00
Andras Bacsai
79b0187b58 fix: stream build logs 2022-08-23 11:29:25 +02:00
Andras Bacsai
bf5659d0e2 fix: dashboard for non-root users 2022-08-23 10:19:57 +02:00
Andras Bacsai
f6314cab69 chore: version++ 2022-08-23 10:11:58 +02:00
Andras Bacsai
4f5fe3d383 feat: Searxng service 2022-08-23 10:11:38 +02:00
Andras Bacsai
1c720d587c fix: batch secret = 2022-08-23 08:57:15 +02:00
Andras Bacsai
c46dc99224 fix: exposedPort checker 2022-08-23 08:50:28 +02:00
Andras Bacsai
5e43d4f20d update packages 2022-08-23 08:49:41 +02:00
Andras Bacsai
359434bfd3 fix: cancel build after 5 seconds 2022-08-23 08:49:32 +02:00
Andras Bacsai
e755a2d4ec fix: port checker 2022-08-22 19:30:09 +00:00
52 changed files with 1802 additions and 1585 deletions

View File

@@ -103,7 +103,7 @@ A fresh installation is necessary. v2 and v3 are not compatible with v1.
- Twitter: [@andrasbacsai](https://twitter.com/andrasbacsai) - Twitter: [@andrasbacsai](https://twitter.com/andrasbacsai)
- Telegram: [@andrasbacsai](https://t.me/andrasbacsai) - Telegram: [@andrasbacsai](https://t.me/andrasbacsai)
- Email: [andras@coollabs.io](mailto:andras@coollabs.io) - Email: [andras@coollabs.io](mailto:andras@coollabs.io)
- Discord: [Invitation](https://discord.gg/6rDM4fkymF) - Discord: [Invitation](https://coollabs.io/discord)
## Financial Contributors ## Financial Contributors

View File

@@ -16,26 +16,27 @@
"dependencies": { "dependencies": {
"@breejs/ts-worker": "2.0.0", "@breejs/ts-worker": "2.0.0",
"@fastify/autoload": "5.2.0", "@fastify/autoload": "5.2.0",
"@fastify/cookie": "7.3.1", "@fastify/cookie": "8.0.0",
"@fastify/cors": "8.1.0", "@fastify/cors": "8.1.0",
"@fastify/env": "4.1.0", "@fastify/env": "4.1.0",
"@fastify/jwt": "6.3.2", "@fastify/jwt": "6.3.2",
"@fastify/static": "6.5.0", "@fastify/static": "6.5.0",
"@iarna/toml": "2.2.5", "@iarna/toml": "2.2.5",
"@ladjs/graceful": "3.0.2",
"@prisma/client": "3.15.2", "@prisma/client": "3.15.2",
"axios": "0.27.2", "axios": "0.27.2",
"bcryptjs": "2.4.3", "bcryptjs": "2.4.3",
"bree": "9.1.2", "bree": "9.1.2",
"cabin": "9.1.2", "cabin": "9.1.2",
"compare-versions": "4.1.3", "compare-versions": "4.1.4",
"cuid": "2.1.8", "cuid": "2.1.8",
"dayjs": "1.11.4", "dayjs": "1.11.5",
"dockerode": "3.3.3", "dockerode": "3.3.4",
"dotenv-extended": "2.9.0", "dotenv-extended": "2.9.0",
"fastify": "4.4.0", "execa": "6.1.0",
"fastify-plugin": "4.1.0", "fastify": "4.5.2",
"fastify-plugin": "4.2.0",
"generate-password": "1.7.0", "generate-password": "1.7.0",
"get-port": "6.1.2",
"got": "12.3.1", "got": "12.3.1",
"is-ip": "5.0.0", "is-ip": "5.0.0",
"is-port-reachable": "4.0.0", "is-port-reachable": "4.0.0",
@@ -43,19 +44,20 @@
"jsonwebtoken": "8.5.1", "jsonwebtoken": "8.5.1",
"node-forge": "1.3.1", "node-forge": "1.3.1",
"node-os-utils": "1.3.7", "node-os-utils": "1.3.7",
"p-queue": "7.3.0", "p-all": "4.0.0",
"p-throttle": "5.0.0",
"public-ip": "6.0.1", "public-ip": "6.0.1",
"ssh-config": "4.1.6", "ssh-config": "4.1.6",
"strip-ansi": "7.0.1", "strip-ansi": "7.0.1",
"unique-names-generator": "4.7.1" "unique-names-generator": "4.7.1"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "18.6.5", "@types/node": "18.7.13",
"@types/node-os-utils": "1.3.0", "@types/node-os-utils": "1.3.0",
"@typescript-eslint/eslint-plugin": "5.33.0", "@typescript-eslint/eslint-plugin": "5.35.1",
"@typescript-eslint/parser": "5.33.0", "@typescript-eslint/parser": "5.35.1",
"esbuild": "0.15.0", "esbuild": "0.15.5",
"eslint": "8.21.0", "eslint": "8.22.0",
"eslint-config-prettier": "8.5.0", "eslint-config-prettier": "8.5.0",
"eslint-plugin-prettier": "4.2.1", "eslint-plugin-prettier": "4.2.1",
"nodemon": "2.0.19", "nodemon": "2.0.19",

View File

@@ -0,0 +1,13 @@
-- CreateTable
CREATE TABLE "Searxng" (
"id" TEXT NOT NULL PRIMARY KEY,
"secretKey" TEXT NOT NULL,
"redisPassword" TEXT NOT NULL,
"serviceId" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
CONSTRAINT "Searxng_serviceId_fkey" FOREIGN KEY ("serviceId") REFERENCES "Service" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateIndex
CREATE UNIQUE INDEX "Searxng_serviceId_key" ON "Searxng"("serviceId");

View File

@@ -0,0 +1,29 @@
-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Setting" (
"id" TEXT NOT NULL PRIMARY KEY,
"fqdn" TEXT,
"isRegistrationEnabled" BOOLEAN NOT NULL DEFAULT false,
"dualCerts" BOOLEAN NOT NULL DEFAULT false,
"minPort" INTEGER NOT NULL DEFAULT 9000,
"maxPort" INTEGER NOT NULL DEFAULT 9100,
"proxyPassword" TEXT NOT NULL,
"proxyUser" TEXT NOT NULL,
"proxyHash" TEXT,
"isAutoUpdateEnabled" BOOLEAN NOT NULL DEFAULT false,
"isDNSCheckEnabled" BOOLEAN NOT NULL DEFAULT true,
"DNSServers" TEXT,
"isTraefikUsed" BOOLEAN NOT NULL DEFAULT true,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
"ipv4" TEXT,
"ipv6" TEXT,
"arch" TEXT,
"concurrentBuilds" INTEGER NOT NULL DEFAULT 1
);
INSERT INTO "new_Setting" ("DNSServers", "arch", "createdAt", "dualCerts", "fqdn", "id", "ipv4", "ipv6", "isAutoUpdateEnabled", "isDNSCheckEnabled", "isRegistrationEnabled", "isTraefikUsed", "maxPort", "minPort", "proxyHash", "proxyPassword", "proxyUser", "updatedAt") SELECT "DNSServers", "arch", "createdAt", "dualCerts", "fqdn", "id", "ipv4", "ipv6", "isAutoUpdateEnabled", "isDNSCheckEnabled", "isRegistrationEnabled", "isTraefikUsed", "maxPort", "minPort", "proxyHash", "proxyPassword", "proxyUser", "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

@@ -0,0 +1,24 @@
-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Build" (
"id" TEXT NOT NULL PRIMARY KEY,
"type" TEXT NOT NULL,
"applicationId" TEXT,
"destinationDockerId" TEXT,
"gitSourceId" TEXT,
"githubAppId" TEXT,
"gitlabAppId" TEXT,
"commit" TEXT,
"pullmergeRequestId" TEXT,
"forceRebuild" BOOLEAN NOT NULL DEFAULT false,
"sourceBranch" TEXT,
"branch" TEXT,
"status" TEXT DEFAULT 'queued',
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);
INSERT INTO "new_Build" ("applicationId", "branch", "commit", "createdAt", "destinationDockerId", "gitSourceId", "githubAppId", "gitlabAppId", "id", "status", "type", "updatedAt") SELECT "applicationId", "branch", "commit", "createdAt", "destinationDockerId", "gitSourceId", "githubAppId", "gitlabAppId", "id", "status", "type", "updatedAt" FROM "Build";
DROP TABLE "Build";
ALTER TABLE "new_Build" RENAME TO "Build";
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON;

View File

@@ -27,6 +27,7 @@ model Setting {
ipv4 String? ipv4 String?
ipv6 String? ipv6 String?
arch String? arch String?
concurrentBuilds Int @default(1)
} }
model User { model User {
@@ -197,6 +198,9 @@ model Build {
githubAppId String? githubAppId String?
gitlabAppId String? gitlabAppId String?
commit String? commit String?
pullmergeRequestId String?
forceRebuild Boolean @default(false)
sourceBranch String?
branch String? branch String?
status String? @default("queued") status String? @default("queued")
createdAt DateTime @default(now()) createdAt DateTime @default(now())
@@ -327,23 +331,23 @@ model Service {
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
destinationDocker DestinationDocker? @relation(fields: [destinationDockerId], references: [id]) destinationDocker DestinationDocker? @relation(fields: [destinationDockerId], references: [id])
fider Fider?
ghost Ghost?
glitchTip GlitchTip?
hasura Hasura?
meiliSearch MeiliSearch?
minio Minio?
moodle Moodle?
plausibleAnalytics PlausibleAnalytics?
persistentStorage ServicePersistentStorage[] persistentStorage ServicePersistentStorage[]
serviceSecret ServiceSecret[] serviceSecret ServiceSecret[]
umami Umami? teams Team[]
vscodeserver Vscodeserver?
wordpress Wordpress?
appwrite Appwrite?
teams Team[] fider Fider?
ghost Ghost?
glitchTip GlitchTip?
hasura Hasura?
meiliSearch MeiliSearch?
minio Minio?
moodle Moodle?
plausibleAnalytics PlausibleAnalytics?
umami Umami?
vscodeserver Vscodeserver?
wordpress Wordpress?
appwrite Appwrite?
searxng Searxng?
} }
model PlausibleAnalytics { model PlausibleAnalytics {
@@ -545,3 +549,13 @@ model GlitchTip {
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
service Service @relation(fields: [serviceId], references: [id]) service Service @relation(fields: [serviceId], references: [id])
} }
model Searxng {
id String @id @default(cuid())
secretKey String
redisPassword String
serviceId String @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
service Service @relation(fields: [serviceId], references: [id])
}

View File

@@ -5,11 +5,10 @@ import env from '@fastify/env';
import cookie from '@fastify/cookie'; import cookie from '@fastify/cookie';
import path, { join } from 'path'; import path, { join } from 'path';
import autoLoad from '@fastify/autoload'; import autoLoad from '@fastify/autoload';
import { asyncExecShell, isDev, listSettings, prisma, version } from './lib/common'; import { asyncExecShell, asyncSleep, isDev, listSettings, prisma, version } from './lib/common';
import { scheduler } from './lib/scheduler'; import { scheduler } from './lib/scheduler';
import axios from 'axios';
import compareVersions from 'compare-versions'; import compareVersions from 'compare-versions';
import Graceful from '@ladjs/graceful'
declare module 'fastify' { declare module 'fastify' {
interface FastifyInstance { interface FastifyInstance {
config: { config: {
@@ -104,49 +103,39 @@ fastify.listen({ port, host }, async (err: any, address: any) => {
} }
console.log(`Coolify's API is listening on ${host}:${port}`); console.log(`Coolify's API is listening on ${host}:${port}`);
await initServer(); await initServer();
await scheduler.start('deployApplication');
await scheduler.start('cleanupStorage');
await scheduler.start('cleanupPrismaEngines');
await scheduler.start('checkProxies');
// Check if no build is running const graceful = new Graceful({ brees: [scheduler] });
graceful.listen();
// Check for update
setInterval(async () => { setInterval(async () => {
const { isAutoUpdateEnabled } = await prisma.setting.findFirst(); if (!scheduler.workers.has('deployApplication')) {
if (isAutoUpdateEnabled) { scheduler.run('deployApplication');
const currentVersion = version;
const { data: versions } = await axios
.get(
`https://get.coollabs.io/versions.json`
, {
params: {
appId: process.env['COOLIFY_APP_ID'] || undefined,
version: currentVersion
}
})
const latestVersion = versions['coolify'].main.version;
const isUpdateAvailable = compareVersions(latestVersion, currentVersion);
if (isUpdateAvailable === 1) {
if (scheduler.workers.has('deployApplication')) {
scheduler.workers.get('deployApplication').postMessage("status:autoUpdater");
}
}
} }
if (!scheduler.workers.has('infrastructure')) {
scheduler.run('infrastructure');
}
}, 2000)
// autoUpdater
setInterval(async () => {
scheduler.workers.has('infrastructure') && scheduler.workers.get('infrastructure').postMessage("action:autoUpdater")
}, isDev ? 5000 : 60000 * 15) }, isDev ? 5000 : 60000 * 15)
// Cleanup storage // cleanupStorage
setInterval(async () => { setInterval(async () => {
if (scheduler.workers.has('deployApplication')) { scheduler.workers.has('infrastructure') && scheduler.workers.get('infrastructure').postMessage("action:cleanupStorage")
scheduler.workers.get('deployApplication').postMessage("status:cleanupStorage"); }, isDev ? 6000 : 60000 * 10)
}
}, isDev ? 5000 : 60000 * 10) // checkProxies
setInterval(async () => {
scheduler.workers.has('infrastructure') && scheduler.workers.get('infrastructure').postMessage("action:checkProxies")
}, 10000)
// cleanupPrismaEngines
// setInterval(async () => {
// scheduler.workers.has('infrastructure') && scheduler.workers.get('infrastructure').postMessage("action:cleanupPrismaEngines")
// }, 60000)
scheduler.on('worker deleted', async (name) => {
if (name === 'autoUpdater' || name === 'cleanupStorage') {
if (!scheduler.workers.has('deployApplication')) await scheduler.start('deployApplication');
}
});
await getArch(); await getArch();
await getIPAddress(); await getIPAddress();
}); });
@@ -170,6 +159,12 @@ async function initServer() {
try { try {
await asyncExecShell(`docker network create --attachable coolify`); await asyncExecShell(`docker network create --attachable coolify`);
} catch (error) { } } catch (error) { }
try {
const isOlder = compareVersions('3.8.1', version);
if (isOlder === -1) {
await prisma.build.updateMany({ where: { status: { in: ['running', 'queued'] } }, data: { status: 'failed' } });
}
} catch (error) { }
} }
async function getArch() { async function getArch() {
try { try {

View File

@@ -1,43 +0,0 @@
import axios from 'axios';
import compareVersions from 'compare-versions';
import { parentPort } from 'node:worker_threads';
import { asyncExecShell, asyncSleep, isDev, prisma, version } from '../lib/common';
(async () => {
if (parentPort) {
try {
const currentVersion = version;
const { data: versions } = await axios
.get(
`https://get.coollabs.io/versions.json`
, {
params: {
appId: process.env['COOLIFY_APP_ID'] || undefined,
version: currentVersion
}
})
const latestVersion = versions['coolify'].main.version;
const isUpdateAvailable = compareVersions(latestVersion, currentVersion);
if (isUpdateAvailable === 1) {
const activeCount = 0
if (activeCount === 0) {
if (!isDev) {
console.log(`Updating Coolify to ${latestVersion}.`);
await asyncExecShell(`docker pull coollabsio/coolify:${latestVersion}`);
await asyncExecShell(`env | grep COOLIFY > .env`);
await asyncExecShell(
`docker run --rm -tid --env-file .env -v /var/run/docker.sock:/var/run/docker.sock -v coolify-db coollabsio/coolify:${latestVersion} /bin/sh -c "env | grep COOLIFY > .env && echo 'TAG=${latestVersion}' >> .env && docker stop -t 0 coolify && docker rm coolify && docker compose up -d --force-recreate"`
);
} else {
console.log('Updating (not really in dev mode).');
}
}
}
} catch (error) {
console.log(error);
} finally {
await prisma.$disconnect();
}
} else process.exit(0);
})();

View File

@@ -1,96 +0,0 @@
import { parentPort } from 'node:worker_threads';
import { prisma, startTraefikTCPProxy, generateDatabaseConfiguration, startTraefikProxy, executeDockerCmd, listSettings } from '../lib/common';
import { checkContainer } from '../lib/docker';
(async () => {
if (parentPort) {
try {
const { arch } = await listSettings();
// Coolify Proxy local
const engine = '/var/run/docker.sock';
const localDocker = await prisma.destinationDocker.findFirst({
where: { engine, network: 'coolify' }
});
if (localDocker && localDocker.isCoolifyProxyUsed) {
// Remove HAProxy
const found = await checkContainer({ dockerId: localDocker.id, container: 'coolify-haproxy' });
if (found) {
await executeDockerCmd({
dockerId: localDocker.id,
command: `docker stop -t 0 coolify-haproxy && docker rm coolify-haproxy`
})
}
await startTraefikProxy(localDocker.id);
}
// TCP Proxies
const databasesWithPublicPort = await prisma.database.findMany({
where: { publicPort: { not: null } },
include: { settings: true, destinationDocker: true }
});
for (const database of databasesWithPublicPort) {
const { destinationDockerId, destinationDocker, publicPort, id } = database;
if (destinationDockerId && destinationDocker.isCoolifyProxyUsed) {
const { privatePort } = generateDatabaseConfiguration(database, arch);
// Remove HAProxy
const found = await checkContainer({
dockerId: localDocker.id, container: `haproxy-for-${publicPort}`
});
if (found) {
await executeDockerCmd({
dockerId: localDocker.id,
command: `docker stop -t 0 haproxy-for-${publicPort} && docker rm haproxy-for-${publicPort}`
})
}
await startTraefikTCPProxy(destinationDocker, id, publicPort, privatePort);
}
}
const wordpressWithFtp = await prisma.wordpress.findMany({
where: { ftpPublicPort: { not: null } },
include: { service: { include: { destinationDocker: true } } }
});
for (const ftp of wordpressWithFtp) {
const { service, ftpPublicPort } = ftp;
const { destinationDockerId, destinationDocker, id } = service;
if (destinationDockerId && destinationDocker.isCoolifyProxyUsed) {
// Remove HAProxy
const found = await checkContainer({ dockerId: localDocker.id, container: `haproxy-for-${ftpPublicPort}` });
if (found) {
await executeDockerCmd({
dockerId: localDocker.id,
command: `docker stop -t 0 haproxy -for-${ftpPublicPort} && docker rm haproxy-for-${ftpPublicPort}`
})
}
await startTraefikTCPProxy(destinationDocker, id, ftpPublicPort, 22, 'wordpressftp');
}
}
// HTTP Proxies
const minioInstances = await prisma.minio.findMany({
where: { publicPort: { not: null } },
include: { service: { include: { destinationDocker: true } } }
});
for (const minio of minioInstances) {
const { service, publicPort } = minio;
const { destinationDockerId, destinationDocker, id } = service;
if (destinationDockerId && destinationDocker.isCoolifyProxyUsed) {
// Remove HAProxy
const found = await checkContainer({ dockerId: localDocker.id, container: `${id}-${publicPort}` });
if (found) {
await executeDockerCmd({
dockerId: localDocker.id,
command: `docker stop -t 0 ${id}-${publicPort} && docker rm ${id}-${publicPort} `
})
}
await startTraefikTCPProxy(destinationDocker, id, publicPort, 9000);
}
}
} catch (error) {
} finally {
await prisma.$disconnect();
}
} else process.exit(0);
})();

View File

@@ -1,19 +0,0 @@
import { parentPort } from 'node:worker_threads';
import { asyncExecShell, isDev, prisma } from '../lib/common';
(async () => {
if (parentPort) {
if (!isDev) {
try {
const { stdout } = await asyncExecShell(`ps -ef | grep /app/prisma-engines/query-engine | grep -v grep | wc -l | xargs`)
if (stdout.trim() != null && stdout.trim() != '' && Number(stdout.trim()) > 1) {
await asyncExecShell(`killall -q -e /app/prisma-engines/query-engine -o 10m`)
}
} catch (error) {
console.log(error);
} finally {
await prisma.$disconnect();
}
}
} else process.exit(0);
})();

View File

@@ -1,60 +0,0 @@
import { parentPort } from 'node:worker_threads';
import { asyncExecShell, cleanupDockerStorage, executeDockerCmd, isDev, prisma, version } from '../lib/common';
(async () => {
if (parentPort) {
const destinationDockers = await prisma.destinationDocker.findMany();
let enginesDone = new Set()
for (const destination of destinationDockers) {
if (enginesDone.has(destination.engine) || enginesDone.has(destination.remoteIpAddress)) return
if (destination.engine) enginesDone.add(destination.engine)
if (destination.remoteIpAddress) enginesDone.add(destination.remoteIpAddress)
let lowDiskSpace = false;
try {
let stdout = null
if (!isDev) {
const output = await executeDockerCmd({ dockerId: destination.id, command: `CONTAINER=$(docker ps -lq | head -1) && docker exec $CONTAINER sh -c 'df -kPT /'` })
stdout = output.stdout;
} else {
const output = await asyncExecShell(
`df -kPT /`
);
stdout = output.stdout;
}
let lines = stdout.trim().split('\n');
let header = lines[0];
let regex =
/^Filesystem\s+|Type\s+|1024-blocks|\s+Used|\s+Available|\s+Capacity|\s+Mounted on\s*$/g;
const boundaries = [];
let match;
while ((match = regex.exec(header))) {
boundaries.push(match[0].length);
}
boundaries[boundaries.length - 1] = -1;
const data = lines.slice(1).map((line) => {
const cl = boundaries.map((boundary) => {
const column = boundary > 0 ? line.slice(0, boundary) : line;
line = line.slice(boundary);
return column.trim();
});
return {
capacity: Number.parseInt(cl[5], 10) / 100
};
});
if (data.length > 0) {
const { capacity } = data[0];
if (capacity > 0.8) {
lowDiskSpace = true;
}
}
} catch (error) {
console.log(error);
}
await cleanupDockerStorage(destination.id, lowDiskSpace, false)
}
await prisma.$disconnect();
} else process.exit(0);
})();

View File

@@ -10,204 +10,270 @@ import * as buildpacks from '../lib/buildPacks';
(async () => { (async () => {
if (parentPort) { if (parentPort) {
const concurrency = 1
const PQueue = await import('p-queue');
const queue = new PQueue.default({ concurrency });
parentPort.on('message', async (message) => { parentPort.on('message', async (message) => {
if (parentPort) { if (message === 'error') throw new Error('oops');
if (message === 'error') throw new Error('oops'); if (message === 'cancel') {
if (message === 'cancel') { parentPort.postMessage('cancelled');
parentPort.postMessage('cancelled'); await prisma.$disconnect()
return; process.exit(0);
} }
if (message === 'status:autoUpdater') { });
parentPort.postMessage({ size: queue.size, pending: queue.pending, caller: 'autoUpdater' }); const pThrottle = await import('p-throttle')
return; const throttle = pThrottle.default({
} limit: 1,
if (message === 'status:cleanupStorage') { interval: 2000
parentPort.postMessage({ size: queue.size, pending: queue.pending, caller: 'cleanupStorage' }); });
return;
}
await queue.add(async () => {
const { const th = throttle(async () => {
id: applicationId, try {
repository, const queuedBuilds = await prisma.build.findMany({ where: { status: 'queued' }, orderBy: { createdAt: 'asc' } });
name, const { concurrentBuilds } = await prisma.setting.findFirst({})
destinationDocker, if (queuedBuilds.length > 0) {
destinationDockerId, parentPort.postMessage({ deploying: true });
gitSource, const concurrency = concurrentBuilds;
build_id: buildId, const pAll = await import('p-all');
configHash, const actions = []
fqdn,
projectId, for (const queueBuild of queuedBuilds) {
secrets, actions.push(async () => {
phpModules, const application = await prisma.application.findUnique({ where: { id: queueBuild.applicationId }, include: { destinationDocker: true, gitSource: { include: { githubApp: true, gitlabApp: true } }, persistentStorage: true, secrets: true, settings: true, teams: true } })
type, const { id: buildId, type, sourceBranch = null, pullmergeRequestId = null, forceRebuild } = queueBuild
pullmergeRequestId = null, const {
sourceBranch = null, id: applicationId,
settings, repository,
persistentStorage, name,
pythonWSGI, destinationDocker,
pythonModule, destinationDockerId,
pythonVariable, gitSource,
denoOptions, configHash,
exposePort, fqdn,
baseImage, projectId,
baseBuildImage, secrets,
deploymentType, phpModules,
forceRebuild settings,
} = message persistentStorage,
let {
branch,
buildPack,
port,
installCommand,
buildCommand,
startCommand,
baseDirectory,
publishDirectory,
dockerFileLocation,
denoMainFile
} = message
const currentHash = crypto
.createHash('sha256')
.update(
JSON.stringify({
pythonWSGI, pythonWSGI,
pythonModule, pythonModule,
pythonVariable, pythonVariable,
deploymentType,
denoOptions, denoOptions,
exposePort,
baseImage, baseImage,
baseBuildImage, baseBuildImage,
deploymentType,
} = application
let {
branch,
buildPack, buildPack,
port, port,
exposePort,
installCommand, installCommand,
buildCommand, buildCommand,
startCommand, startCommand,
secrets, baseDirectory,
branch, publishDirectory,
repository, dockerFileLocation,
fqdn denoMainFile
}) } = application
) const currentHash = crypto
.digest('hex'); .createHash('sha256')
try { .update(
const { debug } = settings; JSON.stringify({
if (concurrency === 1) { pythonWSGI,
await prisma.build.updateMany({ pythonModule,
where: { pythonVariable,
status: { in: ['queued', 'running'] }, deploymentType,
id: { not: buildId }, denoOptions,
applicationId, baseImage,
createdAt: { lt: new Date(new Date().getTime() - 10 * 1000) } baseBuildImage,
}, buildPack,
data: { status: 'failed' } port,
}); exposePort,
} installCommand,
let imageId = applicationId; buildCommand,
let domain = getDomain(fqdn); startCommand,
const volumes = secrets,
persistentStorage?.map((storage) => { branch,
return `${applicationId}${storage.path.replace(/\//gi, '-')}:${buildPack !== 'docker' ? '/app' : '' repository,
}${storage.path}`; fqdn
}) || []; })
// Previews, we need to get the source branch and set subdomain )
if (pullmergeRequestId) { .digest('hex');
branch = sourceBranch;
domain = `${pullmergeRequestId}.${domain}`;
imageId = `${applicationId}-${pullmergeRequestId}`;
}
let deployNeeded = true;
let destinationType;
if (destinationDockerId) {
destinationType = 'docker';
}
if (destinationType === 'docker') {
await prisma.build.update({ where: { id: buildId }, data: { status: 'running' } });
const { workdir, repodir } = await createDirectories({ repository, buildId });
const configuration = await setDefaultConfiguration(message);
buildPack = configuration.buildPack;
port = configuration.port;
installCommand = configuration.installCommand;
startCommand = configuration.startCommand;
buildCommand = configuration.buildCommand;
publishDirectory = configuration.publishDirectory;
baseDirectory = configuration.baseDirectory;
dockerFileLocation = configuration.dockerFileLocation;
denoMainFile = configuration.denoMainFile;
const commit = await importers[gitSource.type]({
applicationId,
debug,
workdir,
repodir,
githubAppId: gitSource.githubApp?.id,
gitlabAppId: gitSource.gitlabApp?.id,
customPort: gitSource.customPort,
repository,
branch,
buildId,
apiUrl: gitSource.apiUrl,
htmlUrl: gitSource.htmlUrl,
projectId,
deployKeyId: gitSource.gitlabApp?.deployKeyId || null,
privateSshKey: decrypt(gitSource.gitlabApp?.privateSshKey) || null,
forPublic: gitSource.forPublic
});
if (!commit) {
throw new Error('No commit found?');
}
let tag = commit.slice(0, 7);
if (pullmergeRequestId) {
tag = `${commit.slice(0, 7)}-${pullmergeRequestId}`;
}
try { try {
await prisma.build.update({ where: { id: buildId }, data: { commit } }); const { debug } = settings;
} catch (err) { if (concurrency === 1) {
console.log(err); await prisma.build.updateMany({
} where: {
status: { in: ['queued', 'running'] },
if (!pullmergeRequestId) { id: { not: buildId },
applicationId,
if (configHash !== currentHash) { createdAt: { lt: new Date(new Date().getTime() - 10 * 1000) }
deployNeeded = true; },
if (configHash) { data: { status: 'failed' }
await saveBuildLog({ line: 'Configuration changed.', buildId, applicationId }); });
} }
} else { let imageId = applicationId;
deployNeeded = false; let domain = getDomain(fqdn);
const volumes =
persistentStorage?.map((storage) => {
return `${applicationId}${storage.path.replace(/\//gi, '-')}:${buildPack !== 'docker' ? '/app' : ''
}${storage.path}`;
}) || [];
// Previews, we need to get the source branch and set subdomain
if (pullmergeRequestId) {
branch = sourceBranch;
domain = `${pullmergeRequestId}.${domain}`;
imageId = `${applicationId}-${pullmergeRequestId}`;
} }
} else {
deployNeeded = true;
}
let imageFound = false; let deployNeeded = true;
try { let destinationType;
await executeDockerCmd({
dockerId: destinationDocker.id,
command: `docker image inspect ${applicationId}:${tag}`
})
imageFound = true;
} catch (error) {
//
}
await copyBaseConfigurationFiles(buildPack, workdir, buildId, applicationId, baseImage);
if (forceRebuild) deployNeeded = true if (destinationDockerId) {
if (!imageFound || deployNeeded) { destinationType = 'docker';
// if (true) { }
if (buildpacks[buildPack]) if (destinationType === 'docker') {
await buildpacks[buildPack]({ await prisma.build.update({ where: { id: buildId }, data: { status: 'running' } });
dockerId: destinationDocker.id, const { workdir, repodir } = await createDirectories({ repository, buildId });
buildId, const configuration = await setDefaultConfiguration(application);
buildPack = configuration.buildPack;
port = configuration.port;
installCommand = configuration.installCommand;
startCommand = configuration.startCommand;
buildCommand = configuration.buildCommand;
publishDirectory = configuration.publishDirectory;
baseDirectory = configuration.baseDirectory;
dockerFileLocation = configuration.dockerFileLocation;
denoMainFile = configuration.denoMainFile;
const commit = await importers[gitSource.type]({
applicationId, applicationId,
domain, debug,
workdir,
repodir,
githubAppId: gitSource.githubApp?.id,
gitlabAppId: gitSource.gitlabApp?.id,
customPort: gitSource.customPort,
repository,
branch,
buildId,
apiUrl: gitSource.apiUrl,
htmlUrl: gitSource.htmlUrl,
projectId,
deployKeyId: gitSource.gitlabApp?.deployKeyId || null,
privateSshKey: decrypt(gitSource.gitlabApp?.privateSshKey) || null,
forPublic: gitSource.forPublic
});
if (!commit) {
throw new Error('No commit found?');
}
let tag = commit.slice(0, 7);
if (pullmergeRequestId) {
tag = `${commit.slice(0, 7)}-${pullmergeRequestId}`;
}
try {
await prisma.build.update({ where: { id: buildId }, data: { commit } });
} catch (err) {
console.log(err);
}
if (!pullmergeRequestId) {
if (configHash !== currentHash) {
deployNeeded = true;
if (configHash) {
await saveBuildLog({ line: 'Configuration changed.', buildId, applicationId });
}
} else {
deployNeeded = false;
}
} else {
deployNeeded = true;
}
let imageFound = false;
try {
await executeDockerCmd({
dockerId: destinationDocker.id,
command: `docker image inspect ${applicationId}:${tag}`
})
imageFound = true;
} catch (error) {
//
}
await copyBaseConfigurationFiles(buildPack, workdir, buildId, applicationId, baseImage);
if (forceRebuild) deployNeeded = true
if (!imageFound || deployNeeded) {
// if (true) {
if (buildpacks[buildPack])
await buildpacks[buildPack]({
dockerId: destinationDocker.id,
buildId,
applicationId,
domain,
name,
type,
pullmergeRequestId,
buildPack,
repository,
branch,
projectId,
publishDirectory,
debug,
commit,
tag,
workdir,
port: exposePort ? `${exposePort}:${port}` : port,
installCommand,
buildCommand,
startCommand,
baseDirectory,
secrets,
phpModules,
pythonWSGI,
pythonModule,
pythonVariable,
dockerFileLocation,
denoMainFile,
denoOptions,
baseImage,
baseBuildImage,
deploymentType
});
else {
await saveBuildLog({ line: `Build pack ${buildPack} not found`, buildId, applicationId });
throw new Error(`Build pack ${buildPack} not found.`);
}
} else {
await saveBuildLog({ line: 'Build image already available - no rebuild required.', buildId, applicationId });
}
try {
await executeDockerCmd({ dockerId: destinationDocker.id, command: `docker stop -t 0 ${imageId}` })
await executeDockerCmd({ dockerId: destinationDocker.id, command: `docker rm ${imageId}` })
} catch (error) {
//
}
const envs = [
`PORT=${port}`
];
if (secrets.length > 0) {
secrets.forEach((secret) => {
secret.value = decrypt(secret.value)
if (pullmergeRequestId) {
if (secret.isPRMRSecret) {
envs.push(`${secret.name}=${secret.value}`);
}
} else {
if (!secret.isPRMRSecret) {
envs.push(`${secret.name}=${secret.value}`);
}
}
});
}
await fs.writeFile(`${workdir}/.env`, envs.join('\n'));
const labels = makeLabelForStandaloneApplication({
applicationId,
fqdn,
name, name,
type, type,
pullmergeRequestId, pullmergeRequestId,
@@ -215,148 +281,93 @@ import * as buildpacks from '../lib/buildPacks';
repository, repository,
branch, branch,
projectId, projectId,
publishDirectory,
debug,
commit,
tag,
workdir,
port: exposePort ? `${exposePort}:${port}` : port, port: exposePort ? `${exposePort}:${port}` : port,
commit,
installCommand, installCommand,
buildCommand, buildCommand,
startCommand, startCommand,
baseDirectory, baseDirectory,
secrets, publishDirectory
phpModules,
pythonWSGI,
pythonModule,
pythonVariable,
dockerFileLocation,
denoMainFile,
denoOptions,
baseImage,
baseBuildImage,
deploymentType
}); });
else { let envFound = false;
await saveBuildLog({ line: `Build pack ${buildPack} not found`, buildId, applicationId }); try {
throw new Error(`Build pack ${buildPack} not found.`); envFound = !!(await fs.stat(`${workdir}/.env`));
} } catch (error) {
} else { //
await saveBuildLog({ line: 'Build image already available - no rebuild required.', buildId, applicationId });
}
try {
await executeDockerCmd({ dockerId: destinationDocker.id, command: `docker stop -t 0 ${imageId}` })
await executeDockerCmd({ dockerId: destinationDocker.id, command: `docker rm ${imageId}` })
} catch (error) {
//
}
const envs = [
`PORT=${port}`
];
if (secrets.length > 0) {
secrets.forEach((secret) => {
if (pullmergeRequestId) {
if (secret.isPRMRSecret) {
envs.push(`${secret.name}=${secret.value}`);
}
} else {
if (!secret.isPRMRSecret) {
envs.push(`${secret.name}=${secret.value}`);
}
} }
}); try {
await saveBuildLog({ line: 'Deployment started.', buildId, applicationId });
const composeVolumes = volumes.map((volume) => {
return {
[`${volume.split(':')[0]}`]: {
name: volume.split(':')[0]
}
};
});
const composeFile = {
version: '3.8',
services: {
[imageId]: {
image: `${applicationId}:${tag}`,
container_name: imageId,
volumes,
env_file: envFound ? [`${workdir}/.env`] : [],
labels,
depends_on: [],
expose: [port],
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
// logging: {
// driver: 'fluentd',
// },
...defaultComposeConfiguration(destinationDocker.network),
}
},
networks: {
[destinationDocker.network]: {
external: true
}
},
volumes: Object.assign({}, ...composeVolumes)
};
await fs.writeFile(`${workdir}/docker-compose.yml`, yaml.dump(composeFile));
await executeDockerCmd({ dockerId: destinationDocker.id, command: `docker compose --project-directory ${workdir} up -d` })
await saveBuildLog({ line: 'Deployment successful!', buildId, applicationId });
} catch (error) {
await saveBuildLog({ line: error, buildId, applicationId });
await prisma.build.updateMany({
where: { id: buildId, status: { in: ['queued', 'running'] } },
data: { status: 'failed' }
});
throw new Error(error);
}
await saveBuildLog({ line: 'Proxy will be updated shortly.', buildId, applicationId });
await prisma.build.update({ where: { id: buildId }, data: { status: 'success' } });
if (!pullmergeRequestId) await prisma.application.update({
where: { id: applicationId },
data: { configHash: currentHash }
});
}
} }
await fs.writeFile(`${workdir}/.env`, envs.join('\n')); catch (error) {
const labels = makeLabelForStandaloneApplication({ await prisma.build.updateMany({
applicationId, where: { id: buildId, status: { in: ['queued', 'running'] } },
fqdn,
name,
type,
pullmergeRequestId,
buildPack,
repository,
branch,
projectId,
port: exposePort ? `${exposePort}:${port}` : port,
commit,
installCommand,
buildCommand,
startCommand,
baseDirectory,
publishDirectory
});
let envFound = false;
try {
envFound = !!(await fs.stat(`${workdir}/.env`));
} catch (error) {
//
}
try {
await saveBuildLog({ line: 'Deployment started.', buildId, applicationId });
const composeVolumes = volumes.map((volume) => {
return {
[`${volume.split(':')[0]}`]: {
name: volume.split(':')[0]
}
};
});
const composeFile = {
version: '3.8',
services: {
[imageId]: {
image: `${applicationId}:${tag}`,
container_name: imageId,
volumes,
env_file: envFound ? [`${workdir}/.env`] : [],
labels,
depends_on: [],
expose: [port],
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
// logging: {
// driver: 'fluentd',
// },
...defaultComposeConfiguration(destinationDocker.network),
}
},
networks: {
[destinationDocker.network]: {
external: true
}
},
volumes: Object.assign({}, ...composeVolumes)
};
await fs.writeFile(`${workdir}/docker-compose.yml`, yaml.dump(composeFile));
await executeDockerCmd({ dockerId: destinationDocker.id, command: `docker compose --project-directory ${workdir} up -d` })
await saveBuildLog({ line: 'Deployment successful!', buildId, applicationId });
} catch (error) {
await saveBuildLog({ line: error, buildId, applicationId });
await prisma.build.update({
where: { id: message.build_id },
data: { status: 'failed' } data: { status: 'failed' }
}); });
throw new Error(error); await saveBuildLog({ line: error, buildId, applicationId });
} }
await saveBuildLog({ line: 'Proxy will be updated shortly.', buildId, applicationId });
await prisma.build.update({ where: { id: message.build_id }, data: { status: 'success' } });
if (!pullmergeRequestId) await prisma.application.update({
where: { id: applicationId },
data: { configHash: currentHash }
});
}
}
catch (error) {
await prisma.build.update({
where: { id: message.build_id },
data: { status: 'failed' }
}); });
await saveBuildLog({ line: error, buildId, applicationId });
} finally {
await prisma.$disconnect();
} }
}); await pAll.default(actions, { concurrency })
await prisma.$disconnect(); }
} catch (error) {
} finally {
} }
}); })
while (true) {
await th()
}
} else process.exit(0); } else process.exit(0);
})(); })();

View File

@@ -0,0 +1,216 @@
import { parentPort } from 'node:worker_threads';
import axios from 'axios';
import compareVersions from 'compare-versions';
import { asyncExecShell, cleanupDockerStorage, executeDockerCmd, isDev, prisma, startTraefikTCPProxy, generateDatabaseConfiguration, startTraefikProxy, listSettings, version } from '../lib/common';
async function disconnect() {
await prisma.$disconnect();
}
async function autoUpdater() {
try {
const currentVersion = version;
const { data: versions } = await axios
.get(
`https://get.coollabs.io/versions.json`
, {
params: {
appId: process.env['COOLIFY_APP_ID'] || undefined,
version: currentVersion
}
})
const latestVersion = versions['coolify'].main.version;
const isUpdateAvailable = compareVersions(latestVersion, currentVersion);
if (isUpdateAvailable === 1) {
const activeCount = 0
if (activeCount === 0) {
if (!isDev) {
console.log(`Updating Coolify to ${latestVersion}.`);
await asyncExecShell(`docker pull coollabsio/coolify:${latestVersion}`);
await asyncExecShell(`env | grep COOLIFY > .env`);
await asyncExecShell(
`docker run --rm -tid --env-file .env -v /var/run/docker.sock:/var/run/docker.sock -v coolify-db coollabsio/coolify:${latestVersion} /bin/sh -c "env | grep COOLIFY > .env && echo 'TAG=${latestVersion}' >> .env && docker stop -t 0 coolify && docker rm coolify && docker compose up -d --force-recreate"`
);
} else {
console.log('Updating (not really in dev mode).');
}
}
}
} catch (error) {
console.log(error);
}
}
async function checkProxies() {
try {
const { default: isReachable } = await import('is-port-reachable');
let portReachable;
const { arch, ipv4, ipv6 } = await listSettings();
// Coolify Proxy local
const engine = '/var/run/docker.sock';
const localDocker = await prisma.destinationDocker.findFirst({
where: { engine, network: 'coolify' }
});
if (localDocker && localDocker.isCoolifyProxyUsed) {
portReachable = await isReachable(80, { host: ipv4 || ipv6 })
if (!portReachable) {
await startTraefikProxy(localDocker.id);
}
}
// TCP Proxies
const databasesWithPublicPort = await prisma.database.findMany({
where: { publicPort: { not: null } },
include: { settings: true, destinationDocker: true }
});
for (const database of databasesWithPublicPort) {
const { destinationDockerId, destinationDocker, publicPort, id } = database;
if (destinationDockerId && destinationDocker.isCoolifyProxyUsed) {
const { privatePort } = generateDatabaseConfiguration(database, arch);
portReachable = await isReachable(publicPort, { host: destinationDocker.remoteIpAddress || ipv4 || ipv6 })
if (!portReachable) {
await startTraefikTCPProxy(destinationDocker, id, publicPort, privatePort);
}
}
}
const wordpressWithFtp = await prisma.wordpress.findMany({
where: { ftpPublicPort: { not: null } },
include: { service: { include: { destinationDocker: true } } }
});
for (const ftp of wordpressWithFtp) {
const { service, ftpPublicPort } = ftp;
const { destinationDockerId, destinationDocker, id } = service;
if (destinationDockerId && destinationDocker.isCoolifyProxyUsed) {
portReachable = await isReachable(ftpPublicPort, { host: destinationDocker.remoteIpAddress || ipv4 || ipv6 })
if (!portReachable) {
await startTraefikTCPProxy(destinationDocker, id, ftpPublicPort, 22, 'wordpressftp');
}
}
}
// HTTP Proxies
const minioInstances = await prisma.minio.findMany({
where: { publicPort: { not: null } },
include: { service: { include: { destinationDocker: true } } }
});
for (const minio of minioInstances) {
const { service, publicPort } = minio;
const { destinationDockerId, destinationDocker, id } = service;
if (destinationDockerId && destinationDocker.isCoolifyProxyUsed) {
portReachable = await isReachable(publicPort, { host: destinationDocker.remoteIpAddress || ipv4 || ipv6 })
if (!portReachable) {
await startTraefikTCPProxy(destinationDocker, id, publicPort, 9000);
}
}
}
} catch (error) {
}
}
async function cleanupPrismaEngines() {
if (!isDev) {
try {
const { stdout } = await asyncExecShell(`ps -ef | grep /app/prisma-engines/query-engine | grep -v grep | wc -l | xargs`)
if (stdout.trim() != null && stdout.trim() != '' && Number(stdout.trim()) > 1) {
await asyncExecShell(`killall -q -e /app/prisma-engines/query-engine -o 1m`)
}
} catch (error) {
console.log(error);
}
}
}
async function cleanupStorage() {
const destinationDockers = await prisma.destinationDocker.findMany();
let enginesDone = new Set()
for (const destination of destinationDockers) {
if (enginesDone.has(destination.engine) || enginesDone.has(destination.remoteIpAddress)) return
if (destination.engine) enginesDone.add(destination.engine)
if (destination.remoteIpAddress) enginesDone.add(destination.remoteIpAddress)
let lowDiskSpace = false;
try {
let stdout = null
if (!isDev) {
const output = await executeDockerCmd({ dockerId: destination.id, command: `CONTAINER=$(docker ps -lq | head -1) && docker exec $CONTAINER sh -c 'df -kPT /'` })
stdout = output.stdout;
} else {
const output = await asyncExecShell(
`df -kPT /`
);
stdout = output.stdout;
}
let lines = stdout.trim().split('\n');
let header = lines[0];
let regex =
/^Filesystem\s+|Type\s+|1024-blocks|\s+Used|\s+Available|\s+Capacity|\s+Mounted on\s*$/g;
const boundaries = [];
let match;
while ((match = regex.exec(header))) {
boundaries.push(match[0].length);
}
boundaries[boundaries.length - 1] = -1;
const data = lines.slice(1).map((line) => {
const cl = boundaries.map((boundary) => {
const column = boundary > 0 ? line.slice(0, boundary) : line;
line = line.slice(boundary);
return column.trim();
});
return {
capacity: Number.parseInt(cl[5], 10) / 100
};
});
if (data.length > 0) {
const { capacity } = data[0];
if (capacity > 0.8) {
lowDiskSpace = true;
}
}
} catch (error) {
console.log(error);
}
await cleanupDockerStorage(destination.id, lowDiskSpace, false)
}
}
(async () => {
let status = {
cleanupStorage: false,
autoUpdater: false
}
if (parentPort) {
parentPort.on('message', async (message) => {
if (parentPort) {
if (message === 'error') throw new Error('oops');
if (message === 'cancel') {
parentPort.postMessage('cancelled');
process.exit(1);
}
if (message === 'action:cleanupStorage') {
if (!status.autoUpdater) {
status.cleanupStorage = true
await cleanupStorage();
status.cleanupStorage = false
}
return;
}
if (message === 'action:cleanupPrismaEngines') {
await cleanupPrismaEngines();
return;
}
if (message === 'action:checkProxies') {
await checkProxies();
return;
}
if (message === 'action:autoUpdater') {
if (!status.cleanupStorage) {
status.autoUpdater = true
await autoUpdater();
status.autoUpdater = false
}
return;
}
}
});
} else process.exit(0);
})();

View File

@@ -541,9 +541,6 @@ export async function buildImage({
} else { } else {
await saveBuildLog({ line: `Building image started.`, buildId, applicationId }); await saveBuildLog({ line: `Building image started.`, buildId, applicationId });
} }
if (debug) {
await saveBuildLog({ line: `\n###############\nIMPORTANT: Due to some issues during implementing Remote Docker Engine, the builds logs are not streamed at the moment - but will be soon! You will see the full build log when the build is finished!\n###############`, buildId, applicationId });
}
if (!debug && isCache) { if (!debug && isCache) {
await saveBuildLog({ await saveBuildLog({
line: `Debug turned off. To see more details, allow it in the configuration.`, line: `Debug turned off. To see more details, allow it in the configuration.`,
@@ -553,54 +550,11 @@ export async function buildImage({
} }
const dockerFile = isCache ? `${dockerFileLocation}-cache` : `${dockerFileLocation}` const dockerFile = isCache ? `${dockerFileLocation}-cache` : `${dockerFileLocation}`
const cache = `${applicationId}:${tag}${isCache ? '-cache' : ''}` const cache = `${applicationId}:${tag}${isCache ? '-cache' : ''}`
const { stderr } = await executeDockerCmd({ dockerId, command: `docker build --progress plain -f ${workdir}/${dockerFile} -t ${cache} ${workdir}` }) await executeDockerCmd({ debug, buildId, applicationId, dockerId, command: `docker build --progress plain -f ${workdir}/${dockerFile} -t ${cache} ${workdir}` })
if (debug) { const { status } = await prisma.build.findUnique({ where: { id: buildId } })
const array = stderr.split('\n') if (status === 'canceled') {
for (const line of array) { throw new Error('Deployment canceled.')
if (line !== '\n') {
await saveBuildLog({
line: `${line.replace('\n', '')}`,
buildId,
applicationId
});
}
}
} }
// await new Promise((resolve, reject) => {
// const command = spawn(`docker`, ['build', '-f', `${workdir}${dockerFile}`, '-t', `${cache}`,`${workdir}`], {
// env: {
// DOCKER_HOST: 'ssh://root@95.217.178.202',
// DOCKER_BUILDKIT: '1'
// }
// });
// command.stdout.on('data', function (data) {
// console.log('stdout: ' + data);
// });
// command.stderr.on('data', function (data) {
// console.log('stderr: ' + data);
// });
// command.on('error', function (error) {
// console.log(error)
// reject(error)
// })
// command.on('exit', function (code) {
// console.log('exit code: ' + code);
// resolve(code)
// });
// })
// console.log({ stdout, stderr })
// const stream = await docker.engine.buildImage(
// { src: ['.'], context: workdir },
// {
// dockerfile: isCache ? `${dockerFileLocation}-cache` : dockerFileLocation,
// t: `${applicationId}:${tag}${isCache ? '-cache' : ''}`
// }
// );
// await streamEvents({ stream, docker, buildId, applicationId, debug });
if (isCache) { if (isCache) {
await saveBuildLog({ line: `Building cache image successful.`, buildId, applicationId }); await saveBuildLog({ line: `Building cache image successful.`, buildId, applicationId });
} else { } else {

View File

@@ -1,4 +1,4 @@
import child from 'child_process'; import { exec } from 'node:child_process'
import util from 'util'; import util from 'util';
import fs from 'fs/promises'; import fs from 'fs/promises';
import yaml from 'js-yaml'; import yaml from 'js-yaml';
@@ -16,8 +16,10 @@ import sshConfig from 'ssh-config'
import { checkContainer, removeContainer } from './docker'; import { checkContainer, removeContainer } from './docker';
import { day } from './dayjs'; import { day } from './dayjs';
import * as serviceFields from './serviceFields' import * as serviceFields from './serviceFields'
import { saveBuildLog } from './buildPacks/common';
import { scheduler } from './scheduler';
export const version = '3.7.0'; export const version = '3.8.3';
export const isDev = process.env.NODE_ENV === 'development'; export const isDev = process.env.NODE_ENV === 'development';
const algorithm = 'aes-256-ctr'; const algorithm = 'aes-256-ctr';
@@ -81,16 +83,84 @@ export const include: any = {
moodle: true, moodle: true,
appwrite: true, appwrite: true,
glitchTip: true, glitchTip: true,
searxng: true
}; };
export const uniqueName = (): string => uniqueNamesGenerator(customConfig); export const uniqueName = (): string => uniqueNamesGenerator(customConfig);
export const asyncExecShell = util.promisify(child.exec); export const asyncExecShell = util.promisify(exec);
export const asyncExecShellStream = async ({ debug, buildId, applicationId, command, engine }: { debug: boolean, buildId: string, applicationId: string, command: string, engine: string }) => {
return await new Promise(async (resolve, reject) => {
const { execaCommand } = await import('execa')
const subprocess = execaCommand(command, { env: { DOCKER_BUILDKIT: "1", DOCKER_HOST: engine } })
if (debug) {
subprocess.stdout.on('data', async (data) => {
const stdout = data.toString();
const array = stdout.split('\n')
for (const line of array) {
if (line !== '\n' && line !== '') {
await saveBuildLog({
line: `${line.replace('\n', '')}`,
buildId,
applicationId
});
}
}
})
subprocess.stderr.on('data', async (data) => {
const stderr = data.toString();
const array = stderr.split('\n')
for (const line of array) {
if (line !== '\n' && line !== '') {
await saveBuildLog({
line: `${line.replace('\n', '')}`,
buildId,
applicationId
});
}
}
})
}
subprocess.on('exit', async (code) => {
await asyncSleep(1000);
if (code === 0) {
resolve(code)
} else {
reject(code)
}
})
})
}
export const asyncSleep = (delay: number): Promise<unknown> => export const asyncSleep = (delay: number): Promise<unknown> =>
new Promise((resolve) => setTimeout(resolve, delay)); new Promise((resolve) => setTimeout(resolve, delay));
export const prisma = new PrismaClient({ export const prisma = new PrismaClient({
errorFormat: 'minimal' errorFormat: 'minimal',
// log: [
// {
// emit: 'event',
// level: 'query',
// },
// {
// emit: 'stdout',
// level: 'error',
// },
// {
// emit: 'stdout',
// level: 'info',
// },
// {
// emit: 'stdout',
// level: 'warn',
// },
// ],
}); });
// prisma.$on('query', (e) => {
// console.log({e})
// console.log('Query: ' + e.query)
// console.log('Params: ' + e.params)
// console.log('Duration: ' + e.duration + 'ms')
// })
export const base64Encode = (text: string): string => { export const base64Encode = (text: string): string => {
return Buffer.from(text).toString('base64'); return Buffer.from(text).toString('base64');
}; };
@@ -311,6 +381,17 @@ export const supportedServiceTypesAndVersions = [
main: 8000 main: 8000
} }
}, },
{
name: 'searxng',
fancyName: 'SearXNG',
baseImage: 'searxng/searxng',
images: [],
versions: ['latest'],
recommendedVersion: 'latest',
ports: {
main: 8080
}
},
]; ];
export async function checkDoubleBranch(branch: string, projectId: number): Promise<boolean> { export async function checkDoubleBranch(branch: string, projectId: number): Promise<boolean> {
@@ -545,21 +626,38 @@ export const supportedDatabaseTypesAndVersions = [
} }
]; ];
export async function getFreeSSHLocalPort(id: string): Promise<number> { export async function getFreeSSHLocalPort(id: string): Promise<number | boolean> {
const { default: getPort, portNumbers } = await import('get-port'); const { default: isReachable } = await import('is-port-reachable');
const { remoteIpAddress, sshLocalPort } = await prisma.destinationDocker.findUnique({ where: { id } }) const { remoteIpAddress, sshLocalPort } = await prisma.destinationDocker.findUnique({ where: { id } })
if (sshLocalPort) { if (sshLocalPort) {
return Number(sshLocalPort) return Number(sshLocalPort)
} }
const data = await prisma.setting.findFirst();
const { minPort, maxPort } = data;
const ports = await prisma.destinationDocker.findMany({ where: { sshLocalPort: { not: null }, remoteIpAddress: { not: remoteIpAddress } } }) const ports = await prisma.destinationDocker.findMany({ where: { sshLocalPort: { not: null }, remoteIpAddress: { not: remoteIpAddress } } })
const alreadyConfigured = await prisma.destinationDocker.findFirst({ where: { remoteIpAddress, id: { not: id }, sshLocalPort: { not: null } } })
const alreadyConfigured = await prisma.destinationDocker.findFirst({
where: {
remoteIpAddress, id: { not: id }, sshLocalPort: { not: null }
}
})
if (alreadyConfigured?.sshLocalPort) { if (alreadyConfigured?.sshLocalPort) {
await prisma.destinationDocker.update({ where: { id }, data: { sshLocalPort: alreadyConfigured.sshLocalPort } }) await prisma.destinationDocker.update({ where: { id }, data: { sshLocalPort: alreadyConfigured.sshLocalPort } })
return Number(alreadyConfigured.sshLocalPort) return Number(alreadyConfigured.sshLocalPort)
} }
const availablePort = await getPort({ port: portNumbers(10000, 10100), exclude: ports.map(p => p.sshLocalPort) }) const range = generateRangeArray(minPort, maxPort)
await prisma.destinationDocker.update({ where: { id }, data: { sshLocalPort: Number(availablePort) } }) console.log({ ports })
return Number(availablePort) const availablePorts = range.filter(port => !ports.map(p => p.sshLocalPort).includes(port))
for (const port of availablePorts) {
const found = await isReachable(port, { host: 'localhost' })
if (!found) {
await prisma.destinationDocker.update({ where: { id }, data: { sshLocalPort: Number(port) } })
return Number(port)
}
}
return false
} }
export async function createRemoteEngineConfiguration(id: string) { export async function createRemoteEngineConfiguration(id: string) {
@@ -591,7 +689,7 @@ export async function createRemoteEngineConfiguration(id: string) {
config.append({ config.append({
Host: remoteIpAddress, Host: remoteIpAddress,
Hostname: 'localhost', Hostname: 'localhost',
Port: Number(localPort), Port: localPort.toString(),
User: remoteUser, User: remoteUser,
IdentityFile: sshKeyFile, IdentityFile: sshKeyFile,
StrictHostKeyChecking: 'no' StrictHostKeyChecking: 'no'
@@ -604,7 +702,7 @@ export async function createRemoteEngineConfiguration(id: string) {
} }
return await fs.writeFile(`${homedir}/.ssh/config`, sshConfig.stringify(config)) return await fs.writeFile(`${homedir}/.ssh/config`, sshConfig.stringify(config))
} }
export async function executeDockerCmd({ dockerId, command }: { dockerId: string, command: string }) { export async function executeDockerCmd({ debug, buildId, applicationId, dockerId, command }: { debug?: boolean, buildId?: string, applicationId?: string, dockerId: string, command: string }): Promise<any> {
let { remoteEngine, remoteIpAddress, engine } = await prisma.destinationDocker.findUnique({ where: { id: dockerId } }) let { remoteEngine, remoteIpAddress, engine } = await prisma.destinationDocker.findUnique({ where: { id: dockerId } })
if (remoteEngine) { if (remoteEngine) {
await createRemoteEngineConfiguration(dockerId) await createRemoteEngineConfiguration(dockerId)
@@ -617,6 +715,9 @@ export async function executeDockerCmd({ dockerId, command }: { dockerId: string
command = command.replace(/docker compose/gi, 'docker-compose') command = command.replace(/docker compose/gi, 'docker-compose')
} }
} }
if (command.startsWith(`docker build --progress plain`)) {
return await asyncExecShellStream({ debug, buildId, applicationId, command, engine });
}
return await asyncExecShell( return await asyncExecShell(
`DOCKER_BUILDKIT=1 DOCKER_HOST="${engine}" ${command}` `DOCKER_BUILDKIT=1 DOCKER_HOST="${engine}" ${command}`
); );
@@ -736,13 +837,18 @@ export async function listSettings(): Promise<any> {
} }
export function generatePassword(length = 24, symbols = false): string { export function generatePassword({ length = 24, symbols = false, isHex = false }: { length?: number, symbols?: boolean, isHex?: boolean } | null): string {
return generator.generate({ if (isHex) {
return crypto.randomBytes(length).toString("hex");
}
const password = generator.generate({
length, length,
numbers: true, numbers: true,
strict: true, strict: true,
symbols symbols
}); });
return password;
} }
export function generateDatabaseConfiguration(database: any, arch: string): export function generateDatabaseConfiguration(database: any, arch: string):
@@ -1208,7 +1314,7 @@ export async function checkExposedPort({ id, configuredPort, exposePort, dockerI
} }
} }
export async function getFreeExposedPort(id, exposePort, dockerId, remoteIpAddress) { export async function getFreeExposedPort(id, exposePort, dockerId, remoteIpAddress) {
const { default: getPort } = await import('get-port'); const { default: checkPort } = await import('is-port-reachable');
const applicationUsed = await ( const applicationUsed = await (
await prisma.application.findMany({ await prisma.application.findMany({
where: { exposePort: { not: null }, id: { not: id }, destinationDockerId: dockerId }, where: { exposePort: { not: null }, id: { not: id }, destinationDockerId: dockerId },
@@ -1222,22 +1328,23 @@ export async function getFreeExposedPort(id, exposePort, dockerId, remoteIpAddre
}) })
).map((a) => a.exposePort); ).map((a) => a.exposePort);
const usedPorts = [...applicationUsed, ...serviceUsed]; const usedPorts = [...applicationUsed, ...serviceUsed];
if (remoteIpAddress) { if (usedPorts.includes(exposePort)) {
const { default: checkPort } = await import('is-port-reachable');
const found = await checkPort(exposePort, { host: remoteIpAddress });
if (!found) {
return exposePort
}
return false return false
} }
return await getPort({ port: Number(exposePort), exclude: usedPorts }); const found = await checkPort(exposePort, { host: remoteIpAddress || 'localhost' });
if (!found) {
return exposePort
}
return false
} }
export function generateRangeArray(start, end) {
return Array.from({ length: (end - start) }, (v, k) => k + start);
}
export async function getFreePublicPort(id, dockerId) { export async function getFreePublicPort(id, dockerId) {
const { default: getPort, portNumbers } = await import('get-port'); const { default: isReachable } = await import('is-port-reachable');
const data = await prisma.setting.findFirst(); const data = await prisma.setting.findFirst();
const { minPort, maxPort } = data; const { minPort, maxPort } = data;
const dbUsed = await ( const dbUsed = await (
await prisma.database.findMany({ await prisma.database.findMany({
where: { publicPort: { not: null }, id: { not: id }, destinationDockerId: dockerId }, where: { publicPort: { not: null }, id: { not: id }, destinationDockerId: dockerId },
@@ -1263,7 +1370,15 @@ export async function getFreePublicPort(id, dockerId) {
}) })
).map((a) => a.publicPort); ).map((a) => a.publicPort);
const usedPorts = [...dbUsed, ...wpFtpUsed, ...wpUsed, ...minioUsed]; const usedPorts = [...dbUsed, ...wpFtpUsed, ...wpUsed, ...minioUsed];
return await getPort({ port: portNumbers(minPort, maxPort), exclude: usedPorts }); const range = generateRangeArray(minPort, maxPort)
const availablePorts = range.filter(port => !usedPorts.includes(port))
for (const port of availablePorts) {
const found = await isReachable(port, { host: 'localhost' })
if (!found) {
return port
}
}
return false
} }
export async function startTraefikTCPProxy( export async function startTraefikTCPProxy(
@@ -1392,11 +1507,11 @@ export async function configureServiceType({
type: string; type: string;
}): Promise<void> { }): Promise<void> {
if (type === 'plausibleanalytics') { if (type === 'plausibleanalytics') {
const password = encrypt(generatePassword()); const password = encrypt(generatePassword({}));
const postgresqlUser = cuid(); const postgresqlUser = cuid();
const postgresqlPassword = encrypt(generatePassword()); const postgresqlPassword = encrypt(generatePassword({}));
const postgresqlDatabase = 'plausibleanalytics'; const postgresqlDatabase = 'plausibleanalytics';
const secretKeyBase = encrypt(generatePassword(64)); const secretKeyBase = encrypt(generatePassword({ length: 64 }));
await prisma.service.update({ await prisma.service.update({
where: { id }, where: { id },
@@ -1420,22 +1535,22 @@ export async function configureServiceType({
}); });
} else if (type === 'minio') { } else if (type === 'minio') {
const rootUser = cuid(); const rootUser = cuid();
const rootUserPassword = encrypt(generatePassword()); const rootUserPassword = encrypt(generatePassword({}));
await prisma.service.update({ await prisma.service.update({
where: { id }, where: { id },
data: { type, minio: { create: { rootUser, rootUserPassword } } } data: { type, minio: { create: { rootUser, rootUserPassword } } }
}); });
} else if (type === 'vscodeserver') { } else if (type === 'vscodeserver') {
const password = encrypt(generatePassword()); const password = encrypt(generatePassword({}));
await prisma.service.update({ await prisma.service.update({
where: { id }, where: { id },
data: { type, vscodeserver: { create: { password } } } data: { type, vscodeserver: { create: { password } } }
}); });
} else if (type === 'wordpress') { } else if (type === 'wordpress') {
const mysqlUser = cuid(); const mysqlUser = cuid();
const mysqlPassword = encrypt(generatePassword()); const mysqlPassword = encrypt(generatePassword({}));
const mysqlRootUser = cuid(); const mysqlRootUser = cuid();
const mysqlRootUserPassword = encrypt(generatePassword()); const mysqlRootUserPassword = encrypt(generatePassword({}));
await prisma.service.update({ await prisma.service.update({
where: { id }, where: { id },
data: { data: {
@@ -1473,11 +1588,11 @@ export async function configureServiceType({
}); });
} else if (type === 'ghost') { } else if (type === 'ghost') {
const defaultEmail = `${cuid()}@example.com`; const defaultEmail = `${cuid()}@example.com`;
const defaultPassword = encrypt(generatePassword()); const defaultPassword = encrypt(generatePassword({}));
const mariadbUser = cuid(); const mariadbUser = cuid();
const mariadbPassword = encrypt(generatePassword()); const mariadbPassword = encrypt(generatePassword({}));
const mariadbRootUser = cuid(); const mariadbRootUser = cuid();
const mariadbRootUserPassword = encrypt(generatePassword()); const mariadbRootUserPassword = encrypt(generatePassword({}));
await prisma.service.update({ await prisma.service.update({
where: { id }, where: { id },
@@ -1496,7 +1611,7 @@ export async function configureServiceType({
} }
}); });
} else if (type === 'meilisearch') { } else if (type === 'meilisearch') {
const masterKey = encrypt(generatePassword(32)); const masterKey = encrypt(generatePassword({ length: 32 }));
await prisma.service.update({ await prisma.service.update({
where: { id }, where: { id },
data: { data: {
@@ -1505,11 +1620,11 @@ export async function configureServiceType({
} }
}); });
} else if (type === 'umami') { } else if (type === 'umami') {
const umamiAdminPassword = encrypt(generatePassword()); const umamiAdminPassword = encrypt(generatePassword({}));
const postgresqlUser = cuid(); const postgresqlUser = cuid();
const postgresqlPassword = encrypt(generatePassword()); const postgresqlPassword = encrypt(generatePassword({}));
const postgresqlDatabase = 'umami'; const postgresqlDatabase = 'umami';
const hashSalt = encrypt(generatePassword(64)); const hashSalt = encrypt(generatePassword({ length: 64 }));
await prisma.service.update({ await prisma.service.update({
where: { id }, where: { id },
data: { data: {
@@ -1527,9 +1642,9 @@ export async function configureServiceType({
}); });
} else if (type === 'hasura') { } else if (type === 'hasura') {
const postgresqlUser = cuid(); const postgresqlUser = cuid();
const postgresqlPassword = encrypt(generatePassword()); const postgresqlPassword = encrypt(generatePassword({}));
const postgresqlDatabase = 'hasura'; const postgresqlDatabase = 'hasura';
const graphQLAdminPassword = encrypt(generatePassword()); const graphQLAdminPassword = encrypt(generatePassword({}));
await prisma.service.update({ await prisma.service.update({
where: { id }, where: { id },
data: { data: {
@@ -1546,9 +1661,9 @@ export async function configureServiceType({
}); });
} else if (type === 'fider') { } else if (type === 'fider') {
const postgresqlUser = cuid(); const postgresqlUser = cuid();
const postgresqlPassword = encrypt(generatePassword()); const postgresqlPassword = encrypt(generatePassword({}));
const postgresqlDatabase = 'fider'; const postgresqlDatabase = 'fider';
const jwtSecret = encrypt(generatePassword(64, true)); const jwtSecret = encrypt(generatePassword({ length: 64, symbols: true }));
await prisma.service.update({ await prisma.service.update({
where: { id }, where: { id },
data: { data: {
@@ -1565,13 +1680,13 @@ export async function configureServiceType({
}); });
} else if (type === 'moodle') { } else if (type === 'moodle') {
const defaultUsername = cuid(); const defaultUsername = cuid();
const defaultPassword = encrypt(generatePassword()); const defaultPassword = encrypt(generatePassword({}));
const defaultEmail = `${cuid()} @example.com`; const defaultEmail = `${cuid()} @example.com`;
const mariadbUser = cuid(); const mariadbUser = cuid();
const mariadbPassword = encrypt(generatePassword()); const mariadbPassword = encrypt(generatePassword({}));
const mariadbDatabase = 'moodle_db'; const mariadbDatabase = 'moodle_db';
const mariadbRootUser = cuid(); const mariadbRootUser = cuid();
const mariadbRootUserPassword = encrypt(generatePassword()); const mariadbRootUserPassword = encrypt(generatePassword({}));
await prisma.service.update({ await prisma.service.update({
where: { id }, where: { id },
data: { data: {
@@ -1591,15 +1706,15 @@ export async function configureServiceType({
} }
}); });
} else if (type === 'appwrite') { } else if (type === 'appwrite') {
const opensslKeyV1 = encrypt(generatePassword()); const opensslKeyV1 = encrypt(generatePassword({}));
const executorSecret = encrypt(generatePassword()); const executorSecret = encrypt(generatePassword({}));
const redisPassword = encrypt(generatePassword()); const redisPassword = encrypt(generatePassword({}));
const mariadbHost = `${id}-mariadb` const mariadbHost = `${id}-mariadb`
const mariadbUser = cuid(); const mariadbUser = cuid();
const mariadbPassword = encrypt(generatePassword()); const mariadbPassword = encrypt(generatePassword({}));
const mariadbDatabase = 'appwrite'; const mariadbDatabase = 'appwrite';
const mariadbRootUser = cuid(); const mariadbRootUser = cuid();
const mariadbRootUserPassword = encrypt(generatePassword()); const mariadbRootUserPassword = encrypt(generatePassword({}));
await prisma.service.update({ await prisma.service.update({
where: { id }, where: { id },
data: { data: {
@@ -1622,11 +1737,11 @@ export async function configureServiceType({
} else if (type === 'glitchTip') { } else if (type === 'glitchTip') {
const defaultUsername = cuid(); const defaultUsername = cuid();
const defaultEmail = `${defaultUsername}@example.com`; const defaultEmail = `${defaultUsername}@example.com`;
const defaultPassword = encrypt(generatePassword()); const defaultPassword = encrypt(generatePassword({}));
const postgresqlUser = cuid(); const postgresqlUser = cuid();
const postgresqlPassword = encrypt(generatePassword()); const postgresqlPassword = encrypt(generatePassword({}));
const postgresqlDatabase = 'glitchTip'; const postgresqlDatabase = 'glitchTip';
const secretKeyBase = encrypt(generatePassword(64)); const secretKeyBase = encrypt(generatePassword({ length: 64 }));
await prisma.service.update({ await prisma.service.update({
where: { id }, where: { id },
@@ -1645,7 +1760,22 @@ export async function configureServiceType({
} }
} }
}); });
} else { } else if (type === 'searxng') {
const secretKey = encrypt(generatePassword({ length: 32, isHex: true }))
const redisPassword = encrypt(generatePassword({}));
await prisma.service.update({
where: { id },
data: {
type,
searxng: {
create: {
secretKey,
redisPassword,
}
}
}
});
} else {
await prisma.service.update({ await prisma.service.update({
where: { id }, where: { id },
data: { data: {
@@ -1670,6 +1800,7 @@ export async function removeService({ id }: { id: string }): Promise<void> {
await prisma.glitchTip.deleteMany({ where: { serviceId: id } }); await prisma.glitchTip.deleteMany({ where: { serviceId: id } });
await prisma.moodle.deleteMany({ where: { serviceId: id } }); await prisma.moodle.deleteMany({ where: { serviceId: id } });
await prisma.appwrite.deleteMany({ where: { serviceId: id } }); await prisma.appwrite.deleteMany({ where: { serviceId: id } });
await prisma.searxng.deleteMany({ where: { serviceId: id } });
await prisma.service.delete({ where: { id } }); await prisma.service.delete({ where: { id } });
} }
@@ -1762,18 +1893,22 @@ export async function stopBuild(buildId, applicationId) {
let count = 0; let count = 0;
await new Promise<void>(async (resolve, reject) => { await new Promise<void>(async (resolve, reject) => {
const { destinationDockerId, status } = await prisma.build.findFirst({ where: { id: buildId } }); const { destinationDockerId, status } = await prisma.build.findFirst({ where: { id: buildId } });
const { engine, id: dockerId } = await prisma.destinationDocker.findFirst({ where: { id: destinationDockerId } }); const { id: dockerId } = await prisma.destinationDocker.findFirst({ where: { id: destinationDockerId } });
const interval = setInterval(async () => { const interval = setInterval(async () => {
try { try {
if (status === 'failed') { if (status === 'failed' || status === 'canceled') {
clearInterval(interval); clearInterval(interval);
return resolve(); return resolve();
} }
if (count > 100) { if (count > 15) {
clearInterval(interval); clearInterval(interval);
return reject(new Error('Build canceled')); if (scheduler.workers.has('deployApplication')) {
scheduler.workers.get('deployApplication').postMessage('cancel')
}
await cleanupDB(buildId, applicationId);
return reject(new Error('Deployment canceled.'));
} }
const { stdout: buildContainers } = await executeDockerCmd({ dockerId, command: `docker container ls--filter "label=coolify.buildId=${buildId}" --format '{{json .}}'` }) const { stdout: buildContainers } = await executeDockerCmd({ dockerId, command: `docker container ls --filter "label=coolify.buildId=${buildId}" --format '{{json .}}'` })
if (buildContainers) { if (buildContainers) {
const containersArray = buildContainers.trim().split('\n'); const containersArray = buildContainers.trim().split('\n');
for (const container of containersArray) { for (const container of containersArray) {
@@ -1781,8 +1916,11 @@ export async function stopBuild(buildId, applicationId) {
const id = containerObj.ID; const id = containerObj.ID;
if (!containerObj.Names.startsWith(`${applicationId} `)) { if (!containerObj.Names.startsWith(`${applicationId} `)) {
await removeContainer({ id, dockerId }); await removeContainer({ id, dockerId });
await cleanupDB(buildId);
clearInterval(interval); clearInterval(interval);
if (scheduler.workers.has('deployApplication')) {
scheduler.workers.get('deployApplication').postMessage('cancel')
}
await cleanupDB(buildId, applicationId);
return resolve(); return resolve();
} }
} }
@@ -1793,11 +1931,12 @@ export async function stopBuild(buildId, applicationId) {
}); });
} }
async function cleanupDB(buildId: string) { async function cleanupDB(buildId: string, applicationId: string) {
const data = await prisma.build.findUnique({ where: { id: buildId } }); const data = await prisma.build.findUnique({ where: { id: buildId } });
if (data?.status === 'queued' || data?.status === 'running') { if (data?.status === 'queued' || data?.status === 'running') {
await prisma.build.update({ where: { id: buildId }, data: { status: 'failed' } }); await prisma.build.update({ where: { id: buildId }, data: { status: 'canceled' } });
} }
await saveBuildLog({ line: 'Deployment canceled.', buildId, applicationId });
} }
export function convertTolOldVolumeNames(type) { export function convertTolOldVolumeNames(type) {
@@ -1805,10 +1944,7 @@ export function convertTolOldVolumeNames(type) {
return 'nc' return 'nc'
} }
} }
// export async function getAvailableServices(): Promise<any> {
// const { data } = await axios.get(`https://gist.githubusercontent.com/andrasbacsai/4aac36d8d6214dbfc34fa78110554a50/raw/5b27e6c37d78aaeedc1148d797112c827a2f43cf/availableServices.json`)
// return data
//
export async function cleanupDockerStorage(dockerId, lowDiskSpace, force) { export async function cleanupDockerStorage(dockerId, lowDiskSpace, force) {
// Cleanup old coolify images // Cleanup old coolify images
try { try {

View File

@@ -2,54 +2,29 @@ import Bree from 'bree';
import path from 'path'; import path from 'path';
import Cabin from 'cabin'; import Cabin from 'cabin';
import TSBree from '@breejs/ts-worker'; import TSBree from '@breejs/ts-worker';
import { isDev } from './common';
export const isDev = process.env.NODE_ENV === 'development';
Bree.extend(TSBree); Bree.extend(TSBree);
const options: any = { const options: any = {
defaultExtension: 'js', defaultExtension: 'js',
// logger: new Cabin(),
logger: false, logger: false,
workerMessageHandler: async ({ name, message }) => { workerMessageHandler: async ({ name, message }) => {
if (name === 'deployApplication') { if (name === 'deployApplication' && message?.deploying) {
if (message.pending === 0 && message.size === 0) { if (scheduler.workers.has('autoUpdater') || scheduler.workers.has('cleanupStorage')) {
if (message.caller === 'autoUpdater') { scheduler.workers.get('deployApplication').postMessage('cancel')
if (!scheduler.workers.has('autoUpdater')) {
await scheduler.stop('deployApplication');
await scheduler.run('autoUpdater')
}
}
if (message.caller === 'cleanupStorage') {
if (!scheduler.workers.has('cleanupStorage')) {
await scheduler.run('cleanupStorage')
}
}
} }
} }
}, },
jobs: [ jobs: [
{ { name: 'infrastructure' },
name: 'deployApplication' { name: 'deployApplication' },
},
{
name: 'cleanupStorage',
},
{
name: 'cleanupPrismaEngines',
interval: '1m'
},
{
name: 'checkProxies',
interval: '10s'
},
{
name: 'autoUpdater',
}
], ],
}; };
if (isDev) options.root = path.join(__dirname, '../jobs'); if (isDev) options.root = path.join(__dirname, '../jobs');
export const scheduler = new Bree(options); export const scheduler = new Bree(options);

View File

@@ -671,3 +671,20 @@ export const glitchTip = [{
isBoolean: true, isBoolean: true,
isEncrypted: false isEncrypted: false
}] }]
export const searxng = [{
name: 'secretKey',
isEditable: false,
isLowerCase: false,
isNumber: false,
isBoolean: false,
isEncrypted: true
},
{
name: 'redisPassword',
isEditable: false,
isLowerCase: false,
isNumber: false,
isBoolean: false,
isEncrypted: true
}]

View File

@@ -75,7 +75,6 @@ export async function getApplicationStatus(request: FastifyRequest<OnlyId>) {
isExited = await isContainerExited(application.destinationDocker.id, id); isExited = await isContainerExited(application.destinationDocker.id, id);
} }
return { return {
isQueueActive: scheduler.workers.has('deployApplication'),
isRunning, isRunning,
isExited, isExited,
}; };
@@ -239,8 +238,8 @@ export async function saveApplication(request: FastifyRequest<SaveApplication>,
exposePort = Number(exposePort); exposePort = Number(exposePort);
} }
const { destinationDockerId } = await prisma.application.findUnique({ where: { id } }) const { destinationDocker: { id: dockerId, remoteIpAddress } } = await prisma.application.findUnique({ where: { id }, include: { destinationDocker: true } })
if (exposePort) await checkExposedPort({ id, exposePort, dockerId: destinationDockerId }) if (exposePort) await checkExposedPort({ id, exposePort, dockerId, remoteIpAddress })
if (denoOptions) denoOptions = denoOptions.trim(); if (denoOptions) denoOptions = denoOptions.trim();
const defaultConfiguration = await setDefaultConfiguration({ const defaultConfiguration = await setDefaultConfiguration({
buildPack, buildPack,
@@ -453,6 +452,8 @@ export async function deployApplication(request: FastifyRequest<DeployApplicatio
id: buildId, id: buildId,
applicationId: id, applicationId: id,
branch: application.branch, branch: application.branch,
pullmergeRequestId,
forceRebuild,
destinationDockerId: application.destinationDocker?.id, destinationDockerId: application.destinationDocker?.id,
gitSourceId: application.gitSource?.id, gitSourceId: application.gitSource?.id,
githubAppId: application.gitSource?.githubApp?.id, githubAppId: application.gitSource?.githubApp?.id,
@@ -461,24 +462,6 @@ export async function deployApplication(request: FastifyRequest<DeployApplicatio
type: 'manual' type: 'manual'
} }
}); });
if (pullmergeRequestId) {
scheduler.workers.get('deployApplication').postMessage({
build_id: buildId,
type: 'manual',
...application,
sourceBranch: branch,
pullmergeRequestId,
forceRebuild
});
} else {
scheduler.workers.get('deployApplication').postMessage({
build_id: buildId,
type: 'manual',
...application,
forceRebuild
});
}
return { return {
buildId buildId
}; };

View File

@@ -29,9 +29,9 @@ export async function newDatabase(request: FastifyRequest, reply: FastifyReply)
const name = uniqueName(); const name = uniqueName();
const dbUser = cuid(); const dbUser = cuid();
const dbUserPassword = encrypt(generatePassword()); const dbUserPassword = encrypt(generatePassword({}));
const rootUser = cuid(); const rootUser = cuid();
const rootUserPassword = encrypt(generatePassword()); const rootUserPassword = encrypt(generatePassword({}));
const defaultDatabase = cuid(); const defaultDatabase = cuid();
const { id } = await prisma.database.create({ const { id } = await prisma.database.create({
@@ -433,9 +433,13 @@ export async function saveDatabaseSettings(request: FastifyRequest<SaveDatabaseS
const { id } = request.params; const { id } = request.params;
const { isPublic, appendOnly = true } = request.body; const { isPublic, appendOnly = true } = request.body;
const { destinationDocker: { id: dockerId } } = await prisma.database.findUnique({ where: { id }, include: { destinationDocker: true } }) let publicPort = null
const publicPort = await getFreePublicPort(id, dockerId);
const { destinationDocker: { id: dockerId } } = await prisma.database.findUnique({ where: { id }, include: { destinationDocker: true } })
if (isPublic) {
publicPort = await getFreePublicPort(id, dockerId);
}
await prisma.database.update({ await prisma.database.update({
where: { id }, where: { id },
data: { data: {

View File

@@ -73,6 +73,23 @@ export async function update(request: FastifyRequest<Update>) {
return errorHandler({ status, message }) return errorHandler({ status, message })
} }
} }
export async function restartCoolify(request: FastifyRequest<any>) {
try {
const teamId = request.user.teamId;
if (teamId === '0') {
if (!isDev) {
await asyncExecShell(`docker restart coolify`);
return {};
} else {
console.log('Restarting Coolify')
return {};
}
}
throw { status: 500, message: 'You are not authorized to restart Coolify.' };
} catch ({ status, message }) {
return errorHandler({ status, message })
}
}
export async function showUsage() { export async function showUsage() {
try { try {
return { return {
@@ -101,7 +118,8 @@ export async function showDashboard(request: FastifyRequest) {
include: { settings: true } include: { settings: true }
}); });
const databases = await prisma.database.findMany({ const databases = await prisma.database.findMany({
where: { teams: { some: { id: teamId === '0' ? undefined : teamId } } } where: { teams: { some: { id: teamId === '0' ? undefined : teamId } } },
include: { settings: true }
}); });
const services = await prisma.service.findMany({ const services = await prisma.service.findMany({
where: { teams: { some: { id: teamId === '0' ? undefined : teamId } } } where: { teams: { some: { id: teamId === '0' ? undefined : teamId } } }

View File

@@ -1,5 +1,5 @@
import { FastifyPluginAsync } from 'fastify'; import { FastifyPluginAsync } from 'fastify';
import { checkUpdate, login, showDashboard, update, showUsage, getCurrentUser, cleanupManually } from './handlers'; import { checkUpdate, login, showDashboard, update, showUsage, getCurrentUser, cleanupManually, restartCoolify } from './handlers';
import { GetCurrentUser } from './types'; import { GetCurrentUser } from './types';
export interface Update { export interface Update {
@@ -47,6 +47,10 @@ const root: FastifyPluginAsync = async (fastify): Promise<void> => {
onRequest: [fastify.authenticate] onRequest: [fastify.authenticate]
}, async () => await showUsage()); }, async () => await showUsage());
fastify.post('/internal/restart', {
onRequest: [fastify.authenticate]
}, async (request) => await restartCoolify(request));
fastify.post('/internal/cleanup', { fastify.post('/internal/cleanup', {
onRequest: [fastify.authenticate] onRequest: [fastify.authenticate]
}, async () => await cleanupManually()); }, async () => await cleanupManually());

View File

@@ -583,6 +583,9 @@ export async function startService(request: FastifyRequest<ServiceStartStop>) {
if (type === 'glitchTip') { if (type === 'glitchTip') {
return await startGlitchTipService(request) return await startGlitchTipService(request)
} }
if (type === 'searxng') {
return await startSearXNGService(request)
}
throw `Service type ${type} not supported.` throw `Service type ${type} not supported.`
} catch (error) { } catch (error) {
throw { status: 500, message: error?.message || error } throw { status: 500, message: error?.message || error }
@@ -591,56 +594,6 @@ export async function startService(request: FastifyRequest<ServiceStartStop>) {
export async function stopService(request: FastifyRequest<ServiceStartStop>) { export async function stopService(request: FastifyRequest<ServiceStartStop>) {
try { try {
return await stopServiceContainers(request) return await stopServiceContainers(request)
// const { type } = request.params
// if (type === 'plausibleanalytics') {
// return await stopPlausibleAnalyticsService(request)
// }
// if (type === 'nocodb') {
// return await stopNocodbService(request)
// }
// if (type === 'minio') {
// return await stopMinioService(request)
// }
// if (type === 'vscodeserver') {
// return await stopVscodeService(request)
// }
// if (type === 'wordpress') {
// return await stopWordpressService(request)
// }
// if (type === 'vaultwarden') {
// return await stopVaultwardenService(request)
// }
// if (type === 'languagetool') {
// return await stopLanguageToolService(request)
// }
// if (type === 'n8n') {
// return await stopN8nService(request)
// }
// if (type === 'uptimekuma') {
// return await stopUptimekumaService(request)
// }
// if (type === 'ghost') {
// return await stopGhostService(request)
// }
// if (type === 'meilisearch') {
// return await stopMeilisearchService(request)
// }
// if (type === 'umami') {
// return await stopUmamiService(request)
// }
// if (type === 'hasura') {
// return await stopHasuraService(request)
// }
// if (type === 'fider') {
// return await stopFiderService(request)
// }
// if (type === 'moodle') {
// return await stopMoodleService(request)
// }
// if (type === 'glitchTip') {
// return await stopGlitchTipService(request)
// }
// throw `Service type ${type} not supported.`
} catch (error) { } catch (error) {
throw { status: 500, message: error?.message || error } throw { status: 500, message: error?.message || error }
} }
@@ -2415,6 +2368,7 @@ async function startAppWriteService(request: FastifyRequest<ServiceStartStop>) {
} }
async function startServiceContainers(dockerId, composeFileDestination) { async function startServiceContainers(dockerId, composeFileDestination) {
await executeDockerCmd({ dockerId, command: `docker compose -f ${composeFileDestination} pull` }) await executeDockerCmd({ dockerId, command: `docker compose -f ${composeFileDestination} pull` })
await executeDockerCmd({ dockerId, command: `docker compose -f ${composeFileDestination} build --no-cache` })
await executeDockerCmd({ dockerId, command: `docker compose -f ${composeFileDestination} create` }) await executeDockerCmd({ dockerId, command: `docker compose -f ${composeFileDestination} create` })
await executeDockerCmd({ dockerId, command: `docker compose -f ${composeFileDestination} start` }) await executeDockerCmd({ dockerId, command: `docker compose -f ${composeFileDestination} start` })
await asyncSleep(1000); await asyncSleep(1000);
@@ -2662,37 +2616,19 @@ async function startGlitchTipService(request: FastifyRequest<ServiceStartStop>)
container_name: id, container_name: id,
image: config.glitchTip.image, image: config.glitchTip.image,
environment: config.glitchTip.environmentVariables, environment: config.glitchTip.environmentVariables,
networks: [network],
volumes, volumes,
restart: 'always',
labels: makeLabelForServices('glitchTip'), labels: makeLabelForServices('glitchTip'),
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}), ...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
deploy: { depends_on: [`${id}-postgresql`, `${id}-redis`],
restart_policy: { ...defaultComposeConfiguration(network),
condition: 'on-failure',
delay: '5s',
max_attempts: 3,
window: '120s'
}
},
depends_on: [`${id}-postgresql`, `${id}-redis`]
}, },
[`${id}-worker`]: { [`${id}-worker`]: {
container_name: `${id}-worker`, container_name: `${id}-worker`,
image: config.glitchTip.image, image: config.glitchTip.image,
command: './bin/run-celery-with-beat.sh', command: './bin/run-celery-with-beat.sh',
environment: config.glitchTip.environmentVariables, environment: config.glitchTip.environmentVariables,
networks: [network], depends_on: [`${id}-postgresql`, `${id}-redis`],
restart: 'always', ...defaultComposeConfiguration(network),
deploy: {
restart_policy: {
condition: 'on-failure',
delay: '5s',
max_attempts: 3,
window: '120s'
}
},
depends_on: [`${id}-postgresql`, `${id}-redis`]
}, },
[`${id}-setup`]: { [`${id}-setup`]: {
container_name: `${id}-setup`, container_name: `${id}-setup`,
@@ -2707,32 +2643,14 @@ async function startGlitchTipService(request: FastifyRequest<ServiceStartStop>)
image: config.postgresql.image, image: config.postgresql.image,
container_name: `${id}-postgresql`, container_name: `${id}-postgresql`,
environment: config.postgresql.environmentVariables, environment: config.postgresql.environmentVariables,
networks: [network],
volumes: [config.postgresql.volume], volumes: [config.postgresql.volume],
restart: 'always', ...defaultComposeConfiguration(network),
deploy: {
restart_policy: {
condition: 'on-failure',
delay: '5s',
max_attempts: 3,
window: '120s'
}
}
}, },
[`${id}-redis`]: { [`${id}-redis`]: {
image: config.redis.image, image: config.redis.image,
container_name: `${id}-redis`, container_name: `${id}-redis`,
networks: [network],
volumes: [config.redis.volume], volumes: [config.redis.volume],
restart: 'always', ...defaultComposeConfiguration(network),
deploy: {
restart_policy: {
condition: 'on-failure',
delay: '5s',
max_attempts: 3,
window: '120s'
}
}
} }
}, },
networks: { networks: {
@@ -2761,54 +2679,93 @@ async function startGlitchTipService(request: FastifyRequest<ServiceStartStop>)
return errorHandler({ status, message }) return errorHandler({ status, message })
} }
} }
async function stopGlitchTipService(request: FastifyRequest<ServiceStartStop>) {
async function startSearXNGService(request: FastifyRequest<ServiceStartStop>) {
try { try {
const { id } = request.params; const { id } = request.params;
const teamId = request.user.teamId; const teamId = request.user.teamId;
const service = await getServiceFromDB({ id, teamId }); const service = await getServiceFromDB({ id, teamId });
const { destinationDockerId, destinationDocker } = service; const { type, version, destinationDockerId, destinationDocker, serviceSecret, exposePort, persistentStorage, fqdn, searxng: { secretKey, redisPassword } } =
if (destinationDockerId) { service;
try { const network = destinationDockerId && destinationDocker.network;
const found = await checkContainer({ dockerId: destinationDocker.id, container: id }); const port = getServiceMainPort('searxng');
if (found) {
await removeContainer({ id, dockerId: destinationDocker.id }); const { workdir } = await createDirectories({ repository: type, buildId: id });
} const image = getServiceImage(type);
} catch (error) {
console.error(error); const config = {
} searxng: {
try { image: `${image}:${version}`,
const found = await checkContainer({ dockerId: destinationDocker.id, container: `${id}-worker` }); volume: `${id}-searxng:/etc/searxng`,
if (found) { environmentVariables: {
await removeContainer({ id: `${id}-worker`, dockerId: destinationDocker.id }); SEARXNG_BASE_URL: `${fqdn}`
} },
} catch (error) { },
console.error(error); redis: {
} image: 'redis:7-alpine',
try {
const found = await checkContainer({ dockerId: destinationDocker.id, container: `${id}-setup` });
if (found) {
await removeContainer({ id: `${id}-setup`, dockerId: destinationDocker.id });
}
} catch (error) {
console.error(error);
}
try {
const found = await checkContainer({ dockerId: destinationDocker.id, container: `${id}-postgresql` });
if (found) {
await removeContainer({ id: `${id}-postgresql`, dockerId: destinationDocker.id });
}
} catch (error) {
console.error(error);
}
try {
const found = await checkContainer({ dockerId: destinationDocker.id, container: `${id}-redis` });
if (found) {
await removeContainer({ id: `${id}-redis`, dockerId: destinationDocker.id });
}
} catch (error) {
console.error(error);
} }
};
const settingsYml = `
# see https://docs.searxng.org/admin/engines/settings.html#use-default-settings
use_default_settings: true
server:
secret_key: ${secretKey}
limiter: true
image_proxy: true
ui:
static_use_hash: true
redis:
url: redis://:${redisPassword}@${id}-redis:6379/0`
const Dockerfile = `
FROM ${config.searxng.image}
COPY ./settings.yml /etc/searxng/settings.yml`;
if (serviceSecret.length > 0) {
serviceSecret.forEach((secret) => {
config.searxng.environmentVariables[secret.name] = secret.value;
});
} }
const { volumes, volumeMounts } = persistentVolumes(id, persistentStorage, config)
const composeFile: ComposeFile = {
version: '3.8',
services: {
[id]: {
build: workdir,
container_name: id,
volumes,
environment: config.searxng.environmentVariables,
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
labels: makeLabelForServices('searxng'),
cap_drop: ['ALL'],
cap_add: ['CHOWN', 'SETGID', 'SETUID', 'DAC_OVERRIDE'],
depends_on: [`${id}-redis`],
...defaultComposeConfiguration(network),
},
[`${id}-redis`]: {
container_name: `${id}-redis`,
image: config.redis.image,
command: `redis-server --requirepass ${redisPassword} --save "" --appendonly "no"`,
labels: makeLabelForServices('searxng'),
cap_drop: ['ALL'],
cap_add: ['SETGID', 'SETUID', 'DAC_OVERRIDE'],
...defaultComposeConfiguration(network),
},
},
networks: {
[network]: {
external: true
}
},
volumes: volumeMounts
};
const composeFileDestination = `${workdir}/docker-compose.yaml`;
await fs.writeFile(composeFileDestination, yaml.dump(composeFile));
await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile);
await fs.writeFile(`${workdir}/settings.yml`, settingsYml);
await startServiceContainers(destinationDocker.id, composeFileDestination)
return {} return {}
} catch ({ status, message }) { } catch ({ status, message }) {
return errorHandler({ status, message }) return errorHandler({ status, message })
@@ -2865,7 +2822,7 @@ export async function activateWordpressFtp(request: FastifyRequest<ActivateWordp
const publicPort = await getFreePublicPort(id, dockerId); const publicPort = await getFreePublicPort(id, dockerId);
let ftpUser = cuid(); let ftpUser = cuid();
let ftpPassword = generatePassword(); let ftpPassword = generatePassword({});
const hostkeyDir = isDev ? '/tmp/hostkeys' : '/app/ssl/hostkeys'; const hostkeyDir = isDev ? '/tmp/hostkeys' : '/app/ssl/hostkeys';
try { try {

View File

@@ -142,12 +142,6 @@ export async function gitHubEvents(request: FastifyRequest<GitHubEvents>): Promi
type: 'webhook_commit' type: 'webhook_commit'
} }
}); });
scheduler.workers.get('deployApplication').postMessage({
build_id: buildId,
type: 'webhook_commit',
...applicationFound
});
return { return {
message: 'Queued. Thank you!' message: 'Queued. Thank you!'
}; };
@@ -183,6 +177,8 @@ export async function gitHubEvents(request: FastifyRequest<GitHubEvents>): Promi
await prisma.build.create({ await prisma.build.create({
data: { data: {
id: buildId, id: buildId,
pullmergeRequestId,
sourceBranch,
applicationId: applicationFound.id, applicationId: applicationFound.id,
destinationDockerId: applicationFound.destinationDocker.id, destinationDockerId: applicationFound.destinationDocker.id,
gitSourceId: applicationFound.gitSource.id, gitSourceId: applicationFound.gitSource.id,
@@ -192,14 +188,7 @@ export async function gitHubEvents(request: FastifyRequest<GitHubEvents>): Promi
type: 'webhook_pr' type: 'webhook_pr'
} }
}); });
scheduler.workers.get('deployApplication').postMessage({
build_id: buildId,
type: 'webhook_pr',
...applicationFound,
sourceBranch,
pullmergeRequestId
});
return { return {
message: 'Queued. Thank you!' message: 'Queued. Thank you!'
}; };

View File

@@ -89,12 +89,6 @@ export async function gitLabEvents(request: FastifyRequest<GitLabEvents>) {
} }
}); });
scheduler.workers.get('deployApplication').postMessage({
build_id: buildId,
type: 'webhook_commit',
...applicationFound
});
return { return {
message: 'Queued. Thank you!' message: 'Queued. Thank you!'
}; };
@@ -141,6 +135,8 @@ export async function gitLabEvents(request: FastifyRequest<GitLabEvents>) {
await prisma.build.create({ await prisma.build.create({
data: { data: {
id: buildId, id: buildId,
pullmergeRequestId,
sourceBranch,
applicationId: applicationFound.id, applicationId: applicationFound.id,
destinationDockerId: applicationFound.destinationDocker.id, destinationDockerId: applicationFound.destinationDocker.id,
gitSourceId: applicationFound.gitSource.id, gitSourceId: applicationFound.gitSource.id,
@@ -150,14 +146,6 @@ export async function gitLabEvents(request: FastifyRequest<GitLabEvents>) {
type: 'webhook_mr' type: 'webhook_mr'
} }
}); });
scheduler.workers.get('deployApplication').postMessage({
build_id: buildId,
type: 'webhook_mr',
...applicationFound,
sourceBranch,
pullmergeRequestId
});
return { return {
message: 'Queued. Thank you!' message: 'Queued. Thank you!'
}; };

View File

@@ -14,20 +14,20 @@
"format": "prettier --write --plugin-search-dir=. ." "format": "prettier --write --plugin-search-dir=. ."
}, },
"devDependencies": { "devDependencies": {
"@playwright/test": "1.24.2", "@playwright/test": "1.25.1",
"@sveltejs/kit": "1.0.0-next.405", "@sveltejs/kit": "1.0.0-next.405",
"@types/js-cookie": "3.0.2", "@types/js-cookie": "3.0.2",
"@typescript-eslint/eslint-plugin": "5.33.0", "@typescript-eslint/eslint-plugin": "5.35.1",
"@typescript-eslint/parser": "5.33.0", "@typescript-eslint/parser": "5.35.1",
"autoprefixer": "10.4.8", "autoprefixer": "10.4.8",
"eslint": "8.21.0", "eslint": "8.22.0",
"eslint-config-prettier": "8.5.0", "eslint-config-prettier": "8.5.0",
"eslint-plugin-svelte3": "4.0.0", "eslint-plugin-svelte3": "4.0.0",
"postcss": "8.4.16", "postcss": "8.4.16",
"prettier": "2.7.1", "prettier": "2.7.1",
"prettier-plugin-svelte": "2.7.0", "prettier-plugin-svelte": "2.7.0",
"svelte": "3.49.0", "svelte": "3.49.0",
"svelte-check": "2.8.0", "svelte-check": "2.8.1",
"svelte-preprocess": "4.10.7", "svelte-preprocess": "4.10.7",
"tailwindcss": "3.1.8", "tailwindcss": "3.1.8",
"tailwindcss-scrollbar": "0.1.0", "tailwindcss-scrollbar": "0.1.0",
@@ -38,8 +38,9 @@
"type": "module", "type": "module",
"dependencies": { "dependencies": {
"@sveltejs/adapter-static": "1.0.0-next.39", "@sveltejs/adapter-static": "1.0.0-next.39",
"@tailwindcss/typography": "^0.5.4",
"cuid": "2.1.8", "cuid": "2.1.8",
"daisyui": "2.22.0", "daisyui": "2.24.0",
"js-cookie": "3.0.1", "js-cookie": "3.0.1",
"p-limit": "4.0.0", "p-limit": "4.0.0",
"svelte-select": "4.4.7", "svelte-select": "4.4.7",

View File

@@ -181,6 +181,17 @@ export const supportedServiceTypesAndVersions = [
main: 8000 main: 8000
} }
}, },
{
name: 'searxng',
fancyName: 'SearXNG',
baseImage: 'searxng/searxng',
images: ['redis:6.2-alpine'],
versions: ['latest'],
recommendedVersion: 'latest',
ports: {
main: 8080
}
},
]; ];
export const asyncSleep = (delay: number) => export const asyncSleep = (delay: number) =>

View File

@@ -20,11 +20,12 @@
let usageInterval: any; let usageInterval: any;
let loading = { let loading = {
usage: false, usage: false,
cleanup: false cleanup: false,
restart: false
}; };
import { appSession } from '$lib/store'; import { addToast, appSession } from '$lib/store';
import { onDestroy, onMount } from 'svelte'; import { onDestroy, onMount } from 'svelte';
import { get } from '$lib/api'; import { get, post } from '$lib/api';
import { errorNotification } from '$lib/common'; import { errorNotification } from '$lib/common';
async function getStatus() { async function getStatus() {
if (loading.usage) return; if (loading.usage) return;
@@ -33,6 +34,25 @@
usage = data.usage; usage = data.usage;
loading.usage = false; loading.usage = false;
} }
async function restartCoolify() {
const sure = confirm(
'Are you sure you would like to restart Coolify? Currently running deployments will be stopped and restarted.'
);
if (sure) {
loading.restart = true;
try {
await post(`/internal/restart`, {});
addToast({
type: 'success',
message: 'Coolify restarted successfully. It will take a moment.'
});
} catch (error) {
return errorNotification(error);
} finally {
loading.restart = false;
}
}
}
onDestroy(() => { onDestroy(() => {
clearInterval(usageInterval); clearInterval(usageInterval);
}); });
@@ -48,65 +68,106 @@
return errorNotification(error); return errorNotification(error);
} }
}); });
async function manuallyCleanupStorage() {
try {
loading.cleanup = true;
await post('/internal/cleanup', {});
return addToast({
message: 'Cleanup done.',
type: 'success'
});
} catch (error) {
return errorNotification(error);
} finally {
loading.cleanup = false;
}
}
</script> </script>
<div class="pb-4"> <div class="w-full">
<div class="title">Hardware Details</div> <div class="flex items-center">
<div class="text-center p-8 "> <h1 class="title text-4xl">Hardware Details</h1>
<div> <div class="flex space-x-4">
<div class="stat w-64"> {#if $appSession.teamId === '0'}
<div class="stat-title">Total Memory</div> <button on:click={manuallyCleanupStorage} class:loading={loading.cleanup} class="btn btn-sm"
<div class="stat-value"> >Cleanup Storage</button
>
<button
on:click={restartCoolify}
class:loading={loading.restart}
class="btn btn-sm bg-red-600 hover:bg-red-500">Restart Coolify</button
>
{/if}
</div>
</div>
<div class="divider" />
<div class="grid grid-flow-col gap-4 grid-rows-3 lg:grid-rows-1">
<div class="stats stats-vertical lg:stats-horizontal w-full mb-5 bg-transparent rounded">
<div class="font-bold flex lg:justify-center">Memory</div>
<div class="stat">
<div class="stat-title">Total</div>
<div class="stat-value text-2xl">
{(usage?.memory.totalMemMb).toFixed(0)}<span class="text-sm">MB</span> {(usage?.memory.totalMemMb).toFixed(0)}<span class="text-sm">MB</span>
</div> </div>
</div> </div>
<div class="stat w-64">
<div class="stat-title">Used Memory</div> <div class="stat">
<div class="stat-value"> <div class="stat-title">Used</div>
<div class="stat-value text-2xl">
{(usage?.memory.usedMemMb).toFixed(0)}<span class="text-sm">MB</span> {(usage?.memory.usedMemMb).toFixed(0)}<span class="text-sm">MB</span>
</div> </div>
</div> </div>
<div class="stat w-64">
<div class="stat-title">Free Memory</div> <div class="stat">
<div class="stat-value"> <div class="stat-title">Free</div>
<div class="stat-value text-2xl">
{usage?.memory.freeMemPercentage}<span class="text-sm">%</span> {usage?.memory.freeMemPercentage}<span class="text-sm">%</span>
</div> </div>
</div> </div>
</div> </div>
<div class="py-10">
<div class="stat w-64"> <div class="stats stats-vertical lg:stats-horizontal w-full mb-5 bg-transparent rounded">
<div class="stat-title">Total CPUs</div> <div class="font-bold flex lg:justify-center">CPU</div>
<div class="stat-value"> <div class="stat">
<div class="stat-title">Total</div>
<div class="stat-value text-2xl">
{usage?.cpu.count} {usage?.cpu.count}
</div> </div>
</div> </div>
<div class="stat w-64">
<div class="stat-title">CPU Usage</div> <div class="stat">
<div class="stat-value"> <div class="stat-title">Usage</div>
<div class="stat-value text-2xl">
{usage?.cpu.usage}<span class="text-sm">%</span> {usage?.cpu.usage}<span class="text-sm">%</span>
</div> </div>
</div> </div>
<div class="stat w-64">
<div class="stat">
<div class="stat-title">Load Average (5,10,30mins)</div> <div class="stat-title">Load Average (5,10,30mins)</div>
<div class="stat-value">{usage?.cpu.load}</div> <div class="stat-value text-2xl">{usage?.cpu.load}</div>
</div> </div>
</div> </div>
<div> <div class="stats stats-vertical lg:stats-horizontal w-full mb-5 bg-transparent rounded">
<div class="stat w-64"> <div class="font-bold flex lg:justify-center">Disk</div>
<div class="stat-title">Total Disk</div> <div class="stat">
<div class="stat-value"> <div class="stat-title">Total</div>
<div class="stat-value text-2xl">
{usage?.disk.totalGb}<span class="text-sm">GB</span> {usage?.disk.totalGb}<span class="text-sm">GB</span>
</div> </div>
</div> </div>
<div class="stat w-64">
<div class="stat-title">Used Disk</div> <div class="stat">
<div class="stat-value"> <div class="stat-title">Used</div>
<div class="stat-value text-2xl">
{usage?.disk.usedGb}<span class="text-sm">GB</span> {usage?.disk.usedGb}<span class="text-sm">GB</span>
</div> </div>
</div> </div>
<div class="stat w-64">
<div class="stat-title">Free Disk</div> <div class="stat">
<div class="stat-value">{usage?.disk.freePercentage}<span class="text-sm">%</span></div> <div class="stat-title">Free</div>
<div class="stat-value text-2xl">
{usage?.disk.freePercentage}<span class="text-sm">%</span>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -2,79 +2,8 @@
export let isAbsolute = true; export let isAbsolute = true;
</script> </script>
<svg
viewBox="0 0 128 128" <svg viewBox="0 0 128 128" class={isAbsolute ? 'absolute top-0 left-0 -m-8 h-16 w-16' : 'mx-auto w-10 h-10'}>
class={isAbsolute ? 'absolute top-0 left-0 -m-8 h-16 w-16' : 'mx-auto w-8 h-8'} <path d="M124.8 52.1c-4.3-2.5-10-2.8-14.8-1.4-.6-5.2-4-9.7-8-12.9l-1.6-1.3-1.4 1.6c-2.7 3.1-3.5 8.3-3.1 12.3.3 2.9 1.2 5.9 3 8.3-1.4.8-2.9 1.9-4.3 2.4-2.8 1-5.9 2-8.9 2H79V49H66V24H51v12H26v13H13v14H1.8l-.2 1.5c-.5 6.4.3 12.6 3 18.5l1.1 2.2.1.2c7.9 13.4 21.7 19 36.8 19 29.2 0 53.3-13.1 64.3-40.6 7.4.4 15-1.8 18.6-8.9l.9-1.8-1.6-1zM28 39h10v11H28V39zm13.1 44.2c0 1.7-1.4 3.1-3.1 3.1-1.7 0-3.1-1.4-3.1-3.1 0-1.7 1.4-3.1 3.1-3.1 1.7.1 3.1 1.4 3.1 3.1zM28 52h10v11H28V52zm-13 0h11v11H15V52zm27.7 50.2c-15.8-.1-24.3-5.4-31.3-12.4 2.1.1 4.1.2 5.9.2 1.6 0 3.2 0 4.7-.1 3.9-.2 7.3-.7 10.1-1.5 2.3 5.3 6.5 10.2 14 13.8h-3.4zM51 63H40V52h11v11zm0-13H40V39h11v11zm13 13H53V52h11v11zm0-13H53V39h11v11zm0-13H53V26h11v11zm13 26H66V52h11v11zM38.8 81.2c-.2-.1-.5-.2-.8-.2-1.2 0-2.2 1-2.2 2.2 0 1.2 1 2.2 2.2 2.2s2.2-1 2.2-2.2c0-.3-.1-.6-.2-.8-.2.3-.4.5-.8.5-.5 0-.9-.4-.9-.9.1-.4.3-.7.5-.8z" fill="#019BC6"></path>
> </svg>
<g
><path
fill-rule="evenodd"
clip-rule="evenodd"
fill="#3A4D54"
d="M73.8 50.8h11.3v11.5h5.7c2.6 0 5.3-.5 7.8-1.3 1.2-.4 2.6-1 3.8-1.7-1.6-2.1-2.4-4.7-2.6-7.3-.3-3.5.4-8.1 2.8-10.8l1.2-1.4 1.4 1.1c3.6 2.9 6.5 6.8 7.1 11.4 4.3-1.3 9.3-1 13.1 1.2l1.5.9-.8 1.6c-3.2 6.2-9.9 8.2-16.4 7.8-9.8 24.3-31 35.8-56.8 35.8-13.3 0-25.5-5-32.5-16.8l-.1-.2-1-2.1c-2.4-5.2-3.1-10.9-2.6-16.6l.2-1.7h9.6v-11.4h11.3v-11.2h22.5v-11.3h13.5v22.5z"
/><path
fill="#00AADA"
d="M110.4 55.1c.8-5.9-3.6-10.5-6.4-12.7-3.1 3.6-3.6 13.2 1.3 17.2-2.8 2.4-8.5 4.7-14.5 4.7h-72.2c-.6 6.2.5 11.9 3 16.8l.8 1.5c.5.9 1.1 1.7 1.7 2.6 3 .2 5.7.3 8.2.2 4.9-.1 8.9-.7 12-1.7.5-.2.9.1 1.1.5.2.5-.1.9-.5 1.1-.4.1-.8.3-1.3.4-2.4.7-5 1.1-8.3 1.3h-.6000000000000001c-1.3.1-2.7.1-4.2.1-1.6 0-3.1 0-4.9-.1 6 6.8 15.4 10.8 27.2 10.8 25 0 46.2-11.1 55.5-35.9 6.7.7 13.1-1 16-6.7-4.5-2.7-10.5-1.8-13.9-.1z"
/><path
fill="#28B8EB"
d="M110.4 55.1c.8-5.9-3.6-10.5-6.4-12.7-3.1 3.6-3.6 13.2 1.3 17.2-2.8 2.4-8.5 4.7-14.5 4.7h-68c-.3 9.5 3.2 16.7 9.5 21 4.9-.1 8.9-.7 12-1.7.5-.2.9.1 1.1.5.2.5-.1.9-.5 1.1-.4.1-.8.3-1.3.4-2.4.7-5.2 1.2-8.5 1.4l-.1-.1c8.5 4.4 20.8 4.3 35-1.1 15.8-6.1 30.6-17.7 40.9-30.9-.2.1-.4.1-.5.2z"
/><path
fill="#028BB8"
d="M18.7 71.8c.4 3.3 1.4 6.4 2.9 9.3l.8 1.5c.5.9 1.1 1.7 1.7 2.6 3 .2 5.7.3 8.2.2 4.9-.1 8.9-.7 12-1.7.5-.2.9.1 1.1.5.2.5-.1.9-.5 1.1-.4.1-.8.3-1.3.4-2.4.7-5.2 1.2-8.5 1.4h-.4c-1.3.1-2.7.1-4.1.1-1.6 0-3.2 0-4.9-.1 6 6.8 15.5 10.8 27.3 10.8 21.4 0 40-8.1 50.8-26h-85.1v-.1z"
/><path
fill="#019BC6"
d="M23.5 71.8c1.3 5.8 4.3 10.4 8.8 13.5 4.9-.1 8.9-.7 12-1.7.5-.2.9.1 1.1.5.2.5-.1.9-.5 1.1-.4.1-.8.3-1.3.4-2.4.7-5.2 1.2-8.6 1.4 8.5 4.4 20.8 4.3 34.9-1.1 8.5-3.3 16.8-8.2 24.2-14.1h-70.6z"
/><path
fill-rule="evenodd"
clip-rule="evenodd"
fill="#00ACD3"
d="M28.4 52.7h9.8v9.8h-9.8v-9.8zm.8.8h.8v8.1h-.8v-8.1zm1.4 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zM39.6 41.5h9.8v9.8h-9.8v-9.8zm.9.8h.8v8.1h-.8v-8.1zm1.4 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.4 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1z"
/><path
fill-rule="evenodd"
clip-rule="evenodd"
fill="#23C2EE"
d="M39.6 52.7h9.8v9.8h-9.8v-9.8zm.9.8h.8v8.1h-.8v-8.1zm1.4 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.4 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1z"
/><path
fill-rule="evenodd"
clip-rule="evenodd"
fill="#00ACD3"
d="M50.9 52.7h9.8v9.8h-9.8v-9.8zm.8.8h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.4 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1z"
/><path
fill-rule="evenodd"
clip-rule="evenodd"
fill="#23C2EE"
d="M50.9 41.5h9.8v9.8h-9.8v-9.8zm.8.8h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.4 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zM62.2 52.7h9.8v9.8h-9.8v-9.8zm.8.8h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.4 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1z"
/><path
fill-rule="evenodd"
clip-rule="evenodd"
fill="#00ACD3"
d="M62.2 41.5h9.8v9.8h-9.8v-9.8zm.8.8h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.4 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1z"
/><path
fill-rule="evenodd"
clip-rule="evenodd"
fill="#23C2EE"
d="M62.2 30.2h9.8v9.8h-9.8v-9.8zm.8.8h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.4 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1z"
/><path
fill-rule="evenodd"
clip-rule="evenodd"
fill="#00ACD3"
d="M73.5 52.7h9.8v9.8h-9.8v-9.8zm.8.8h.8v8.1h-.8v-8.1zm1.4 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1zm1.5 0h.8v8.1h-.8v-8.1z"
/><path
fill-rule="evenodd"
clip-rule="evenodd"
fill="#D4EEF1"
d="M48.8 78.3c1.5 0 2.7 1.2 2.7 2.7 0 1.5-1.2 2.7-2.7 2.7-1.5 0-2.7-1.2-2.7-2.7 0-1.5 1.2-2.7 2.7-2.7"
/><path
fill-rule="evenodd"
clip-rule="evenodd"
fill="#3A4D54"
d="M48.8 79.1c.2 0 .5 0 .7.1-.2.1-.4.4-.4.7 0 .4.4.8.8.8.3 0 .6-.2.7-.4.1.2.1.5.1.7 0 1.1-.9 1.9-1.9 1.9-1.1 0-1.9-.9-1.9-1.9 0-1 .8-1.9 1.9-1.9M1.1 72.8h125.4c-2.7-.7-8.6-1.6-7.7-5.2-5 5.7-16.9 4-20 1.2-3.4 4.9-23 3-24.3-.8-4.2 5-17.3 5-21.5 0-1.4 3.8-21 5.7-24.3.8-3 2.8-15 4.5-20-1.2 1.1 3.5-4.9 4.5-7.6 5.2"
/><path
fill="#BFDBE0"
d="M56 97.8c-6.7-3.2-10.3-7.5-12.4-12.2-2.5.7-5.5 1.2-8.9 1.4-1.3.1-2.7.1-4.1.1-1.7 0-3.4 0-5.2-.1 6 6 13.6 10.7 27.5 10.8h3.1z"
/><path
fill="#D4EEF1"
d="M46.1 89.9c-.9-1.3-1.8-2.8-2.5-4.3-2.5.7-5.5 1.2-8.9 1.4 2.3 1.2 5.7 2.4 11.4 2.9z"
/></g
>
</svg>

View File

@@ -4,7 +4,7 @@
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
class={isAbsolute ? 'w-14 h-14 absolute top-0 left-0 -m-5' : 'w-9 mx-auto'} class={isAbsolute ? 'w-14 h-14 absolute top-0 left-0 -m-5' : 'w-9 h-9 mx-auto'}
viewBox="0 0 384 384" viewBox="0 0 384 384"
fill="none" fill="none"
> >

View File

@@ -5,7 +5,7 @@
<svg <svg
viewBox="0 0 700 240" viewBox="0 0 700 240"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
class={isAbsolute ? 'w-36 absolute top-0 left-0 -m-3 -mt-5' : 'w-28 mx-auto'} class={isAbsolute ? 'w-36 absolute top-0 left-0 -m-3 -mt-5' : 'w-28 h-28 mx-auto'}
><path fill="#FDBC3D" d="m90.694 107.498-.981.39-20.608 8.23 6.332 6.547z" /><path ><path fill="#FDBC3D" d="m90.694 107.498-.981.39-20.608 8.23 6.332 6.547z" /><path
fill="#8EC63F" fill="#8EC63F"
d="M61.139 77.914 46.632 93 56.9 103.547c8.649-7.169 17.832-10.502 18.653-10.789L61.139 77.914z" d="M61.139 77.914 46.632 93 56.9 103.547c8.649-7.169 17.832-10.502 18.653-10.789L61.139 77.914z"

View File

@@ -3,7 +3,7 @@
</script> </script>
<svg <svg
class={isAbsolute ? 'w-10 h-10 absolute top-0 left-0 -m-5' : 'w-8 mx-auto'} class={isAbsolute ? 'w-10 h-10 absolute top-0 left-0 -m-5' : 'w-8 h-8 mx-auto'}
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xlink="http://www.w3.org/1999/xlink"
style="isolation:isolate" style="isolation:isolate"

View File

@@ -4,6 +4,6 @@
<img <img
alt="plausible logo" alt="plausible logo"
class={isAbsolute ? 'w-9 absolute top-0 left-0 -m-4' : 'w-6 mx-auto'} class={isAbsolute ? 'w-9 h-12 absolute top-0 left-0 -m-4' : 'w-6 h-8 mx-auto'}
src="/plausible.png" src="/plausible.png"
/> />

View File

@@ -0,0 +1,56 @@
<script lang="ts">
export let isAbsolute = false;
</script>
<svg
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
id="svg8"
version="1.1"
viewBox="0 0 92 92"
class={isAbsolute ? 'w-12 h-12 absolute top-0 left-0 -m-3 -mt-5' : 'w-8 h-8 mx-auto'}
>
<defs id="defs2" />
<metadata id="metadata5">
<rdf:RDF>
<cc:Work rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g transform="translate(-40.921303,-17.416526)" id="layer1">
<circle
r="0"
style="fill:none;stroke:#000000;stroke-width:12;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
cy="92"
cx="75"
id="path3713"
/>
<circle
r="30"
cy="53.902557"
cx="75.921303"
id="path834"
style="fill:none;fill-opacity:1;stroke:#3050ff;stroke-width:10;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
/>
<path
d="m 67.514849,37.91524 a 18,18 0 0 1 21.051475,3.312407 18,18 0 0 1 3.137312,21.078282"
id="path852"
style="fill:none;fill-opacity:1;stroke:#3050ff;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
/>
<rect
transform="rotate(-46.234709)"
ry="1.8669105e-13"
y="122.08995"
x="3.7063529"
height="39.963303"
width="18.846331"
id="rect912"
style="opacity:1;fill:#3050ff;fill-opacity:1;stroke:none;stroke-width:8;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
/>
</g>
</svg>

View File

@@ -38,4 +38,6 @@
<Icons.Moodle {isAbsolute} /> <Icons.Moodle {isAbsolute} />
{:else if type === 'glitchTip'} {:else if type === 'glitchTip'}
<Icons.GlitchTip {isAbsolute} /> <Icons.GlitchTip {isAbsolute} />
{:else if type === 'searxng'}
<Icons.Searxng {isAbsolute} />
{/if} {/if}

View File

@@ -16,3 +16,4 @@ export { default as Fider } from './Fider.svelte';
export { default as Appwrite } from './Appwrite.svelte'; export { default as Appwrite } from './Appwrite.svelte';
export { default as Moodle } from './Moodle.svelte'; export { default as Moodle } from './Moodle.svelte';
export { default as GlitchTip } from './GlitchTip.svelte'; export { default as GlitchTip } from './GlitchTip.svelte';
export { default as Searxng } from './Searxng.svelte';

View File

@@ -66,7 +66,6 @@
let loading = false; let loading = false;
let statusInterval: any; let statusInterval: any;
let isQueueActive = false;
$disabledButton = $disabledButton =
!$appSession.isAdmin || !$appSession.isAdmin ||
(!application.fqdn && !application.settings.isBot) || (!application.fqdn && !application.settings.isBot) ||
@@ -121,7 +120,6 @@
if ($status.application.loading) return; if ($status.application.loading) return;
$status.application.loading = true; $status.application.loading = true;
const data = await get(`/applications/${id}/status`); const data = await get(`/applications/${id}/status`);
isQueueActive = data.isQueueActive;
$status.application.isRunning = data.isRunning; $status.application.isRunning = data.isRunning;
$status.application.isExited = data.isExited; $status.application.isExited = data.isExited;
$status.application.loading = false; $status.application.loading = false;
@@ -259,13 +257,10 @@
<form on:submit|preventDefault={() => handleDeploySubmit(true)}> <form on:submit|preventDefault={() => handleDeploySubmit(true)}>
<button <button
type="submit" type="submit"
disabled={$disabledButton || !isQueueActive} disabled={$disabledButton}
class:hover:text-green-500={isQueueActive}
class="icons bg-transparent tooltip tooltip-primary tooltip-bottom text-sm flex items-center space-x-2" class="icons bg-transparent tooltip tooltip-primary tooltip-bottom text-sm flex items-center space-x-2"
data-tip={$appSession.isAdmin data-tip={$appSession.isAdmin
? isQueueActive ? 'Force Rebuild Application'
? 'Force Rebuild Application'
: 'Autoupdate inprogress. Cannot rebuild application.'
: 'You do not have permission to rebuild application.'} : 'You do not have permission to rebuild application.'}
> >
<svg <svg
@@ -287,7 +282,7 @@
</button> </button>
</form> </form>
{:else} {:else}
<form on:submit|preventDefault={handleDeploySubmit}> <form on:submit|preventDefault={() => handleDeploySubmit(false)}>
<button <button
type="submit" type="submit"
disabled={$disabledButton} disabled={$disabledButton}
@@ -359,7 +354,7 @@
<button <button
disabled={$disabledButton} disabled={$disabledButton}
class="icons bg-transparent tooltip tooltip-primary tooltip-bottom text-sm" class="icons bg-transparent tooltip tooltip-primary tooltip-bottom text-sm"
data-tip="Secret" data-tip="Secrets"
> >
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"

View File

@@ -146,6 +146,7 @@
class="tooltip tooltip-primary tooltip-top flex cursor-pointer items-center justify-center border-l-2 py-4 no-underline transition-all duration-100 hover:bg-coolgray-400 hover:shadow-xl" class="tooltip tooltip-primary tooltip-top flex cursor-pointer items-center justify-center border-l-2 py-4 no-underline transition-all duration-100 hover:bg-coolgray-400 hover:shadow-xl"
class:bg-coolgray-400={buildId === build.id} class:bg-coolgray-400={buildId === build.id}
class:border-red-500={build.status === 'failed'} class:border-red-500={build.status === 'failed'}
class:border-orange-500={build.status === 'canceled'}
class:border-green-500={build.status === 'success'} class:border-green-500={build.status === 'success'}
class:border-yellow-500={build.status === 'running'} class:border-yellow-500={build.status === 'running'}
> >
@@ -157,7 +158,6 @@
{build.type} {build.type}
</div> </div>
</div> </div>
<div class="flex-1" />
<div class="w-48 text-center text-xs"> <div class="w-48 text-center text-xs">
{#if build.status === 'running'} {#if build.status === 'running'}
@@ -177,7 +177,7 @@
{#if !noMoreBuilds} {#if !noMoreBuilds}
{#if buildCount > 5} {#if buildCount > 5}
<div class="flex space-x-2"> <div class="flex space-x-2">
<button disabled={noMoreBuilds} class="w-full" on:click={loadMoreBuilds} <button disabled={noMoreBuilds} class=" btn btn-sm w-full" on:click={loadMoreBuilds}
>{$t('application.build.load_more')}</button >{$t('application.build.load_more')}</button
> >
</div> </div>

View File

@@ -194,12 +194,13 @@
</div> </div>
</a> </a>
<div class="flex items-center justify-center"> <div class="flex items-center justify-center">
<button class="bg-coollabs hover:bg-coollabs-100" on:click={() => redeploy(container)} <button class="btn btn-sm bg-coollabs hover:bg-coollabs-100" on:click={() => redeploy(container)}
>{$t('application.preview.redeploy')}</button >{$t('application.preview.redeploy')}</button
> >
</div> </div>
<div class="flex items-center justify-center"> <div class="flex items-center justify-center">
<button <button
class="btn btn-sm"
class:bg-red-600={!loading.removing} class:bg-red-600={!loading.removing}
class:hover:bg-red-500={!loading.removing} class:hover:bg-red-500={!loading.removing}
disabled={loading.removing} disabled={loading.removing}

View File

@@ -43,7 +43,8 @@
const batchSecretsPairs = eachValuePair const batchSecretsPairs = eachValuePair
.filter((secret) => !secret.startsWith('#') && secret) .filter((secret) => !secret.startsWith('#') && secret)
.map((secret) => { .map((secret) => {
const [name, value] = secret.split('='); const [name, ...rest] = secret.split('=');
const value = rest.join('=');
const cleanValue = value?.replaceAll('"', '') || ''; const cleanValue = value?.replaceAll('"', '') || '';
return { return {
name, name,

View File

@@ -64,7 +64,7 @@
</button> </button>
{/if} {/if}
</div> </div>
<div class="flex-col justify-center"> <div class="flex-col justify-center mt-10 pb-12 sm:pb-16">
{#if !applications || ownApplications.length === 0} {#if !applications || ownApplications.length === 0}
<div class="flex-col"> <div class="flex-col">
<div class="text-center text-xl font-bold">{$t('application.no_applications_found')}</div> <div class="text-center text-xl font-bold">{$t('application.no_applications_found')}</div>

View File

@@ -61,7 +61,7 @@
</button> </button>
</div> </div>
<div class="flex-col justify-center"> <div class="flex-col justify-center mt-10 pb-12 sm:pb-16">
{#if !databases || ownDatabases.length === 0} {#if !databases || ownDatabases.length === 0}
<div class="flex-col"> <div class="flex-col">
<div class="text-center text-xl font-bold">{$t('database.no_databases_found')}</div> <div class="text-center text-xl font-bold">{$t('database.no_databases_found')}</div>

View File

@@ -56,7 +56,7 @@
</a> </a>
{/if} {/if}
</div> </div>
<div class="flex-col justify-center"> <div class="flex-col justify-center mt-10 pb-12 sm:pb-16">
{#if !destinations || ownDestinations.length === 0} {#if !destinations || ownDestinations.length === 0}
<div class="flex-col"> <div class="flex-col">
<div class="text-center text-xl font-bold">{$t('destination.no_destination_found')}</div> <div class="text-center text-xl font-bold">{$t('destination.no_destination_found')}</div>

View File

@@ -212,6 +212,7 @@
<div class="flex items-center justify-center pt-3"> <div class="flex items-center justify-center pt-3">
<button <button
on:click|preventDefault={() => switchTeam(team.id)} on:click|preventDefault={() => switchTeam(team.id)}
class="btn btn-sm"
class:bg-fuchsia-600={$appSession.teamId !== team.id} class:bg-fuchsia-600={$appSession.teamId !== team.id}
class:hover:bg-fuchsia-500={$appSession.teamId !== team.id} class:hover:bg-fuchsia-500={$appSession.teamId !== team.id}
class:bg-transparent={$appSession.teamId === team.id} class:bg-transparent={$appSession.teamId === team.id}

View File

@@ -36,10 +36,6 @@
import ServiceIcons from '$lib/components/svg/services/ServiceIcons.svelte'; import ServiceIcons from '$lib/components/svg/services/ServiceIcons.svelte';
import { dev } from '$app/env'; import { dev } from '$app/env';
let loading = {
cleanup: false
};
let numberOfGetStatus = 0; let numberOfGetStatus = 0;
function getRndInteger(min: number, max: number) { function getRndInteger(min: number, max: number) {
@@ -75,276 +71,217 @@
numberOfGetStatus--; numberOfGetStatus--;
} }
} }
async function manuallyCleanupStorage() {
try {
loading.cleanup = true;
await post('/internal/cleanup', {});
return addToast({
message: 'Cleanup done.',
type: 'success'
});
} catch (error) {
return errorNotification(error);
} finally {
loading.cleanup = false;
}
}
</script> </script>
<div class="flex space-x-1 p-6 font-bold"> <div class="flex space-x-1 p-6 font-bold">
<div class="mr-4 text-2xl tracking-tight">{$t('index.dashboard')}</div> <div class="mr-4 text-2xl tracking-tight">{$t('index.dashboard')}</div>
<button on:click={manuallyCleanupStorage} class:loading={loading.cleanup} class="btn btn-sm"
>Cleanup Storage</button
>
</div> </div>
<div class="mt-10 pb-12 tracking-tight sm:pb-16"> <div class="container lg:mx-auto lg:p-0 p-5">
<div class="mx-auto px-10"> {#if $appSession.teamId === '0'}
<div class="flex flex-col justify-center xl:flex-row"> <Usage />
{#if applications.length > 0} {/if}
<div> <h1 class="title text-4xl mt-10">Applications</h1>
<div class="title">Resources</div> <div class="divider" />
<div class="flex items-start justify-center p-8"> <div class="grid grid-col gap-4 auto-cols-max grid-cols-1 lg:grid-cols-3 p-4">
<table class="rounded-none text-base"> {#if applications.length > 0}
<tbody> {#each applications as application}
{#each applications as application} <a class="no-underline mb-5" href={`/applications/${application.id}`}>
<tr> <div class="w-full rounded p-5 bg-coolgray-200 hover:bg-green-600 indicator">
<td class="space-x-2 items-center tracking-tight font-bold"> {#await getStatus(application)}
{#await getStatus(application)} <span class="indicator-item badge bg-yellow-500 badge-xs" />
<div class="inline-flex w-2 h-2 bg-yellow-500 rounded-full" /> {:then status}
{:then status} {#if status === 'Running'}
{#if status === 'Running'} <span class="indicator-item badge bg-success badge-xs" />
<div class="inline-flex w-2 h-2 bg-success rounded-full" /> {:else}
{:else} <span class="indicator-item badge bg-error badge-xs" />
<div class="inline-flex w-2 h-2 bg-error rounded-full" /> {/if}
{/if} {/await}
{/await} <div class="w-full flex flex-row">
<div class="inline-flex">{application.name}</div> <ApplicationsIcons {application} isAbsolute={false} />
</td> <div class="w-full flex flex-col ml-5">
<td class="px-10 inline-flex"> <h1 class="font-bold text-xl truncate">
<ApplicationsIcons {application} isAbsolute={false} /> {application.name}
</td> {#if application.settings.isBot}
<td class="px-10"> <span class="text-xs"> BOT</span>
<div {/if}
class="badge badge-outline text-xs border-applications rounded text-white" </h1>
<div class="h-10">
{#if application?.fqdn}
<h2>{application?.fqdn.replace('https://', '').replace('http://', '')}</h2>
{:else if !application.settings.isBot && !application?.fqdn}
<h2 class="text-red-500">Not configured</h2>
{/if}
</div>
<div class="flex justify-end items-end space-x-2 h-10">
{#if application.fqdn}
<a href={application.fqdn} target="_blank" class="icons hover:bg-green-500">
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
> >
Application <path stroke="none" d="M0 0h24v24H0z" fill="none" />
{#if application.settings.isBot} <path d="M11 7h-5a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-5" />
| BOT <line x1="10" y1="14" x2="20" y2="4" />
{/if} <polyline points="15 4 20 4 20 9" />
</div></td </svg>
</a>
{/if}
{#if application.settings.isBot && application.exposePort}
<a
href={`http://${dev ? 'localhost' : settings.ipv4}:${application.exposePort}`}
target="_blank"
class="icons hover:bg-green-500"
> >
<td class="flex justify-end"> <svg
{#if application.fqdn} xmlns="http://www.w3.org/2000/svg"
<a class="h-6 w-6"
href={application.fqdn} viewBox="0 0 24 24"
target="_blank" stroke-width="1.5"
class="icons bg-transparent text-sm inline-flex" stroke="currentColor"
><svg fill="none"
xmlns="http://www.w3.org/2000/svg" stroke-linecap="round"
class="h-6 w-6" stroke-linejoin="round"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M11 7h-5a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-5" />
<line x1="10" y1="14" x2="20" y2="4" />
<polyline points="15 4 20 4 20 9" />
</svg></a
>
{/if}
{#if application.settings.isBot && application.exposePort}
<a
href={`http://${dev ? 'localhost' : settings.ipv4}:${
application.exposePort
}`}
target="_blank"
class="icons bg-transparent text-sm inline-flex"
><svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M11 7h-5a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-5" />
<line x1="10" y1="14" x2="20" y2="4" />
<polyline points="15 4 20 4 20 9" />
</svg></a
>
{/if}
<a
href={`/applications/${application.id}`}
class="icons bg-transparent text-sm inline-flex"
> >
<svg <path stroke="none" d="M0 0h24v24H0z" fill="none" />
xmlns="http://www.w3.org/2000/svg" <path d="M11 7h-5a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-5" />
class="h-6 w-6" <line x1="10" y1="14" x2="20" y2="4" />
viewBox="0 0 24 24" <polyline points="15 4 20 4 20 9" />
stroke-width="1.5" </svg>
stroke="currentColor" </a>
fill="none" {/if}
stroke-linecap="round" </div>
stroke-linejoin="round" </div>
> </div>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<rect x="4" y="8" width="4" height="4" />
<line x1="6" y1="4" x2="6" y2="8" />
<line x1="6" y1="12" x2="6" y2="20" />
<rect x="10" y="14" width="4" height="4" />
<line x1="12" y1="4" x2="12" y2="14" />
<line x1="12" y1="18" x2="12" y2="20" />
<rect x="16" y="5" width="4" height="4" />
<line x1="18" y1="4" x2="18" y2="5" />
<line x1="18" y1="9" x2="18" y2="20" />
</svg>
</a>
</td>
</tr>
{/each}
{#each services as service}
<tr>
<td class="space-x-2 items-center tracking-tight font-bold">
{#await getStatus(service)}
<div class="inline-flex w-2 h-2 bg-yellow-500 rounded-full" />
{:then status}
{#if status === 'Running'}
<div class="inline-flex w-2 h-2 bg-success rounded-full" />
{:else}
<div class="inline-flex w-2 h-2 bg-error rounded-full" />
{/if}
{/await}
<div class="inline-flex">{service.name}</div>
</td>
<td class="px-10 inline-flex">
<ServiceIcons type={service.type} isAbsolute={false} />
</td>
<td class="px-10"
><div class="badge badge-outline text-xs border-services rounded text-white">
Service
</div>
</td>
<td class="flex justify-end">
{#if service.fqdn}
<a
href={service.fqdn}
target="_blank"
class="icons bg-transparent text-sm inline-flex"
><svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M11 7h-5a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-5" />
<line x1="10" y1="14" x2="20" y2="4" />
<polyline points="15 4 20 4 20 9" />
</svg></a
>
{/if}
<a
href={`/services/${service.id}`}
class="icons bg-transparent text-sm inline-flex"
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<rect x="4" y="8" width="4" height="4" />
<line x1="6" y1="4" x2="6" y2="8" />
<line x1="6" y1="12" x2="6" y2="20" />
<rect x="10" y="14" width="4" height="4" />
<line x1="12" y1="4" x2="12" y2="14" />
<line x1="12" y1="18" x2="12" y2="20" />
<rect x="16" y="5" width="4" height="4" />
<line x1="18" y1="4" x2="18" y2="5" />
<line x1="18" y1="9" x2="18" y2="20" />
</svg>
</a>
</td>
</tr>
{/each}
{#each databases as database}
<tr>
<td class="space-x-2 items-center tracking-tight font-bold">
{#await getStatus(database)}
<div class="inline-flex w-2 h-2 bg-yellow-500 rounded-full" />
{:then status}
{#if status === 'Running'}
<div class="inline-flex w-2 h-2 bg-success rounded-full" />
{:else}
<div class="inline-flex w-2 h-2 bg-error rounded-full" />
{/if}
{/await}
<div class="inline-flex">{database.name}</div>
</td>
<td class="px-10 inline-flex">
<DatabaseIcons type={database.type} />
</td>
<td class="px-10">
<div class="badge badge-outline text-xs border-databases rounded text-white">
Database
</div>
</td>
<td class="flex justify-end">
<a
href={`/databases/${database.id}`}
class="icons bg-transparent text-sm inline-flex ml-11"
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<rect x="4" y="8" width="4" height="4" />
<line x1="6" y1="4" x2="6" y2="8" />
<line x1="6" y1="12" x2="6" y2="20" />
<rect x="10" y="14" width="4" height="4" />
<line x1="12" y1="4" x2="12" y2="14" />
<line x1="12" y1="18" x2="12" y2="20" />
<rect x="16" y="5" width="4" height="4" />
<line x1="18" y1="4" x2="18" y2="5" />
<line x1="18" y1="9" x2="18" y2="20" />
</svg>
</a>
</td>
</tr>
{/each}
</tbody>
</table>
</div> </div>
</div> </a>
{/if} {/each}
{#if $appSession.teamId === '0'} {:else}
<Usage /> <h1 class="">Nothing is configured yet.</h1>
{/if} {/if}
</div> </div>
<h1 class="title text-4xl mt-10">Services</h1>
<div class="divider" />
<div class="grid grid-col gap-4 auto-cols-max grid-cols-1 lg:grid-cols-3 p-4">
{#if services.length > 0}
{#each services as service}
<a class="no-underline mb-5" href={`/services/${service.id}`}>
<div class="w-full rounded p-5 bg-coolgray-200 hover:bg-pink-600 indicator">
{#await getStatus(service)}
<span class="indicator-item badge bg-yellow-500 badge-xs" />
{:then status}
{#if status === 'Running'}
<span class="indicator-item badge bg-success badge-xs" />
{:else}
<span class="indicator-item badge bg-error badge-xs" />
{/if}
{/await}
<div class="w-full flex flex-row">
<ServiceIcons type={service.type} isAbsolute={false} />
<div class="w-full flex flex-col ml-5">
<h1 class="font-bold text-xl truncate">{service.name}</h1>
<div class="h-10">
{#if service?.fqdn}
<h2>{service?.fqdn.replace('https://', '').replace('http://', '')}</h2>
{:else}
<h2 class="text-red-500">Not configured</h2>
{/if}
</div>
<div class="flex justify-end items-end space-x-2 h-10">
{#if service.fqdn}
<a href={service.fqdn} target="_blank" class="icons hover:bg-pink-500">
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M11 7h-5a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-5" />
<line x1="10" y1="14" x2="20" y2="4" />
<polyline points="15 4 20 4 20 9" />
</svg>
</a>
{/if}
</div>
</div>
</div>
</div>
</a>
{/each}
{:else}
<h1 class="">Nothing is configured yet.</h1>
{/if}
</div>
<h1 class="title text-4xl mt-10">Databases</h1>
<div class="divider" />
<div class="grid grid-col gap-4 auto-cols-max grid-cols-1 lg:grid-cols-3 p-4 mb-32">
{#if databases.length > 0}
{#each databases as database}
<a class="no-underline mb-5" href={`/databases/${database.id}`}>
<div class="w-full rounded p-5 bg-coolgray-200 hover:bg-purple-500 indicator">
{#await getStatus(database)}
<span class="indicator-item badge bg-yellow-500 badge-xs" />
{:then status}
{#if status === 'Running'}
<span class="indicator-item badge bg-success badge-xs" />
{:else}
<span class="indicator-item badge bg-error badge-xs" />
{/if}
{/await}
<div class="w-full flex flex-row pt-2">
<DatabaseIcons type={database.type} isAbsolute={false} />
<div class="w-full flex flex-col ml-5">
<div class="h-10">
<h1 class="font-bold text-xl truncate">{database.name}</h1>
<div class="h-10">
{#if database?.version}
<h2>{database?.version}</h2>
{:else}
<h2 class="text-red-500">Not configured</h2>
{/if}
</div>
</div>
<div class="flex justify-end items-end space-x-2 h-10">
{#if database.settings.isPublic}
<div title="Public">
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6 "
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<circle cx="12" cy="12" r="9" />
<line x1="3.6" y1="9" x2="20.4" y2="9" />
<line x1="3.6" y1="15" x2="20.4" y2="15" />
<path d="M11.5 3a17 17 0 0 0 0 18" />
<path d="M12.5 3a17 17 0 0 1 0 18" />
</svg>
</div>
{/if}
</div>
</div>
</div>
</div>
</a>
{/each}
{:else}
<h1 class="">Nothing is configured yet.</h1>
{/if}
</div> </div>
</div> </div>

View File

@@ -57,7 +57,7 @@
</a> </a>
{:else if service.type === 'appwrite'} {:else if service.type === 'appwrite'}
<a href="https://appwrite.io" target="_blank"> <a href="https://appwrite.io" target="_blank">
<Icons.Appwrite/> <Icons.Appwrite />
</a> </a>
{:else if service.type === 'moodle'} {:else if service.type === 'moodle'}
<a href="https://moodle.org" target="_blank"> <a href="https://moodle.org" target="_blank">
@@ -67,4 +67,8 @@
<a href="https://glitchtip.com" target="_blank"> <a href="https://glitchtip.com" target="_blank">
<Icons.GlitchTip /> <Icons.GlitchTip />
</a> </a>
{:else if service.type === 'searxng'}
<a href="https://searxng.org" target="_blank">
<Icons.Searxng />
</a>
{/if} {/if}

View File

@@ -0,0 +1,36 @@
<script lang="ts">
import CopyPasswordField from '$lib/components/CopyPasswordField.svelte';
import { t } from '$lib/translations';
export let service: any;
</script>
<div class="flex space-x-1 py-5 font-bold">
<div class="title">SearXNG</div>
</div>
<div class="grid grid-cols-2 items-center px-10">
<label for="secretKey">Secret Key</label>
<CopyPasswordField
name="secretKey"
id="secretKey"
isPasswordField
value={service.searxng.secretKey}
readonly
disabled
/>
</div>
<div class="flex space-x-1 py-5 font-bold">
<div class="title">Redis</div>
</div>
<div class="grid grid-cols-2 items-center px-10">
<label for="redisPassword">{$t('forms.password')}</label>
<CopyPasswordField
name="redisPassword"
id="redisPassword"
isPasswordField
value={service.searxng.redisPassword}
readonly
disabled
/>
</div>

View File

@@ -29,6 +29,7 @@
import Wordpress from './_Wordpress.svelte'; import Wordpress from './_Wordpress.svelte';
import Appwrite from './_Appwrite.svelte'; import Appwrite from './_Appwrite.svelte';
import Moodle from './_Moodle.svelte'; import Moodle from './_Moodle.svelte';
import Searxng from './_Searxng.svelte';
const { id } = $page.params; const { id } = $page.params;
$: isDisabled = $: isDisabled =
@@ -402,6 +403,8 @@
<Moodle bind:service {readOnly} /> <Moodle bind:service {readOnly} />
{:else if service.type === 'glitchTip'} {:else if service.type === 'glitchTip'}
<GlitchTip bind:service /> <GlitchTip bind:service />
{:else if service.type === 'searxng'}
<Searxng bind:service />
{/if} {/if}
</div> </div>
</form> </form>

View File

@@ -62,7 +62,7 @@
</button> </button>
</div> </div>
<div class="flex-col justify-center"> <div class="flex-col justify-center mt-10 pb-12 sm:pb-16">
{#if !services || ownServices.length === 0} {#if !services || ownServices.length === 0}
<div class="flex-col"> <div class="flex-col">
<div class="text-center text-xl font-bold">{$t('service.no_service')}</div> <div class="text-center text-xl font-bold">{$t('service.no_service')}</div>

View File

@@ -56,7 +56,7 @@
</a> </a>
{/if} {/if}
</div> </div>
<div class="flex-col justify-center"> <div class="flex-col justify-center mt-10 pb-12 sm:pb-16">
{#if !sources || ownSources.length === 0} {#if !sources || ownSources.length === 0}
<div class="flex-col"> <div class="flex-col">
<div class="text-center text-xl font-bold">{$t('source.no_git_sources_found')}</div> <div class="text-center text-xl font-bold">{$t('source.no_git_sources_found')}</div>

View File

@@ -62,5 +62,5 @@ module.exports = {
scrollbar: ['dark'], scrollbar: ['dark'],
extend: {} extend: {}
}, },
plugins: [require('tailwindcss-scrollbar'), require('daisyui')] plugins: [require('tailwindcss-scrollbar'), require('daisyui'), require("@tailwindcss/typography")]
}; };

View File

@@ -1,7 +1,7 @@
{ {
"name": "coolify", "name": "coolify",
"description": "An open-source & self-hostable Heroku / Netlify alternative.", "description": "An open-source & self-hostable Heroku / Netlify alternative.",
"version": "3.7.0", "version": "3.8.3",
"license": "Apache-2.0", "license": "Apache-2.0",
"repository": "github:coollabsio/coolify", "repository": "github:coollabsio/coolify",
"scripts": { "scripts": {

553
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff