Merge github.com:coollabsio/coolify into exposePort

This commit is contained in:
Aaron Styles
2022-05-03 16:14:58 +10:00
83 changed files with 2833 additions and 400 deletions

View File

@@ -12,6 +12,7 @@ import type {
Application,
ApplicationPersistentStorage
} from '@prisma/client';
import { setDefaultBaseImage } from '$lib/buildPacks/common';
export async function listApplications(teamId: string): Promise<Application[]> {
if (teamId === '0') {
@@ -195,8 +196,18 @@ export async function getApplication({ id, teamId }: { id: string; teamId: strin
return s;
});
}
const { baseImage, baseBuildImage, baseBuildImages, baseImages } = setDefaultBaseImage(
body.buildPack
);
return { ...body };
// Set default build images
if (!body.baseImage) {
body.baseImage = baseImage;
}
if (!body.baseBuildImage) {
body.baseBuildImage = baseBuildImage;
}
return { ...body, baseBuildImages, baseImages };
}
export async function configureGitRepository({
@@ -267,7 +278,9 @@ export async function configureApplication({
pythonVariable,
dockerFileLocation,
denoMainFile,
denoOptions
denoOptions,
baseImage,
baseBuildImage
}: {
id: string;
buildPack: string;
@@ -286,6 +299,8 @@ export async function configureApplication({
dockerFileLocation: string;
denoMainFile: string;
denoOptions: string;
baseImage: string;
baseBuildImage: string;
}): Promise<Application> {
return await prisma.application.update({
where: { id },
@@ -305,7 +320,9 @@ export async function configureApplication({
pythonVariable,
dockerFileLocation,
denoMainFile,
denoOptions
denoOptions,
baseImage,
baseBuildImage
}
});
}

View File

@@ -11,11 +11,12 @@ import generator from 'generate-password';
import forge from 'node-forge';
import getPort, { portNumbers } from 'get-port';
export function generatePassword(length = 24): string {
export function generatePassword(length = 24, symbols = false): string {
return generator.generate({
length,
numbers: true,
strict: true
strict: true,
symbols
});
}

View File

@@ -14,7 +14,9 @@ const include: Prisma.ServiceInclude = {
wordpress: true,
ghost: true,
meiliSearch: true,
umami: true
umami: true,
hasura: true,
fider: true
};
export async function listServicesWithIncludes() {
return await prisma.service.findMany({
@@ -97,6 +99,17 @@ export async function getService({ id, teamId }: { id: string; teamId: string })
body.umami.umamiAdminPassword = decrypt(body.umami.umamiAdminPassword);
if (body.umami?.hashSalt) body.umami.hashSalt = decrypt(body.umami.hashSalt);
if (body.hasura?.postgresqlPassword)
body.hasura.postgresqlPassword = decrypt(body.hasura.postgresqlPassword);
if (body.hasura?.graphQLAdminPassword)
body.hasura.graphQLAdminPassword = decrypt(body.hasura.graphQLAdminPassword);
if (body.fider?.postgresqlPassword)
body.fider.postgresqlPassword = decrypt(body.fider.postgresqlPassword);
if (body.fider?.jwtSecret) body.fider.jwtSecret = decrypt(body.fider.jwtSecret);
if (body.fider?.emailSmtpPassword)
body.fider.emailSmtpPassword = decrypt(body.fider.emailSmtpPassword);
const settings = await prisma.setting.findFirst();
return { ...body, settings };
@@ -243,6 +256,44 @@ export async function configureServiceType({
}
}
});
} else if (type === 'hasura') {
const postgresqlUser = cuid();
const postgresqlPassword = encrypt(generatePassword());
const postgresqlDatabase = 'hasura';
const graphQLAdminPassword = encrypt(generatePassword());
await prisma.service.update({
where: { id },
data: {
type,
hasura: {
create: {
postgresqlDatabase,
postgresqlPassword,
postgresqlUser,
graphQLAdminPassword
}
}
}
});
} else if (type === 'fider') {
const postgresqlUser = cuid();
const postgresqlPassword = encrypt(generatePassword());
const postgresqlDatabase = 'fider';
const jwtSecret = encrypt(generatePassword(64, true));
await prisma.service.update({
where: { id },
data: {
type,
fider: {
create: {
postgresqlDatabase,
postgresqlPassword,
postgresqlUser,
jwtSecret
}
}
}
});
}
}
@@ -305,60 +356,56 @@ export async function updateService({
return await prisma.service.update({ where: { id }, data: { fqdn, name, exposePort } });
}
export async function updateLanguageToolService({
export async function updateFiderService({
id,
fqdn,
name,
exposePort,
name
emailNoreply,
emailMailgunApiKey,
emailMailgunDomain,
emailMailgunRegion,
emailSmtpHost,
emailSmtpPort,
emailSmtpUser,
emailSmtpPassword,
emailSmtpEnableStartTls
}: {
id: string;
fqdn: string;
exposePort?: number;
name: string;
emailNoreply: string;
emailMailgunApiKey: string;
emailMailgunDomain: string;
emailMailgunRegion: string;
emailSmtpHost: string;
emailSmtpPort: number;
emailSmtpUser: string;
emailSmtpPassword: string;
emailSmtpEnableStartTls: boolean;
}): Promise<Service> {
return await prisma.service.update({ where: { id }, data: { fqdn, name, exposePort } });
}
export async function updateMeiliSearchService({
id,
fqdn,
exposePort,
name
}: {
id: string;
fqdn: string;
exposePort?: number;
name: string;
}): Promise<Service> {
return await prisma.service.update({ where: { id }, data: { fqdn, name, exposePort } });
}
export async function updateVaultWardenService({
id,
fqdn,
exposePort,
name
}: {
id: string;
fqdn: string;
exposePort?: number;
name: string;
}): Promise<Service> {
return await prisma.service.update({ where: { id }, data: { fqdn, name, exposePort } });
}
export async function updateVsCodeServer({
id,
fqdn,
exposePort,
name
}: {
id: string;
fqdn: string;
exposePort?: number;
name: string;
}): Promise<Service> {
return await prisma.service.update({ where: { id }, data: { fqdn, name, exposePort } });
return await prisma.service.update({
where: { id },
data: {
fqdn,
name,
exposePort,
fider: {
update: {
emailNoreply,
emailMailgunApiKey,
emailMailgunDomain,
emailMailgunRegion,
emailSmtpHost,
emailSmtpPort,
emailSmtpUser,
emailSmtpPassword,
emailSmtpEnableStartTls
}
}
}
});
}
export async function updateWordpress({
@@ -414,8 +461,10 @@ export async function updateGhostService({
export async function removeService({ id }: { id: string }): Promise<void> {
await prisma.servicePersistentStorage.deleteMany({ where: { serviceId: id } });
await prisma.meiliSearch.deleteMany({ where: { serviceId: id } });
await prisma.fider.deleteMany({ where: { serviceId: id } });
await prisma.ghost.deleteMany({ where: { serviceId: id } });
await prisma.umami.deleteMany({ where: { serviceId: id } });
await prisma.hasura.deleteMany({ where: { serviceId: id } });
await prisma.plausibleAnalytics.deleteMany({ where: { serviceId: id } });
await prisma.minio.deleteMany({ where: { serviceId: id } });
await prisma.vscodeserver.deleteMany({ where: { serviceId: id } });