Merge branch 'main' into exposePort

This commit is contained in:
Aaron Charcoal Styles 2022-04-11 09:49:07 +00:00 committed by GitHub
commit 27f1e1d7cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 38 additions and 14 deletions

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": "2.4.0", "version": "2.4.2",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"scripts": { "scripts": {
"dev": "docker-compose -f docker-compose-dev.yaml up -d && cross-env NODE_ENV=development & svelte-kit dev", "dev": "docker-compose -f docker-compose-dev.yaml up -d && cross-env NODE_ENV=development & svelte-kit dev",

View File

@ -159,6 +159,7 @@ export function generateDatabaseConfiguration(database) {
// url: `psql://${dbUser}:${dbUserPassword}@${id}:${isPublic ? port : 5432}/${defaultDatabase}`, // url: `psql://${dbUser}:${dbUserPassword}@${id}:${isPublic ? port : 5432}/${defaultDatabase}`,
privatePort: 5432, privatePort: 5432,
environmentVariables: { environmentVariables: {
POSTGRESQL_POSTGRES_PASSWORD: rootUserPassword,
POSTGRESQL_PASSWORD: dbUserPassword, POSTGRESQL_PASSWORD: dbUserPassword,
POSTGRESQL_USERNAME: dbUser, POSTGRESQL_USERNAME: dbUser,
POSTGRESQL_DATABASE: defaultDatabase POSTGRESQL_DATABASE: defaultDatabase

View File

@ -138,7 +138,7 @@ export async function stopDatabase(database) {
return everStarted; return everStarted;
} }
export async function updatePasswordInDb(database, user, newPassword) { export async function updatePasswordInDb(database, user, newPassword, isRoot) {
const { const {
id, id,
type, 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}';\"` `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') { } else if (type === 'postgresql') {
await asyncExecShell( if (isRoot) {
`DOCKER_HOST=${host} docker exec ${id} psql postgresql://${dbUser}:${dbUserPassword}@${id}:5432/${defaultDatabase} -c "ALTER role ${user} WITH PASSWORD '${newPassword}'"` 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') { } else if (type === 'mongodb') {
await asyncExecShell( await asyncExecShell(
`DOCKER_HOST=${host} docker exec ${id} mongo 'mongodb://${rootUser}:${rootUserPassword}@${id}:27017/admin?readPreference=primary&ssl=false' --eval "db.changeUserPassword('${user}','${newPassword}')"` `DOCKER_HOST=${host} docker exec ${id} mongo 'mongodb://${rootUser}:${rootUserPassword}@${id}:27017/admin?readPreference=primary&ssl=false' --eval "db.changeUserPassword('${user}','${newPassword}')"`

View File

@ -165,7 +165,7 @@ export async function configureServiceType({ id, type }) {
} }
}); });
} else if (type === 'ghost') { } else if (type === 'ghost') {
const defaultEmail = `${cuid()}@coolify.io`; 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());

View File

@ -49,7 +49,7 @@
$: databaseUrl = generateUrl(); $: databaseUrl = generateUrl();
function generateUrl() { function generateUrl() {
return browser return (databaseUrl = browser
? `${database.type}://${ ? `${database.type}://${
databaseDbUser ? databaseDbUser + ':' : '' databaseDbUser ? databaseDbUser + ':' : ''
}${databaseDbUserPassword}@${ }${databaseDbUserPassword}@${
@ -59,7 +59,7 @@
: window.location.hostname : window.location.hostname
: database.id : database.id
}:${isPublic ? database.publicPort : privatePort}/${databaseDefault}` }:${isPublic ? database.publicPort : privatePort}/${databaseDefault}`
: 'Loading...'; : 'Loading...');
} }
async function changeSettings(name) { async function changeSettings(name) {
@ -200,7 +200,7 @@
name="url" name="url"
readonly readonly
disabled disabled
value={publicLoading || loading ? 'Loading...' : databaseUrl} value={publicLoading || loading ? 'Loading...' : generateUrl()}
/> />
</div> </div>
</div> </div>

View File

@ -21,6 +21,19 @@
bind:value={database.defaultDatabase} bind:value={database.defaultDatabase}
/> />
</div> </div>
<div class="grid grid-cols-2 items-center">
<label for="rootUser" class="text-base font-bold text-stone-100"
>Root (postgres) User Password</label
>
<CopyPasswordField
disabled={!isRunning}
readonly={!isRunning}
placeholder="Generated automatically after start"
id="rootUserPassword"
name="rootUserPassword"
bind:value={database.rootUserPassword}
/>
</div>
<div class="grid grid-cols-2 items-center"> <div class="grid grid-cols-2 items-center">
<label for="dbUser" class="text-base font-bold text-stone-100">User</label> <label for="dbUser" class="text-base font-bold text-stone-100">User</label>
<CopyPasswordField <CopyPasswordField

View File

@ -68,9 +68,9 @@ export const post: RequestHandler = async (event) => {
const database = await db.getDatabase({ id, teamId }); const database = await db.getDatabase({ id, teamId });
if (isRunning) { if (isRunning) {
if (database.dbUserPassword !== dbUserPassword) { if (database.dbUserPassword !== dbUserPassword) {
await updatePasswordInDb(database, dbUser, dbUserPassword); await updatePasswordInDb(database, dbUser, dbUserPassword, false);
} else if (database.rootUserPassword !== rootUserPassword) { } else if (database.rootUserPassword !== rootUserPassword) {
await updatePasswordInDb(database, rootUser, rootUserPassword); await updatePasswordInDb(database, rootUser, rootUserPassword, true);
} }
} }
await db.updateDatabase({ await db.updateDatabase({

View File

@ -44,12 +44,15 @@ export const post: RequestHandler = async (event) => {
const { workdir } = await createDirectories({ repository: type, buildId: id }); const { workdir } = await createDirectories({ repository: type, buildId: id });
const image = getServiceImage(type); const image = getServiceImage(type);
const domain = getDomain(fqdn); const domain = getDomain(fqdn);
const isHttps = fqdn.startsWith('https://');
const config = { const config = {
ghost: { ghost: {
image: `${image}:${version}`, image: `${image}:${version}`,
volume: `${id}-ghost:/bitnami/ghost`, volume: `${id}-ghost:/bitnami/ghost`,
environmentVariables: { environmentVariables: {
url: fqdn,
GHOST_HOST: domain, GHOST_HOST: domain,
GHOST_ENABLE_HTTPS: isHttps ? 'yes' : 'no',
GHOST_EMAIL: defaultEmail, GHOST_EMAIL: defaultEmail,
GHOST_PASSWORD: defaultPassword, GHOST_PASSWORD: defaultPassword,
GHOST_DATABASE_HOST: `${id}-mariadb`, GHOST_DATABASE_HOST: `${id}-mariadb`,

View File

@ -104,7 +104,7 @@
</div> </div>
{/if} {/if}
</form> </form>
{:else if source.githubAppId} {:else if source.githubApp?.installationId}
<form on:submit|preventDefault={handleSubmit} class="py-4"> <form on:submit|preventDefault={handleSubmit} class="py-4">
<div class="flex space-x-1 pb-5 font-bold"> <div class="flex space-x-1 pb-5 font-bold">
<div class="title">General</div> <div class="title">General</div>

View File

@ -82,7 +82,8 @@
{#if $session.teamId === '0' && otherSources.length > 0} {#if $session.teamId === '0' && otherSources.length > 0}
<div class="truncate text-center">{source.teams[0].name}</div> <div class="truncate text-center">{source.teams[0].name}</div>
{/if} {/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)}
<div class="truncate text-center font-bold text-red-500 group-hover:text-white"> <div class="truncate text-center font-bold text-red-500 group-hover:text-white">
Configuration missing Configuration missing
</div> </div>
@ -109,7 +110,7 @@
{#if $session.teamId === '0'} {#if $session.teamId === '0'}
<div class="truncate text-center">{source.teams[0].name}</div> <div class="truncate text-center">{source.teams[0].name}</div>
{/if} {/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)}
<div class="truncate text-center font-bold text-red-500 group-hover:text-white"> <div class="truncate text-center font-bold text-red-500 group-hover:text-white">
Configuration missing Configuration missing
</div> </div>