From 22e937c798034f0dd2abd85bbbd3bc1872284086 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 29 Sep 2022 14:32:35 +0200 Subject: [PATCH 01/23] fix: do not start tcp proxy without main container --- apps/api/src/jobs/infrastructure.ts | 6 +++--- apps/api/src/lib/common.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/api/src/jobs/infrastructure.ts b/apps/api/src/jobs/infrastructure.ts index e0b2d3a61..d14a118ba 100644 --- a/apps/api/src/jobs/infrastructure.ts +++ b/apps/api/src/jobs/infrastructure.ts @@ -146,7 +146,7 @@ async function checkProxies() { const { destinationDockerId, destinationDocker, publicPort, id } = database; if (destinationDockerId && destinationDocker.isCoolifyProxyUsed) { const { privatePort } = generateDatabaseConfiguration(database, arch); - portReachable = await isReachable(publicPort, { host: destinationDocker.remoteIpAddress || ipv4 || ipv6 }) + portReachable = await isReachable(publicPort, { host: isDev ? 'localhost' : destinationDocker.remoteIpAddress || ipv4 || ipv6 }) if (!portReachable) { await startTraefikTCPProxy(destinationDocker, id, publicPort, privatePort); } @@ -160,7 +160,7 @@ async function checkProxies() { const { service, ftpPublicPort } = ftp; const { destinationDockerId, destinationDocker, id } = service; if (destinationDockerId && destinationDocker.isCoolifyProxyUsed) { - portReachable = await isReachable(ftpPublicPort, { host: destinationDocker.remoteIpAddress || ipv4 || ipv6 }) + portReachable = await isReachable(ftpPublicPort, { host: isDev ? 'localhost' : destinationDocker.remoteIpAddress || ipv4 || ipv6 }) if (!portReachable) { await startTraefikTCPProxy(destinationDocker, id, ftpPublicPort, 22, 'wordpressftp'); } @@ -176,7 +176,7 @@ async function checkProxies() { const { service, publicPort } = minio; const { destinationDockerId, destinationDocker, id } = service; if (destinationDockerId && destinationDocker.isCoolifyProxyUsed) { - portReachable = await isReachable(publicPort, { host: destinationDocker.remoteIpAddress || ipv4 || ipv6 }) + portReachable = await isReachable(publicPort, { host: isDev ? 'localhost' : destinationDocker.remoteIpAddress || ipv4 || ipv6 }) if (!portReachable) { await startTraefikTCPProxy(destinationDocker, id, publicPort, 9000); } diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.ts index e8d12c97e..ce38724f3 100644 --- a/apps/api/src/lib/common.ts +++ b/apps/api/src/lib/common.ts @@ -1365,7 +1365,7 @@ export async function startTraefikTCPProxy( let dependentId = id; if (type === 'wordpressftp') dependentId = `${id}-ftp`; - const foundDependentContainer = await checkContainer({ + const { found: foundDependentContainer } = await checkContainer({ dockerId, container: dependentId, remove: true From 6dbf53b5588e32f58fb8bde64a947feadfb73f91 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 29 Sep 2022 14:32:55 +0200 Subject: [PATCH 02/23] chore: version++ --- apps/api/src/lib/common.ts | 3 +-- package.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.ts index ce38724f3..a2889ae31 100644 --- a/apps/api/src/lib/common.ts +++ b/apps/api/src/lib/common.ts @@ -9,7 +9,6 @@ import generator from 'generate-password'; import crypto from 'crypto'; import { promises as dns } from 'dns'; import { PrismaClient } from '@prisma/client'; -import cuid from 'cuid'; import os from 'os'; import sshConfig from 'ssh-config'; @@ -21,7 +20,7 @@ import { scheduler } from './scheduler'; import { supportedServiceTypesAndVersions } from './services/supportedVersions'; import { includeServices } from './services/common'; -export const version = '3.10.12'; +export const version = '3.10.13'; export const isDev = process.env.NODE_ENV === 'development'; const algorithm = 'aes-256-ctr'; diff --git a/package.json b/package.json index 8c4799c7d..741d79460 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "coolify", "description": "An open-source & self-hostable Heroku / Netlify alternative.", - "version": "3.10.12", + "version": "3.10.13", "license": "Apache-2.0", "repository": "github:coollabsio/coolify", "scripts": { From 3f76cadea9b988f96d58f47cdda3c0703da5b38a Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 29 Sep 2022 14:44:20 +0200 Subject: [PATCH 03/23] fix: cleanup stucked tcp proxies --- apps/api/src/jobs/infrastructure.ts | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/apps/api/src/jobs/infrastructure.ts b/apps/api/src/jobs/infrastructure.ts index d14a118ba..2bd9c329d 100644 --- a/apps/api/src/jobs/infrastructure.ts +++ b/apps/api/src/jobs/infrastructure.ts @@ -146,10 +146,7 @@ async function checkProxies() { const { destinationDockerId, destinationDocker, publicPort, id } = database; if (destinationDockerId && destinationDocker.isCoolifyProxyUsed) { const { privatePort } = generateDatabaseConfiguration(database, arch); - portReachable = await isReachable(publicPort, { host: isDev ? 'localhost' : destinationDocker.remoteIpAddress || ipv4 || ipv6 }) - if (!portReachable) { - await startTraefikTCPProxy(destinationDocker, id, publicPort, privatePort); - } + await startTraefikTCPProxy(destinationDocker, id, publicPort, privatePort); } } const wordpressWithFtp = await prisma.wordpress.findMany({ @@ -160,10 +157,7 @@ async function checkProxies() { const { service, ftpPublicPort } = ftp; const { destinationDockerId, destinationDocker, id } = service; if (destinationDockerId && destinationDocker.isCoolifyProxyUsed) { - portReachable = await isReachable(ftpPublicPort, { host: isDev ? 'localhost' : destinationDocker.remoteIpAddress || ipv4 || ipv6 }) - if (!portReachable) { - await startTraefikTCPProxy(destinationDocker, id, ftpPublicPort, 22, 'wordpressftp'); - } + await startTraefikTCPProxy(destinationDocker, id, ftpPublicPort, 22, 'wordpressftp'); } } @@ -176,10 +170,7 @@ async function checkProxies() { const { service, publicPort } = minio; const { destinationDockerId, destinationDocker, id } = service; if (destinationDockerId && destinationDocker.isCoolifyProxyUsed) { - portReachable = await isReachable(publicPort, { host: isDev ? 'localhost' : destinationDocker.remoteIpAddress || ipv4 || ipv6 }) - if (!portReachable) { - await startTraefikTCPProxy(destinationDocker, id, publicPort, 9000); - } + await startTraefikTCPProxy(destinationDocker, id, publicPort, 9000); } } } catch (error) { From 51b3293e694283b27646911fd78e4f59d793052e Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 29 Sep 2022 15:46:52 +0200 Subject: [PATCH 04/23] ui: inprogress version of iam --- apps/api/src/routes/api/v1/handlers.ts | 2 + apps/ui/src/lib/store.ts | 4 +- apps/ui/src/routes/__layout.svelte | 20 ++++-- apps/ui/src/routes/iam/_Menu.svelte | 70 +++++++++++++++++++ apps/ui/src/routes/iam/__layout.svelte | 28 ++++++++ apps/ui/src/routes/iam/index.svelte | 97 ++++++++++++++++++++------ apps/ui/src/routes/iam/pending.svelte | 51 ++++++++++++++ 7 files changed, 246 insertions(+), 26 deletions(-) create mode 100644 apps/ui/src/routes/iam/_Menu.svelte create mode 100644 apps/ui/src/routes/iam/__layout.svelte create mode 100644 apps/ui/src/routes/iam/pending.svelte diff --git a/apps/api/src/routes/api/v1/handlers.ts b/apps/api/src/routes/api/v1/handlers.ts index c57766ed6..d16d3ed24 100644 --- a/apps/api/src/routes/api/v1/handlers.ts +++ b/apps/api/src/routes/api/v1/handlers.ts @@ -353,8 +353,10 @@ export async function getCurrentUser( // No new token -> not switching teams } } + const pendingInvitations = await prisma.teamInvitation.findMany({ where: { uid: request.user.userId } }) return { settings: await prisma.setting.findFirst(), + pendingInvitations, supportedServiceTypesAndVersions, token, ...request.user, diff --git a/apps/ui/src/lib/store.ts b/apps/ui/src/lib/store.ts index 4e8244e29..aa3493ca5 100644 --- a/apps/ui/src/lib/store.ts +++ b/apps/ui/src/lib/store.ts @@ -20,6 +20,7 @@ interface AppSession { gitlab: string | null, }, supportedServiceTypesAndVersions: Array + pendingInvitations: Array } interface AddToast { type?: "info" | "success" | "error", @@ -47,7 +48,8 @@ export const appSession: Writable = writable({ github: null, gitlab: null }, - supportedServiceTypesAndVersions: [] + supportedServiceTypesAndVersions: [], + pendingInvitations: [] }); export const disabledButton: Writable = writable(false); export const isDeploymentEnabled: Writable = writable(false); diff --git a/apps/ui/src/routes/__layout.svelte b/apps/ui/src/routes/__layout.svelte index be3a49550..ac7edee82 100644 --- a/apps/ui/src/routes/__layout.svelte +++ b/apps/ui/src/routes/__layout.svelte @@ -66,6 +66,8 @@ + + diff --git a/apps/ui/src/routes/iam/__layout.svelte b/apps/ui/src/routes/iam/__layout.svelte new file mode 100644 index 000000000..5b7d16bd3 --- /dev/null +++ b/apps/ui/src/routes/iam/__layout.svelte @@ -0,0 +1,28 @@ + + +
+ +
+
+ +
+ +
+
diff --git a/apps/ui/src/routes/iam/index.svelte b/apps/ui/src/routes/iam/index.svelte index 9b140b130..ba1d9b7e9 100644 --- a/apps/ui/src/routes/iam/index.svelte +++ b/apps/ui/src/routes/iam/index.svelte @@ -29,9 +29,11 @@ import { addToast, appSession } from '$lib/store'; import { goto } from '$app/navigation'; import Cookies from 'js-cookie'; - if (accounts.length === 0) { - accounts.push(account); - } + let search = ''; + let searchResults: any = []; + // if (accounts.length === 0) { + // accounts.push(account); + // } async function resetPassword(id: any) { const sure = window.confirm('Are you sure you want to reset the password?'); @@ -65,22 +67,6 @@ return errorNotification(error); } } - async function acceptInvitation(id: any, teamId: any) { - try { - await post(`/iam/team/${teamId}/invitation/accept`, { id }); - return window.location.reload(); - } catch (error) { - return errorNotification(error); - } - } - async function revokeInvitation(id: any, teamId: any) { - try { - await post(`/iam/team/${teamId}/invitation/revoke`, { id }); - return window.location.reload(); - } catch (error) { - return errorNotification(error); - } - } async function switchTeam(selectedTeamId: any) { try { @@ -104,9 +90,78 @@ const { id } = await post('/iam/new', {}); return await goto(`/iam/team/${id}`, { replaceState: true }); } + function searchAccount() { + searchResults = accounts.filter((account: { email: string | string[] }) => { + return account.email.includes(search); + }); + } -