From a5f1b4b6756f857ad198c52c9b3cb6d177dee61b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sat, 9 Apr 2022 13:25:46 +0200 Subject: [PATCH 01/10] fix: Enable https for Ghost --- src/lib/database/services.ts | 2 +- src/routes/services/[id]/ghost/start.json.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/database/services.ts b/src/lib/database/services.ts index b4d355946..0aec569b6 100644 --- a/src/lib/database/services.ts +++ b/src/lib/database/services.ts @@ -165,7 +165,7 @@ export async function configureServiceType({ id, type }) { } }); } else if (type === 'ghost') { - const defaultEmail = `${cuid()}@coolify.io`; + const defaultEmail = `${cuid()}@example.com`; const defaultPassword = encrypt(generatePassword()); const mariadbUser = cuid(); const mariadbPassword = encrypt(generatePassword()); diff --git a/src/routes/services/[id]/ghost/start.json.ts b/src/routes/services/[id]/ghost/start.json.ts index 9e0b4ba11..41c5e95d4 100644 --- a/src/routes/services/[id]/ghost/start.json.ts +++ b/src/routes/services/[id]/ghost/start.json.ts @@ -44,12 +44,15 @@ export const post: RequestHandler = async (event) => { const { workdir } = await createDirectories({ repository: type, buildId: id }); const image = getServiceImage(type); const domain = getDomain(fqdn); + const isHttps = fqdn.startsWith('https://'); const config = { ghost: { image: `${image}:${version}`, volume: `${id}-ghost:/bitnami/ghost`, environmentVariables: { + url: fqdn, GHOST_HOST: domain, + GHOST_ENABLE_HTTPS: isHttps ? 'yes' : 'no', GHOST_EMAIL: defaultEmail, GHOST_PASSWORD: defaultPassword, GHOST_DATABASE_HOST: `${id}-mariadb`, From e92775887daa907cf018d7600cdb057787f1604d Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sat, 9 Apr 2022 13:26:00 +0200 Subject: [PATCH 02/10] fix: Postgres root passwor shown and set --- src/lib/database/common.ts | 1 + .../databases/[id]/_Databases/_PostgreSQL.svelte | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/lib/database/common.ts b/src/lib/database/common.ts index 287dcd834..9d588fcc4 100644 --- a/src/lib/database/common.ts +++ b/src/lib/database/common.ts @@ -159,6 +159,7 @@ export function generateDatabaseConfiguration(database) { // url: `psql://${dbUser}:${dbUserPassword}@${id}:${isPublic ? port : 5432}/${defaultDatabase}`, privatePort: 5432, environmentVariables: { + POSTGRESQL_POSTGRES_PASSWORD: rootUserPassword, POSTGRESQL_PASSWORD: dbUserPassword, POSTGRESQL_USERNAME: dbUser, POSTGRESQL_DATABASE: defaultDatabase diff --git a/src/routes/databases/[id]/_Databases/_PostgreSQL.svelte b/src/routes/databases/[id]/_Databases/_PostgreSQL.svelte index d59f6bbbc..72b01bcea 100644 --- a/src/routes/databases/[id]/_Databases/_PostgreSQL.svelte +++ b/src/routes/databases/[id]/_Databases/_PostgreSQL.svelte @@ -21,6 +21,19 @@ bind:value={database.defaultDatabase} /> +
+ + +
Date: Sat, 9 Apr 2022 13:26:08 +0200 Subject: [PATCH 03/10] chore: version++ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ac2396dab..5bfd9fa40 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "coolify", "description": "An open-source & self-hostable Heroku / Netlify alternative.", - "version": "2.4.0", + "version": "2.4.1", "license": "AGPL-3.0", "scripts": { "dev": "docker-compose -f docker-compose-dev.yaml up -d && cross-env NODE_ENV=development & svelte-kit dev", From d2f5a58f3bcb97acb34803d63fd4e750de57f81f Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sat, 9 Apr 2022 13:33:23 +0200 Subject: [PATCH 04/10] fix: Able to change postgres user password from ui --- src/lib/database/databases.ts | 14 ++++++++++---- .../databases/[id]/_Databases/_PostgreSQL.svelte | 6 +++--- src/routes/databases/[id]/index.json.ts | 4 ++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/lib/database/databases.ts b/src/lib/database/databases.ts index 2179b5479..9132fc2b2 100644 --- a/src/lib/database/databases.ts +++ b/src/lib/database/databases.ts @@ -138,7 +138,7 @@ export async function stopDatabase(database) { return everStarted; } -export async function updatePasswordInDb(database, user, newPassword) { +export async function updatePasswordInDb(database, user, newPassword, isRoot) { const { id, type, @@ -157,9 +157,15 @@ export async function updatePasswordInDb(database, user, newPassword) { `DOCKER_HOST=${host} docker exec ${id} mysql -u ${rootUser} -p${rootUserPassword} -e \"ALTER USER '${user}'@'%' IDENTIFIED WITH caching_sha2_password BY '${newPassword}';\"` ); } else if (type === 'postgresql') { - await asyncExecShell( - `DOCKER_HOST=${host} docker exec ${id} psql postgresql://${dbUser}:${dbUserPassword}@${id}:5432/${defaultDatabase} -c "ALTER role ${user} WITH PASSWORD '${newPassword}'"` - ); + if (isRoot) { + await asyncExecShell( + `DOCKER_HOST=${host} docker exec ${id} psql postgresql://postgres:${rootUserPassword}@${id}:5432/${defaultDatabase} -c "ALTER role postgres WITH PASSWORD '${newPassword}'"` + ); + } else { + await asyncExecShell( + `DOCKER_HOST=${host} docker exec ${id} psql postgresql://${dbUser}:${dbUserPassword}@${id}:5432/${defaultDatabase} -c "ALTER role ${user} WITH PASSWORD '${newPassword}'"` + ); + } } else if (type === 'mongodb') { await asyncExecShell( `DOCKER_HOST=${host} docker exec ${id} mongo 'mongodb://${rootUser}:${rootUserPassword}@${id}:27017/admin?readPreference=primary&ssl=false' --eval "db.changeUserPassword('${user}','${newPassword}')"` diff --git a/src/routes/databases/[id]/_Databases/_PostgreSQL.svelte b/src/routes/databases/[id]/_Databases/_PostgreSQL.svelte index 72b01bcea..343ad74d6 100644 --- a/src/routes/databases/[id]/_Databases/_PostgreSQL.svelte +++ b/src/routes/databases/[id]/_Databases/_PostgreSQL.svelte @@ -26,12 +26,12 @@ >Root (postgres) User Password
diff --git a/src/routes/databases/[id]/index.json.ts b/src/routes/databases/[id]/index.json.ts index cdfb33d21..830deee10 100644 --- a/src/routes/databases/[id]/index.json.ts +++ b/src/routes/databases/[id]/index.json.ts @@ -68,9 +68,9 @@ export const post: RequestHandler = async (event) => { const database = await db.getDatabase({ id, teamId }); if (isRunning) { if (database.dbUserPassword !== dbUserPassword) { - await updatePasswordInDb(database, dbUser, dbUserPassword); + await updatePasswordInDb(database, dbUser, dbUserPassword, false); } else if (database.rootUserPassword !== rootUserPassword) { - await updatePasswordInDb(database, rootUser, rootUserPassword); + await updatePasswordInDb(database, rootUser, rootUserPassword, true); } } await db.updateDatabase({ From 7ec296be6b31982b5dbec3b8bf49c4091e66233c Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sat, 9 Apr 2022 13:58:13 +0200 Subject: [PATCH 05/10] fix: DB Connecting string generator --- src/routes/databases/[id]/_Databases/_Databases.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/databases/[id]/_Databases/_Databases.svelte b/src/routes/databases/[id]/_Databases/_Databases.svelte index 731dcd80e..c441534e4 100644 --- a/src/routes/databases/[id]/_Databases/_Databases.svelte +++ b/src/routes/databases/[id]/_Databases/_Databases.svelte @@ -49,7 +49,7 @@ $: databaseUrl = generateUrl(); function generateUrl() { - return browser + return (databaseUrl = browser ? `${database.type}://${ databaseDbUser ? databaseDbUser + ':' : '' }${databaseDbUserPassword}@${ @@ -59,7 +59,7 @@ : window.location.hostname : database.id }:${isPublic ? database.publicPort : privatePort}/${databaseDefault}` - : 'Loading...'; + : 'Loading...'); } async function changeSettings(name) { @@ -200,7 +200,7 @@ name="url" readonly disabled - value={publicLoading || loading ? 'Loading...' : databaseUrl} + value={publicLoading || loading ? 'Loading...' : generateUrl()} />
From 7953c1df30ae00e717df59ca38c74050d2f531f3 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 10 Apr 2022 00:30:47 +0200 Subject: [PATCH 06/10] fix: Missing install repositories GitHub --- src/routes/sources/[id]/_Github.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/sources/[id]/_Github.svelte b/src/routes/sources/[id]/_Github.svelte index 6b8aa0c89..a01746267 100644 --- a/src/routes/sources/[id]/_Github.svelte +++ b/src/routes/sources/[id]/_Github.svelte @@ -104,7 +104,7 @@ {/if} - {:else if source.githubAppId} + {:else if source.githubApp?.installationId}
General
From bb0c93dc2fe57b42c6d50564145ad7dcd602254b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 10 Apr 2022 00:31:10 +0200 Subject: [PATCH 07/10] fix: Return own and other sources better --- src/routes/applications/[id]/configuration/source.svelte | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/routes/applications/[id]/configuration/source.svelte b/src/routes/applications/[id]/configuration/source.svelte index e5c05ebdd..2f23de4d8 100644 --- a/src/routes/applications/[id]/configuration/source.svelte +++ b/src/routes/applications/[id]/configuration/source.svelte @@ -46,15 +46,12 @@ (source.type === 'github' && source.githubAppId && source.githubApp.installationId) || (source.type === 'gitlab' && source.gitlabAppId) ); + console.log(filteredSources); const ownSources = filteredSources.filter((source) => { - if (source.teams[0].id === $session.teamId) { - return source; - } + return source.teams.filter((team) => team.id === $session.teamId); }); const otherSources = filteredSources.filter((source) => { - if (source.teams[0].id !== $session.teamId) { - return source; - } + return source.teams.filter((team) => team.id !== $session.teamId); }); async function handleSubmit(gitSourceId) { From 41c5dd3b53dc7e6a2158727a3179c151e4c4fa44 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 10 Apr 2022 00:36:42 +0200 Subject: [PATCH 08/10] fix: Show config missing on sources --- src/routes/sources/index.svelte | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/routes/sources/index.svelte b/src/routes/sources/index.svelte index 1e2d4d510..191eb8857 100644 --- a/src/routes/sources/index.svelte +++ b/src/routes/sources/index.svelte @@ -82,7 +82,8 @@ {#if $session.teamId === '0' && otherSources.length > 0}
{source.teams[0].name}
{/if} - {#if (source.type === 'gitlab' && !source.gitlabAppId) || (source.type === 'github' && !source.githubAppId && !source.githubApp?.installationId)} + + {#if (source.type === 'gitlab' && !source.gitlabAppId) || (source.type === 'github' && source.githubApp?.installationId === null)}
Configuration missing
@@ -109,7 +110,7 @@ {#if $session.teamId === '0'}
{source.teams[0].name}
{/if} - {#if (source.type === 'gitlab' && !source.gitlabAppId) || (source.type === 'github' && !source.githubAppId && !source.githubApp?.installationId)} + {#if (source.type === 'gitlab' && !source.gitlabAppId) || (source.type === 'github' && source.githubApp?.installationId === null)}
Configuration missing
From 73c9cb1d51db851b4d368d1eab46363185460e9c Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 10 Apr 2022 00:39:50 +0200 Subject: [PATCH 09/10] Revert source configuration changes --- src/routes/applications/[id]/configuration/source.svelte | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/routes/applications/[id]/configuration/source.svelte b/src/routes/applications/[id]/configuration/source.svelte index 2f23de4d8..e5c05ebdd 100644 --- a/src/routes/applications/[id]/configuration/source.svelte +++ b/src/routes/applications/[id]/configuration/source.svelte @@ -46,12 +46,15 @@ (source.type === 'github' && source.githubAppId && source.githubApp.installationId) || (source.type === 'gitlab' && source.gitlabAppId) ); - console.log(filteredSources); const ownSources = filteredSources.filter((source) => { - return source.teams.filter((team) => team.id === $session.teamId); + if (source.teams[0].id === $session.teamId) { + return source; + } }); const otherSources = filteredSources.filter((source) => { - return source.teams.filter((team) => team.id !== $session.teamId); + if (source.teams[0].id !== $session.teamId) { + return source; + } }); async function handleSubmit(gitSourceId) { From b2e7435d0f6e3b9aad6189199c0b0a2d2175cd72 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 10 Apr 2022 00:40:12 +0200 Subject: [PATCH 10/10] chore: version++ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5bfd9fa40..a272908c7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "coolify", "description": "An open-source & self-hostable Heroku / Netlify alternative.", - "version": "2.4.1", + "version": "2.4.2", "license": "AGPL-3.0", "scripts": { "dev": "docker-compose -f docker-compose-dev.yaml up -d && cross-env NODE_ENV=development & svelte-kit dev",