Merge branch 'next' into feature/glitchtip-service

This commit is contained in:
Andras Bacsai
2022-08-18 21:47:06 +02:00
committed by GitHub
39 changed files with 1031 additions and 612 deletions

2
.gitpod.Dockerfile vendored
View File

@@ -1,2 +1,2 @@
FROM gitpod/workspace-node:2022-06-20-19-54-55 FROM gitpod/workspace-node:2022-06-20-19-54-55
RUN (curl -sSL "https://github.com/buildpacks/pack/releases/download/v0.27.0/pack-v0.27.0-linux.tgz" | tar -C /usr/local/bin/ --no-same-owner -xzv pack) RUN brew install buildpacks/tap/pack

View File

@@ -30,7 +30,8 @@ RUN mkdir -p ~/.docker/cli-plugins/
# https://download.docker.com/linux/static/stable/ # https://download.docker.com/linux/static/stable/
RUN curl -SL https://cdn.coollabs.io/bin/$TARGETPLATFORM/docker-20.10.9 -o /usr/bin/docker RUN curl -SL https://cdn.coollabs.io/bin/$TARGETPLATFORM/docker-20.10.9 -o /usr/bin/docker
# https://github.com/docker/compose/releases # https://github.com/docker/compose/releases
RUN curl -SL https://cdn.coollabs.io/bin/$TARGETPLATFORM/docker-compose-linux-2.7.0 -o ~/.docker/cli-plugins/docker-compose # Reverted to 2.6.1 because of this https://github.com/docker/compose/issues/9704. 2.9.0 still has a bug.
RUN curl -SL https://cdn.coollabs.io/bin/$TARGETPLATFORM/docker-compose-linux-2.6.1 -o ~/.docker/cli-plugins/docker-compose
RUN chmod +x ~/.docker/cli-plugins/docker-compose /usr/bin/docker RUN chmod +x ~/.docker/cli-plugins/docker-compose /usr/bin/docker
RUN (curl -sSL "https://github.com/buildpacks/pack/releases/download/v0.27.0/pack-v0.27.0-linux.tgz" | tar -C /usr/local/bin/ --no-same-owner -xzv pack) RUN (curl -sSL "https://github.com/buildpacks/pack/releases/download/v0.27.0/pack-v0.27.0-linux.tgz" | tar -C /usr/local/bin/ --no-same-owner -xzv pack)

View File

@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Setting" ADD COLUMN "DNSServers" TEXT;

View File

@@ -0,0 +1,42 @@
-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_GitSource" (
"id" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"forPublic" BOOLEAN NOT NULL DEFAULT false,
"type" TEXT,
"apiUrl" TEXT,
"htmlUrl" TEXT,
"customPort" INTEGER NOT NULL DEFAULT 22,
"organization" TEXT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
"githubAppId" TEXT,
"gitlabAppId" TEXT,
CONSTRAINT "GitSource_githubAppId_fkey" FOREIGN KEY ("githubAppId") REFERENCES "GithubApp" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT "GitSource_gitlabAppId_fkey" FOREIGN KEY ("gitlabAppId") REFERENCES "GitlabApp" ("id") ON DELETE SET NULL ON UPDATE CASCADE
);
INSERT INTO "new_GitSource" ("apiUrl", "createdAt", "customPort", "githubAppId", "gitlabAppId", "htmlUrl", "id", "name", "organization", "type", "updatedAt") SELECT "apiUrl", "createdAt", "customPort", "githubAppId", "gitlabAppId", "htmlUrl", "id", "name", "organization", "type", "updatedAt" FROM "GitSource";
DROP TABLE "GitSource";
ALTER TABLE "new_GitSource" RENAME TO "GitSource";
CREATE UNIQUE INDEX "GitSource_githubAppId_key" ON "GitSource"("githubAppId");
CREATE UNIQUE INDEX "GitSource_gitlabAppId_key" ON "GitSource"("gitlabAppId");
CREATE TABLE "new_ApplicationSettings" (
"id" TEXT NOT NULL PRIMARY KEY,
"applicationId" TEXT NOT NULL,
"dualCerts" BOOLEAN NOT NULL DEFAULT false,
"debug" BOOLEAN NOT NULL DEFAULT false,
"previews" BOOLEAN NOT NULL DEFAULT false,
"autodeploy" BOOLEAN NOT NULL DEFAULT true,
"isBot" BOOLEAN NOT NULL DEFAULT false,
"isPublicRepository" BOOLEAN NOT NULL DEFAULT false,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
CONSTRAINT "ApplicationSettings_applicationId_fkey" FOREIGN KEY ("applicationId") REFERENCES "Application" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
INSERT INTO "new_ApplicationSettings" ("applicationId", "autodeploy", "createdAt", "debug", "dualCerts", "id", "isBot", "previews", "updatedAt") SELECT "applicationId", "autodeploy", "createdAt", "debug", "dualCerts", "id", "isBot", "previews", "updatedAt" FROM "ApplicationSettings";
DROP TABLE "ApplicationSettings";
ALTER TABLE "new_ApplicationSettings" RENAME TO "ApplicationSettings";
CREATE UNIQUE INDEX "ApplicationSettings_applicationId_key" ON "ApplicationSettings"("applicationId");
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON;

View File

@@ -20,6 +20,7 @@ model Setting {
proxyHash String? proxyHash String?
isAutoUpdateEnabled Boolean @default(false) isAutoUpdateEnabled Boolean @default(false)
isDNSCheckEnabled Boolean @default(true) isDNSCheckEnabled Boolean @default(true)
DNSServers String?
isTraefikUsed Boolean @default(true) isTraefikUsed Boolean @default(true)
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
@@ -118,16 +119,17 @@ model Application {
} }
model ApplicationSettings { model ApplicationSettings {
id String @id @default(cuid()) id String @id @default(cuid())
applicationId String @unique applicationId String @unique
dualCerts Boolean @default(false) dualCerts Boolean @default(false)
debug Boolean @default(false) debug Boolean @default(false)
previews Boolean @default(false) previews Boolean @default(false)
autodeploy Boolean @default(true) autodeploy Boolean @default(true)
isBot Boolean @default(false) isBot Boolean @default(false)
createdAt DateTime @default(now()) isPublicRepository Boolean @default(false)
updatedAt DateTime @updatedAt createdAt DateTime @default(now())
application Application @relation(fields: [applicationId], references: [id]) updatedAt DateTime @updatedAt
application Application @relation(fields: [applicationId], references: [id])
} }
model ApplicationPersistentStorage { model ApplicationPersistentStorage {
@@ -237,6 +239,7 @@ model SshKey {
model GitSource { model GitSource {
id String @id @default(cuid()) id String @id @default(cuid())
name String name String
forPublic Boolean @default(false)
type String? type String?
apiUrl String? apiUrl String?
htmlUrl String? htmlUrl String?

View File

@@ -66,6 +66,34 @@ async function main() {
} }
}); });
} }
const github = await prisma.gitSource.findFirst({
where: { htmlUrl: 'https://github.com', forPublic: true }
});
const gitlab = await prisma.gitSource.findFirst({
where: { htmlUrl: 'https://gitlab.com', forPublic: true }
});
if (!github) {
await prisma.gitSource.create({
data: {
apiUrl: 'https://api.github.com',
htmlUrl: 'https://github.com',
forPublic: true,
name: 'Github Public',
type: 'github'
}
});
}
if (!gitlab) {
await prisma.gitSource.create({
data: {
apiUrl: 'https://gitlab.com/api/v4',
htmlUrl: 'https://gitlab.com',
forPublic: true,
name: 'Gitlab Public',
type: 'gitlab'
}
});
}
} }
main() main()
.catch((e) => { .catch((e) => {

View File

@@ -5,8 +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 } from './lib/common'; import { asyncExecShell, 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';
declare module 'fastify' { declare module 'fastify' {
interface FastifyInstance { interface FastifyInstance {
@@ -113,8 +115,22 @@ fastify.listen({ port, host }, async (err: any, address: any) => {
setInterval(async () => { setInterval(async () => {
const { isAutoUpdateEnabled } = await prisma.setting.findFirst(); const { isAutoUpdateEnabled } = await prisma.setting.findFirst();
if (isAutoUpdateEnabled) { if (isAutoUpdateEnabled) {
if (scheduler.workers.has('deployApplication')) { const currentVersion = version;
scheduler.workers.get('deployApplication').postMessage("status:autoUpdater"); 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");
}
} }
} }
}, isDev ? 5000 : 60000 * 15) }, isDev ? 5000 : 60000 * 15)

View File

@@ -4,7 +4,7 @@ import fs from 'fs/promises';
import yaml from 'js-yaml'; import yaml from 'js-yaml';
import { copyBaseConfigurationFiles, makeLabelForStandaloneApplication, saveBuildLog, setDefaultConfiguration } from '../lib/buildPacks/common'; import { copyBaseConfigurationFiles, makeLabelForStandaloneApplication, saveBuildLog, setDefaultConfiguration } from '../lib/buildPacks/common';
import { createDirectories, decrypt, executeDockerCmd, getDomain, prisma } from '../lib/common'; import { createDirectories, decrypt, defaultComposeConfiguration, executeDockerCmd, getDomain, prisma } from '../lib/common';
import * as importers from '../lib/importers'; import * as importers from '../lib/importers';
import * as buildpacks from '../lib/buildPacks'; import * as buildpacks from '../lib/buildPacks';
@@ -56,6 +56,7 @@ import * as buildpacks from '../lib/buildPacks';
baseImage, baseImage,
baseBuildImage, baseBuildImage,
deploymentType, deploymentType,
forceRebuild
} = message } = message
let { let {
branch, branch,
@@ -69,6 +70,30 @@ import * as buildpacks from '../lib/buildPacks';
dockerFileLocation, dockerFileLocation,
denoMainFile denoMainFile
} = message } = message
const currentHash = crypto
.createHash('sha256')
.update(
JSON.stringify({
pythonWSGI,
pythonModule,
pythonVariable,
deploymentType,
denoOptions,
baseImage,
baseBuildImage,
buildPack,
port,
exposePort,
installCommand,
buildCommand,
startCommand,
secrets,
branch,
repository,
fqdn
})
)
.digest('hex');
try { try {
const { debug } = settings; const { debug } = settings;
if (concurrency === 1) { if (concurrency === 1) {
@@ -131,7 +156,8 @@ import * as buildpacks from '../lib/buildPacks';
htmlUrl: gitSource.htmlUrl, htmlUrl: gitSource.htmlUrl,
projectId, projectId,
deployKeyId: gitSource.gitlabApp?.deployKeyId || null, deployKeyId: gitSource.gitlabApp?.deployKeyId || null,
privateSshKey: decrypt(gitSource.gitlabApp?.privateSshKey) || null privateSshKey: decrypt(gitSource.gitlabApp?.privateSshKey) || null,
forPublic: gitSource.forPublic
}); });
if (!commit) { if (!commit) {
throw new Error('No commit found?'); throw new Error('No commit found?');
@@ -146,38 +172,10 @@ import * as buildpacks from '../lib/buildPacks';
} catch (err) { } catch (err) {
console.log(err); console.log(err);
} }
if (!pullmergeRequestId) { if (!pullmergeRequestId) {
const currentHash = crypto
//@ts-ignore
.createHash('sha256')
.update(
JSON.stringify({
pythonWSGI,
pythonModule,
pythonVariable,
deploymentType,
denoOptions,
baseImage,
baseBuildImage,
buildPack,
port,
exposePort,
installCommand,
buildCommand,
startCommand,
secrets,
branch,
repository,
fqdn
})
)
.digest('hex');
if (configHash !== currentHash) { if (configHash !== currentHash) {
await prisma.application.update({
where: { id: applicationId },
data: { configHash: currentHash }
});
deployNeeded = true; deployNeeded = true;
if (configHash) { if (configHash) {
await saveBuildLog({ line: 'Configuration changed.', buildId, applicationId }); await saveBuildLog({ line: 'Configuration changed.', buildId, applicationId });
@@ -200,8 +198,10 @@ import * as buildpacks from '../lib/buildPacks';
// //
} }
await copyBaseConfigurationFiles(buildPack, workdir, buildId, applicationId, baseImage); await copyBaseConfigurationFiles(buildPack, workdir, buildId, applicationId, baseImage);
if (forceRebuild) deployNeeded = true
if (!imageFound || deployNeeded) { if (!imageFound || deployNeeded) {
// if (true) { // if (true) {
if (buildpacks[buildPack]) if (buildpacks[buildPack])
await buildpacks[buildPack]({ await buildpacks[buildPack]({
dockerId: destinationDocker.id, dockerId: destinationDocker.id,
@@ -250,16 +250,18 @@ import * as buildpacks from '../lib/buildPacks';
} catch (error) { } catch (error) {
// //
} }
const envs = []; const envs = [
`PORT=${port}`
];
if (secrets.length > 0) { if (secrets.length > 0) {
secrets.forEach((secret) => { secrets.forEach((secret) => {
if (pullmergeRequestId) { if (pullmergeRequestId) {
if (secret.isPRMRSecret) { if (secret.isPRMRSecret) {
envs.push(`${secret.name}='${secret.value}'`); envs.push(`${secret.name}=${secret.value}`);
} }
} else { } else {
if (!secret.isPRMRSecret) { if (!secret.isPRMRSecret) {
envs.push(`${secret.name}='${secret.value}'`); envs.push(`${secret.name}=${secret.value}`);
} }
} }
}); });
@@ -306,23 +308,14 @@ import * as buildpacks from '../lib/buildPacks';
container_name: imageId, container_name: imageId,
volumes, volumes,
env_file: envFound ? [`${workdir}/.env`] : [], env_file: envFound ? [`${workdir}/.env`] : [],
networks: [destinationDocker.network],
labels, labels,
depends_on: [], depends_on: [],
restart: 'always',
expose: [port], expose: [port],
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}), ...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
// logging: { // logging: {
// driver: 'fluentd', // driver: 'fluentd',
// }, // },
deploy: { ...defaultComposeConfiguration(destinationDocker.network),
restart_policy: {
condition: 'on-failure',
delay: '5s',
max_attempts: 3,
window: '120s'
}
}
} }
}, },
networks: { networks: {
@@ -345,6 +338,10 @@ import * as buildpacks from '../lib/buildPacks';
} }
await saveBuildLog({ line: 'Proxy will be updated shortly.', buildId, applicationId }); await saveBuildLog({ line: 'Proxy will be updated shortly.', buildId, applicationId });
await prisma.build.update({ where: { id: message.build_id }, data: { status: 'success' } }); await prisma.build.update({ where: { id: message.build_id }, data: { status: 'success' } });
if (!pullmergeRequestId) await prisma.application.update({
where: { id: applicationId },
data: { configHash: currentHash }
});
} }
} }

View File

@@ -17,7 +17,7 @@ import { checkContainer, removeContainer } from './docker';
import { day } from './dayjs'; import { day } from './dayjs';
import * as serviceFields from './serviceFields' import * as serviceFields from './serviceFields'
export const version = '3.5.0'; export const version = '3.6.0';
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';
@@ -319,6 +319,10 @@ export async function checkDoubleBranch(branch: string, projectId: number): Prom
} }
export async function isDNSValid(hostname: any, domain: string): Promise<any> { export async function isDNSValid(hostname: any, domain: string): Promise<any> {
const { isIP } = await import('is-ip'); const { isIP } = await import('is-ip');
const { DNSServers } = await listSettings();
if (DNSServers) {
dns.setServers([DNSServers]);
}
let resolves = []; let resolves = [];
try { try {
if (isIP(hostname)) { if (isIP(hostname)) {
@@ -332,7 +336,6 @@ export async function isDNSValid(hostname: any, domain: string): Promise<any> {
try { try {
let ipDomainFound = false; let ipDomainFound = false;
dns.setServers(['1.1.1.1', '8.8.8.8']);
const dnsResolve = await dns.resolve4(domain); const dnsResolve = await dns.resolve4(domain);
if (dnsResolve.length > 0) { if (dnsResolve.length > 0) {
for (const ip of dnsResolve) { for (const ip of dnsResolve) {
@@ -424,7 +427,12 @@ export async function checkDomainsIsValidInDNS({ hostname, fqdn, dualCerts }): P
const { isIP } = await import('is-ip'); const { isIP } = await import('is-ip');
const domain = getDomain(fqdn); const domain = getDomain(fqdn);
const domainDualCert = domain.includes('www.') ? domain.replace('www.', '') : `www.${domain}`; const domainDualCert = domain.includes('www.') ? domain.replace('www.', '') : `www.${domain}`;
dns.setServers(['1.1.1.1', '8.8.8.8']);
const { DNSServers } = await listSettings();
if (DNSServers) {
dns.setServers([DNSServers]);
}
let resolves = []; let resolves = [];
try { try {
if (isIP(hostname)) { if (isIP(hostname)) {
@@ -1180,6 +1188,25 @@ export async function updatePasswordInDb(database, user, newPassword, isRoot) {
} }
} }
} }
export async function checkExposedPort({ id, configuredPort, exposePort, dockerId, remoteIpAddress }: { id: string, configuredPort?: number, exposePort: number, dockerId: string, remoteIpAddress?: string }) {
if (exposePort < 1024 || exposePort > 65535) {
throw { status: 500, message: `Exposed Port needs to be between 1024 and 65535.` }
}
if (configuredPort) {
if (configuredPort !== exposePort) {
const availablePort = await getFreeExposedPort(id, exposePort, dockerId, remoteIpAddress);
if (availablePort.toString() !== exposePort.toString()) {
throw { status: 500, message: `Port ${exposePort} is already in use.` }
}
}
} else {
const availablePort = await getFreeExposedPort(id, exposePort, dockerId, remoteIpAddress);
if (availablePort.toString() !== exposePort.toString()) {
throw { status: 500, message: `Port ${exposePort} is already in use.` }
}
}
}
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: getPort } = await import('get-port');
const applicationUsed = await ( const applicationUsed = await (
@@ -1565,7 +1592,7 @@ 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();
@@ -1845,3 +1872,17 @@ export function persistentVolumes(id, persistentStorage, config) {
) || {} ) || {}
return { volumes, volumeMounts } return { volumes, volumeMounts }
} }
export function defaultComposeConfiguration(network: string): any {
return {
networks: [network],
restart: 'on-failure',
deploy: {
restart_policy: {
condition: 'on-failure',
delay: '5s',
max_attempts: 10,
window: '120s'
}
}
}
}

View File

@@ -71,7 +71,6 @@ export async function removeContainer({
}): Promise<void> { }): Promise<void> {
try { try {
const { stdout } = await executeDockerCmd({ dockerId, command: `docker inspect --format '{{json .State}}' ${id}` }) const { stdout } = await executeDockerCmd({ dockerId, command: `docker inspect --format '{{json .State}}' ${id}` })
console.log(id)
if (JSON.parse(stdout).Running) { if (JSON.parse(stdout).Running) {
await executeDockerCmd({ dockerId, command: `docker stop -t 0 ${id}` }) await executeDockerCmd({ dockerId, command: `docker stop -t 0 ${id}` })
await executeDockerCmd({ dockerId, command: `docker rm ${id}` }) await executeDockerCmd({ dockerId, command: `docker rm ${id}` })

View File

@@ -12,7 +12,8 @@ export default async function ({
htmlUrl, htmlUrl,
branch, branch,
buildId, buildId,
customPort customPort,
forPublic
}: { }: {
applicationId: string; applicationId: string;
workdir: string; workdir: string;
@@ -23,41 +24,55 @@ export default async function ({
branch: string; branch: string;
buildId: string; buildId: string;
customPort: number; customPort: number;
forPublic?: boolean;
}): Promise<string> { }): Promise<string> {
const { default: got } = await import('got') const { default: got } = await import('got')
const url = htmlUrl.replace('https://', '').replace('http://', ''); const url = htmlUrl.replace('https://', '').replace('http://', '');
await saveBuildLog({ line: 'GitHub importer started.', buildId, applicationId }); await saveBuildLog({ line: 'GitHub importer started.', buildId, applicationId });
if (forPublic) {
await saveBuildLog({
line: `Cloning ${repository}:${branch} branch.`,
buildId,
applicationId
});
await asyncExecShell(
`git clone -q -b ${branch} https://${url}/${repository}.git ${workdir}/ && cd ${workdir} && git submodule update --init --recursive && git lfs pull && cd .. `
);
const body = await prisma.githubApp.findUnique({ where: { id: githubAppId } }); } else {
if (body.privateKey) body.privateKey = decrypt(body.privateKey); const body = await prisma.githubApp.findUnique({ where: { id: githubAppId } });
const { privateKey, appId, installationId } = body if (body.privateKey) body.privateKey = decrypt(body.privateKey);
const { privateKey, appId, installationId } = body
const githubPrivateKey = privateKey.replace(/\\n/g, '\n').replace(/"/g, '');
const githubPrivateKey = privateKey.replace(/\\n/g, '\n').replace(/"/g, ''); const payload = {
iat: Math.round(new Date().getTime() / 1000),
const payload = { exp: Math.round(new Date().getTime() / 1000 + 60),
iat: Math.round(new Date().getTime() / 1000), iss: appId
exp: Math.round(new Date().getTime() / 1000 + 60), };
iss: appId const jwtToken = jsonwebtoken.sign(payload, githubPrivateKey, {
}; algorithm: 'RS256'
const jwtToken = jsonwebtoken.sign(payload, githubPrivateKey, { });
algorithm: 'RS256' const { token } = await got
}); .post(`${apiUrl}/app/installations/${installationId}/access_tokens`, {
const { token } = await got headers: {
.post(`${apiUrl}/app/installations/${installationId}/access_tokens`, { Authorization: `Bearer ${jwtToken}`,
headers: { Accept: 'application/vnd.github.machine-man-preview+json'
Authorization: `Bearer ${jwtToken}`, }
Accept: 'application/vnd.github.machine-man-preview+json' })
} .json();
}) await saveBuildLog({
.json(); line: `Cloning ${repository}:${branch} branch.`,
await saveBuildLog({ buildId,
line: `Cloning ${repository}:${branch} branch.`, applicationId
buildId, });
applicationId await asyncExecShell(
}); `git clone -q -b ${branch} https://x-access-token:${token}@${url}/${repository}.git --config core.sshCommand="ssh -p ${customPort}" ${workdir}/ && cd ${workdir} && git submodule update --init --recursive && git lfs pull && cd .. `
await asyncExecShell( );
`git clone -q -b ${branch} https://x-access-token:${token}@${url}/${repository}.git --config core.sshCommand="ssh -p ${customPort}" ${workdir}/ && cd ${workdir} && git submodule update --init --recursive && git lfs pull && cd .. ` }
);
const { stdout: commit } = await asyncExecShell(`cd ${workdir}/ && git rev-parse HEAD`); const { stdout: commit } = await asyncExecShell(`cd ${workdir}/ && git rev-parse HEAD`);
return commit.replace('\n', ''); return commit.replace('\n', '');
} }

View File

@@ -20,7 +20,6 @@ const options: any = {
} }
if (message.caller === 'cleanupStorage') { if (message.caller === 'cleanupStorage') {
if (!scheduler.workers.has('cleanupStorage')) { if (!scheduler.workers.has('cleanupStorage')) {
await scheduler.stop('deployApplication');
await scheduler.run('cleanupStorage') await scheduler.run('cleanupStorage')
} }
} }

View File

@@ -17,19 +17,4 @@ export async function defaultServiceConfigurations({ id, teamId }) {
}); });
} }
return { ...service, network, port, workdir, image, secrets } return { ...service, network, port, workdir, image, secrets }
}
export function defaultServiceComposeConfiguration(network: string): any {
return {
networks: [network],
restart: 'always',
deploy: {
restart_policy: {
condition: 'on-failure',
delay: '10s',
max_attempts: 10,
window: '120s'
}
}
}
} }

View File

@@ -5,7 +5,7 @@ import axios from 'axios';
import { FastifyReply } from 'fastify'; import { FastifyReply } from 'fastify';
import { day } from '../../../../lib/dayjs'; import { day } from '../../../../lib/dayjs';
import { setDefaultBaseImage, setDefaultConfiguration } from '../../../../lib/buildPacks/common'; import { setDefaultBaseImage, setDefaultConfiguration } from '../../../../lib/buildPacks/common';
import { checkDomainsIsValidInDNS, checkDoubleBranch, decrypt, encrypt, errorHandler, executeDockerCmd, generateSshKeyPair, getContainerUsage, getDomain, getFreeExposedPort, isDev, isDomainConfigured, listSettings, prisma, stopBuild, uniqueName } from '../../../../lib/common'; import { checkDomainsIsValidInDNS, checkDoubleBranch, checkExposedPort, decrypt, encrypt, errorHandler, executeDockerCmd, generateSshKeyPair, getContainerUsage, getDomain, getFreeExposedPort, isDev, isDomainConfigured, listSettings, prisma, stopBuild, uniqueName } from '../../../../lib/common';
import { checkContainer, formatLabelsOnDocker, isContainerExited, removeContainer } from '../../../../lib/docker'; import { checkContainer, formatLabelsOnDocker, isContainerExited, removeContainer } from '../../../../lib/docker';
import { scheduler } from '../../../../lib/scheduler'; import { scheduler } from '../../../../lib/scheduler';
@@ -18,7 +18,7 @@ export async function listApplications(request: FastifyRequest) {
const { teamId } = request.user const { teamId } = request.user
const applications = await prisma.application.findMany({ const applications = await prisma.application.findMany({
where: { teams: { some: { id: teamId === '0' ? undefined : teamId } } }, where: { teams: { some: { id: teamId === '0' ? undefined : teamId } } },
include: { teams: true, destinationDocker: true } include: { teams: true, destinationDocker: true, settings: true }
}); });
const settings = await prisma.setting.findFirst() const settings = await prisma.setting.findFirst()
return { return {
@@ -238,6 +238,9 @@ export async function saveApplication(request: FastifyRequest<SaveApplication>,
if (exposePort) { if (exposePort) {
exposePort = Number(exposePort); exposePort = Number(exposePort);
} }
const { destinationDockerId } = await prisma.application.findUnique({ where: { id } })
if (exposePort) await checkExposedPort({ id, exposePort, dockerId: destinationDockerId })
if (denoOptions) denoOptions = denoOptions.trim(); if (denoOptions) denoOptions = denoOptions.trim();
const defaultConfiguration = await setDefaultConfiguration({ const defaultConfiguration = await setDefaultConfiguration({
buildPack, buildPack,
@@ -392,18 +395,7 @@ export async function checkDNS(request: FastifyRequest<CheckDNS>) {
if (found) { if (found) {
throw { status: 500, message: `Domain ${getDomain(fqdn).replace('www.', '')} is already in use!` } throw { status: 500, message: `Domain ${getDomain(fqdn).replace('www.', '')} is already in use!` }
} }
if (exposePort) { await checkExposedPort({ id, configuredPort, exposePort, dockerId, remoteIpAddress })
if (exposePort < 1024 || exposePort > 65535) {
throw { status: 500, message: `Exposed Port needs to be between 1024 and 65535.` }
}
if (configuredPort !== exposePort) {
const availablePort = await getFreeExposedPort(id, exposePort, dockerId, remoteIpAddress);
if (availablePort.toString() !== exposePort.toString()) {
throw { status: 500, message: `Port ${exposePort} is already in use.` }
}
}
}
if (isDNSCheckEnabled && !isDev && !forceSave) { if (isDNSCheckEnabled && !isDev && !forceSave) {
let hostname = request.hostname.split(':')[0]; let hostname = request.hostname.split(':')[0];
if (remoteEngine) hostname = remoteIpAddress; if (remoteEngine) hostname = remoteIpAddress;
@@ -436,7 +428,7 @@ export async function deployApplication(request: FastifyRequest<DeployApplicatio
try { try {
const { id } = request.params const { id } = request.params
const teamId = request.user?.teamId; const teamId = request.user?.teamId;
const { pullmergeRequestId = null, branch } = request.body const { pullmergeRequestId = null, branch, forceRebuild } = request.body
const buildId = cuid(); const buildId = cuid();
const application = await getApplicationFromDB(id, teamId); const application = await getApplicationFromDB(id, teamId);
if (application) { if (application) {
@@ -475,13 +467,15 @@ export async function deployApplication(request: FastifyRequest<DeployApplicatio
type: 'manual', type: 'manual',
...application, ...application,
sourceBranch: branch, sourceBranch: branch,
pullmergeRequestId pullmergeRequestId,
forceRebuild
}); });
} else { } else {
scheduler.workers.get('deployApplication').postMessage({ scheduler.workers.get('deployApplication').postMessage({
build_id: buildId, build_id: buildId,
type: 'manual', type: 'manual',
...application ...application,
forceRebuild
}); });
} }
@@ -499,11 +493,20 @@ export async function deployApplication(request: FastifyRequest<DeployApplicatio
export async function saveApplicationSource(request: FastifyRequest<SaveApplicationSource>, reply: FastifyReply) { export async function saveApplicationSource(request: FastifyRequest<SaveApplicationSource>, reply: FastifyReply) {
try { try {
const { id } = request.params const { id } = request.params
const { gitSourceId } = request.body const { gitSourceId, forPublic, type } = request.body
await prisma.application.update({ if (forPublic) {
where: { id }, const publicGit = await prisma.gitSource.findFirst({ where: { type, forPublic } });
data: { gitSource: { connect: { id: gitSourceId } } } await prisma.application.update({
}); where: { id },
data: { gitSource: { connect: { id: publicGit.id } } }
});
} else {
await prisma.application.update({
where: { id },
data: { gitSource: { connect: { id: gitSourceId } } }
});
}
return reply.code(201).send() return reply.code(201).send()
} catch ({ status, message }) { } catch ({ status, message }) {
return errorHandler({ status, message }) return errorHandler({ status, message })
@@ -557,7 +560,7 @@ export async function checkRepository(request: FastifyRequest<CheckRepository>)
export async function saveRepository(request, reply) { export async function saveRepository(request, reply) {
try { try {
const { id } = request.params const { id } = request.params
let { repository, branch, projectId, autodeploy, webhookToken } = request.body let { repository, branch, projectId, autodeploy, webhookToken, isPublicRepository = false } = request.body
repository = repository.toLowerCase(); repository = repository.toLowerCase();
branch = branch.toLowerCase(); branch = branch.toLowerCase();
@@ -565,17 +568,19 @@ export async function saveRepository(request, reply) {
if (webhookToken) { if (webhookToken) {
await prisma.application.update({ await prisma.application.update({
where: { id }, where: { id },
data: { repository, branch, projectId, gitSource: { update: { gitlabApp: { update: { webhookToken: webhookToken ? webhookToken : undefined } } } }, settings: { update: { autodeploy } } } data: { repository, branch, projectId, gitSource: { update: { gitlabApp: { update: { webhookToken: webhookToken ? webhookToken : undefined } } } }, settings: { update: { autodeploy, isPublicRepository } } }
}); });
} else { } else {
await prisma.application.update({ await prisma.application.update({
where: { id }, where: { id },
data: { repository, branch, projectId, settings: { update: { autodeploy } } } data: { repository, branch, projectId, settings: { update: { autodeploy, isPublicRepository } } }
}); });
} }
const isDouble = await checkDoubleBranch(branch, projectId); if (!isPublicRepository) {
if (isDouble) { const isDouble = await checkDoubleBranch(branch, projectId);
await prisma.applicationSettings.updateMany({ where: { application: { branch, projectId } }, data: { autodeploy: false } }) if (isDouble) {
await prisma.applicationSettings.updateMany({ where: { application: { branch, projectId } }, data: { autodeploy: false, isPublicRepository } })
}
} }
return reply.code(201).send() return reply.code(201).send()
} catch ({ status, message }) { } catch ({ status, message }) {
@@ -607,7 +612,8 @@ export async function getBuildPack(request) {
projectId: application.projectId, projectId: application.projectId,
repository: application.repository, repository: application.repository,
branch: application.branch, branch: application.branch,
apiUrl: application.gitSource.apiUrl apiUrl: application.gitSource.apiUrl,
isPublicRepository: application.settings.isPublicRepository
} }
} catch ({ status, message }) { } catch ({ status, message }) {
return errorHandler({ status, message }) return errorHandler({ status, message })
@@ -657,13 +663,13 @@ export async function saveSecret(request: FastifyRequest<SaveSecret>, reply: Fas
if (found) { if (found) {
throw { status: 500, message: `Secret ${name} already exists.` } throw { status: 500, message: `Secret ${name} already exists.` }
} else { } else {
value = encrypt(value); value = encrypt(value.trim());
await prisma.secret.create({ await prisma.secret.create({
data: { name, value, isBuildSecret, isPRMRSecret, application: { connect: { id } } } data: { name, value, isBuildSecret, isPRMRSecret, application: { connect: { id } } }
}); });
} }
} else { } else {
value = encrypt(value); value = encrypt(value.trim());
const found = await prisma.secret.findFirst({ where: { applicationId: id, name, isPRMRSecret } }); const found = await prisma.secret.findFirst({ where: { applicationId: id, name, isPRMRSecret } });
if (found) { if (found) {

View File

@@ -44,13 +44,13 @@ export interface CheckDNS extends OnlyId {
} }
export interface DeployApplication { export interface DeployApplication {
Querystring: { domain: string } Querystring: { domain: string }
Body: { pullmergeRequestId: string | null, branch: string } Body: { pullmergeRequestId: string | null, branch: string, forceRebuild?: boolean }
} }
export interface GetImages { export interface GetImages {
Body: { buildPack: string, deploymentType: string } Body: { buildPack: string, deploymentType: string }
} }
export interface SaveApplicationSource extends OnlyId { export interface SaveApplicationSource extends OnlyId {
Body: { gitSourceId: string } Body: { gitSourceId?: string | null, forPublic?: boolean, type?: string }
} }
export interface CheckRepository extends OnlyId { export interface CheckRepository extends OnlyId {
Querystring: { repository: string, branch: string } Querystring: { repository: string, branch: string }
@@ -115,7 +115,8 @@ export interface CancelDeployment {
export interface DeployApplication extends OnlyId { export interface DeployApplication extends OnlyId {
Body: { Body: {
pullmergeRequestId: string | null, pullmergeRequestId: string | null,
branch: string branch: string,
forceRebuild?: boolean
} }
} }

View File

@@ -79,7 +79,6 @@ export async function newDestination(request: FastifyRequest<NewDestination>, re
let { name, network, engine, isCoolifyProxyUsed, remoteIpAddress, remoteUser, remotePort } = request.body let { name, network, engine, isCoolifyProxyUsed, remoteIpAddress, remoteUser, remotePort } = request.body
if (id === 'new') { if (id === 'new') {
console.log(engine)
if (engine) { if (engine) {
const { stdout } = await asyncExecShell(`DOCKER_HOST=unix:///var/run/docker.sock docker network ls --filter 'name=^${network}$' --format '{{json .}}'`); const { stdout } = await asyncExecShell(`DOCKER_HOST=unix:///var/run/docker.sock docker network ls --filter 'name=^${network}$' --format '{{json .}}'`);
if (stdout === '') { if (stdout === '') {

View File

@@ -4,7 +4,7 @@ import axios from 'axios';
import compare from 'compare-versions'; import compare from 'compare-versions';
import cuid from 'cuid'; import cuid from 'cuid';
import bcrypt from 'bcryptjs'; import bcrypt from 'bcryptjs';
import { asyncExecShell, asyncSleep, cleanupDockerStorage, errorHandler, isDev, prisma, uniqueName, version } from '../../../lib/common'; import { asyncExecShell, asyncSleep, cleanupDockerStorage, errorHandler, isDev, listSettings, prisma, uniqueName, version } from '../../../lib/common';
import type { FastifyReply, FastifyRequest } from 'fastify'; import type { FastifyReply, FastifyRequest } from 'fastify';
import type { Login, Update } from '.'; import type { Login, Update } from '.';
@@ -97,7 +97,8 @@ export async function showDashboard(request: FastifyRequest) {
const userId = request.user.userId; const userId = request.user.userId;
const teamId = request.user.teamId; const teamId = request.user.teamId;
const applications = await prisma.application.findMany({ const applications = await prisma.application.findMany({
where: { teams: { some: { id: teamId === '0' ? undefined : teamId } } } where: { teams: { some: { id: teamId === '0' ? undefined : teamId } } },
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 } } }
@@ -105,10 +106,12 @@ export async function showDashboard(request: FastifyRequest) {
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 } } }
}); });
const settings = await listSettings();
return { return {
applications, applications,
databases, databases,
services, services,
settings,
}; };
} catch ({ status, message }) { } catch ({ status, message }) {
return errorHandler({ status, message }) return errorHandler({ status, message })

View File

@@ -2,14 +2,14 @@ import type { FastifyReply, FastifyRequest } from 'fastify';
import fs from 'fs/promises'; import fs from 'fs/promises';
import yaml from 'js-yaml'; import yaml from 'js-yaml';
import bcrypt from 'bcryptjs'; import bcrypt from 'bcryptjs';
import { prisma, uniqueName, asyncExecShell, getServiceImage, configureServiceType, getServiceFromDB, getContainerUsage, removeService, isDomainConfigured, saveUpdateableFields, fixType, decrypt, encrypt, getServiceMainPort, createDirectories, ComposeFile, makeLabelForServices, getFreePublicPort, getDomain, errorHandler, generatePassword, isDev, stopTcpHttpProxy, supportedServiceTypesAndVersions, executeDockerCmd, listSettings, getFreeExposedPort, checkDomainsIsValidInDNS, persistentVolumes, asyncSleep, isARM } from '../../../../lib/common'; import { prisma, uniqueName, asyncExecShell, getServiceImage, configureServiceType, getServiceFromDB, getContainerUsage, removeService, isDomainConfigured, saveUpdateableFields, fixType, decrypt, encrypt, getServiceMainPort, createDirectories, ComposeFile, makeLabelForServices, getFreePublicPort, getDomain, errorHandler, generatePassword, isDev, stopTcpHttpProxy, supportedServiceTypesAndVersions, executeDockerCmd, listSettings, getFreeExposedPort, checkDomainsIsValidInDNS, persistentVolumes, asyncSleep, isARM, defaultComposeConfiguration, checkExposedPort } from '../../../../lib/common';
import { day } from '../../../../lib/dayjs'; import { day } from '../../../../lib/dayjs';
import { checkContainer, isContainerExited, removeContainer } from '../../../../lib/docker'; import { checkContainer, isContainerExited, removeContainer } from '../../../../lib/docker';
import cuid from 'cuid'; import cuid from 'cuid';
import type { OnlyId } from '../../../../types'; import type { OnlyId } from '../../../../types';
import type { ActivateWordpressFtp, CheckService, CheckServiceDomain, DeleteServiceSecret, DeleteServiceStorage, GetServiceLogs, SaveService, SaveServiceDestination, SaveServiceSecret, SaveServiceSettings, SaveServiceStorage, SaveServiceType, SaveServiceVersion, ServiceStartStop, SetWordpressSettings } from './types'; import type { ActivateWordpressFtp, CheckService, CheckServiceDomain, DeleteServiceSecret, DeleteServiceStorage, GetServiceLogs, SaveService, SaveServiceDestination, SaveServiceSecret, SaveServiceSettings, SaveServiceStorage, SaveServiceType, SaveServiceVersion, ServiceStartStop, SetWordpressSettings } from './types';
import { defaultServiceComposeConfiguration, defaultServiceConfigurations } from '../../../../lib/services'; import { defaultServiceConfigurations } from '../../../../lib/services';
// async function startServiceNew(request: FastifyRequest<OnlyId>) { // async function startServiceNew(request: FastifyRequest<OnlyId>) {
// try { // try {
@@ -378,18 +378,7 @@ export async function checkService(request: FastifyRequest<CheckService>) {
} }
} }
} }
if (exposePort) { await checkExposedPort({ id, configuredPort, exposePort, dockerId, remoteIpAddress })
if (exposePort < 1024 || exposePort > 65535) {
throw { status: 500, message: `Exposed Port needs to be between 1024 and 65535.` }
}
if (configuredPort !== exposePort) {
const availablePort = await getFreeExposedPort(id, exposePort, dockerId, remoteIpAddress);
if (availablePort.toString() !== exposePort.toString()) {
throw { status: 500, message: `Port ${exposePort} is already in use.` }
}
}
}
if (isDNSCheckEnabled && !isDev && !forceSave) { if (isDNSCheckEnabled && !isDev && !forceSave) {
let hostname = request.hostname.split(':')[0]; let hostname = request.hostname.split(':')[0];
if (remoteEngine) hostname = remoteIpAddress; if (remoteEngine) hostname = remoteIpAddress;
@@ -458,13 +447,13 @@ export async function saveServiceSecret(request: FastifyRequest<SaveServiceSecre
if (found) { if (found) {
throw `Secret ${name} already exists.` throw `Secret ${name} already exists.`
} else { } else {
value = encrypt(value); value = encrypt(value.trim());
await prisma.serviceSecret.create({ await prisma.serviceSecret.create({
data: { name, value, service: { connect: { id } } } data: { name, value, service: { connect: { id } } }
}); });
} }
} else { } else {
value = encrypt(value); value = encrypt(value.trim());
const found = await prisma.serviceSecret.findFirst({ where: { serviceId: id, name } }); const found = await prisma.serviceSecret.findFirst({ where: { serviceId: id, name } });
if (found) { if (found) {
@@ -812,21 +801,21 @@ COPY ./init-db.sh /docker-entrypoint-initdb.d/init-db.sh`;
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}), ...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
depends_on: [`${id}-postgresql`, `${id}-clickhouse`], depends_on: [`${id}-postgresql`, `${id}-clickhouse`],
labels: makeLabelForServices('plausibleAnalytics'), labels: makeLabelForServices('plausibleAnalytics'),
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}, },
[`${id}-postgresql`]: { [`${id}-postgresql`]: {
container_name: `${id}-postgresql`, container_name: `${id}-postgresql`,
image: config.postgresql.image, image: config.postgresql.image,
environment: config.postgresql.environmentVariables, environment: config.postgresql.environmentVariables,
volumes: [config.postgresql.volume], volumes: [config.postgresql.volume],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}, },
[`${id}-clickhouse`]: { [`${id}-clickhouse`]: {
build: workdir, build: workdir,
container_name: `${id}-clickhouse`, container_name: `${id}-clickhouse`,
environment: config.clickhouse.environmentVariables, environment: config.clickhouse.environmentVariables,
volumes: [config.clickhouse.volume], volumes: [config.clickhouse.volume],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
} }
}, },
networks: { networks: {
@@ -887,7 +876,7 @@ async function startNocodbService(request: FastifyRequest<ServiceStartStop>) {
environment: config.environmentVariables, environment: config.environmentVariables,
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}), ...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
labels: makeLabelForServices('nocodb'), labels: makeLabelForServices('nocodb'),
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
} }
}, },
networks: { networks: {
@@ -959,7 +948,7 @@ async function startMinioService(request: FastifyRequest<ServiceStartStop>) {
volumes, volumes,
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}), ...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
labels: makeLabelForServices('minio'), labels: makeLabelForServices('minio'),
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
} }
}, },
networks: { networks: {
@@ -1025,7 +1014,7 @@ async function startVscodeService(request: FastifyRequest<ServiceStartStop>) {
volumes, volumes,
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}), ...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
labels: makeLabelForServices('vscodeServer'), labels: makeLabelForServices('vscodeServer'),
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
} }
}, },
networks: { networks: {
@@ -1132,7 +1121,7 @@ async function startWordpressService(request: FastifyRequest<ServiceStartStop>)
volumes, volumes,
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}), ...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
labels: makeLabelForServices('wordpress'), labels: makeLabelForServices('wordpress'),
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
} }
}, },
networks: { networks: {
@@ -1149,7 +1138,7 @@ async function startWordpressService(request: FastifyRequest<ServiceStartStop>)
image: config.mysql.image, image: config.mysql.image,
volumes: [config.mysql.volume], volumes: [config.mysql.volume],
environment: config.mysql.environmentVariables, environment: config.mysql.environmentVariables,
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}; };
composeFile.volumes[config.mysql.volume.split(':')[0]] = { composeFile.volumes[config.mysql.volume.split(':')[0]] = {
@@ -1202,7 +1191,7 @@ async function startVaultwardenService(request: FastifyRequest<ServiceStartStop>
volumes, volumes,
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}), ...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
labels: makeLabelForServices('vaultWarden'), labels: makeLabelForServices('vaultWarden'),
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
} }
}, },
networks: { networks: {
@@ -1258,7 +1247,7 @@ async function startLanguageToolService(request: FastifyRequest<ServiceStartStop
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}), ...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
volumes, volumes,
labels: makeLabelForServices('languagetool'), labels: makeLabelForServices('languagetool'),
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
} }
}, },
networks: { networks: {
@@ -1315,7 +1304,7 @@ async function startN8nService(request: FastifyRequest<ServiceStartStop>) {
environment: config.environmentVariables, environment: config.environmentVariables,
labels: makeLabelForServices('n8n'), labels: makeLabelForServices('n8n'),
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}), ...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
} }
}, },
networks: { networks: {
@@ -1370,7 +1359,7 @@ async function startUptimekumaService(request: FastifyRequest<ServiceStartStop>)
environment: config.environmentVariables, environment: config.environmentVariables,
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}), ...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
labels: makeLabelForServices('uptimekuma'), labels: makeLabelForServices('uptimekuma'),
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
} }
}, },
networks: { networks: {
@@ -1469,14 +1458,14 @@ async function startGhostService(request: FastifyRequest<ServiceStartStop>) {
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}), ...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
labels: makeLabelForServices('ghost'), labels: makeLabelForServices('ghost'),
depends_on: [`${id}-mariadb`], depends_on: [`${id}-mariadb`],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}, },
[`${id}-mariadb`]: { [`${id}-mariadb`]: {
container_name: `${id}-mariadb`, container_name: `${id}-mariadb`,
image: config.mariadb.image, image: config.mariadb.image,
volumes: [config.mariadb.volume], volumes: [config.mariadb.volume],
environment: config.mariadb.environmentVariables, environment: config.mariadb.environmentVariables,
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
} }
}, },
networks: { networks: {
@@ -1542,7 +1531,7 @@ async function startMeilisearchService(request: FastifyRequest<ServiceStartStop>
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}), ...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
volumes, volumes,
labels: makeLabelForServices('meilisearch'), labels: makeLabelForServices('meilisearch'),
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
} }
}, },
networks: { networks: {
@@ -1708,14 +1697,14 @@ async function startUmamiService(request: FastifyRequest<ServiceStartStop>) {
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}), ...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
labels: makeLabelForServices('umami'), labels: makeLabelForServices('umami'),
depends_on: [`${id}-postgresql`], depends_on: [`${id}-postgresql`],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}, },
[`${id}-postgresql`]: { [`${id}-postgresql`]: {
build: workdir, build: workdir,
container_name: `${id}-postgresql`, container_name: `${id}-postgresql`,
environment: config.postgresql.environmentVariables, environment: config.postgresql.environmentVariables,
volumes: [config.postgresql.volume], volumes: [config.postgresql.volume],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
} }
}, },
networks: { networks: {
@@ -1795,14 +1784,14 @@ async function startHasuraService(request: FastifyRequest<ServiceStartStop>) {
labels: makeLabelForServices('hasura'), labels: makeLabelForServices('hasura'),
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}), ...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
depends_on: [`${id}-postgresql`], depends_on: [`${id}-postgresql`],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}, },
[`${id}-postgresql`]: { [`${id}-postgresql`]: {
image: config.postgresql.image, image: config.postgresql.image,
container_name: `${id}-postgresql`, container_name: `${id}-postgresql`,
environment: config.postgresql.environmentVariables, environment: config.postgresql.environmentVariables,
volumes: [config.postgresql.volume], volumes: [config.postgresql.volume],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
} }
}, },
networks: { networks: {
@@ -1908,14 +1897,14 @@ async function startFiderService(request: FastifyRequest<ServiceStartStop>) {
labels: makeLabelForServices('fider'), labels: makeLabelForServices('fider'),
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}), ...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
depends_on: [`${id}-postgresql`], depends_on: [`${id}-postgresql`],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}, },
[`${id}-postgresql`]: { [`${id}-postgresql`]: {
image: config.postgresql.image, image: config.postgresql.image,
container_name: `${id}-postgresql`, container_name: `${id}-postgresql`,
environment: config.postgresql.environmentVariables, environment: config.postgresql.environmentVariables,
volumes: [config.postgresql.volume], volumes: [config.postgresql.volume],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
} }
}, },
networks: { networks: {
@@ -2001,7 +1990,7 @@ async function startAppWriteService(request: FastifyRequest<ServiceStartStop>) {
"_APP_STATSD_PORT=8125", "_APP_STATSD_PORT=8125",
...secrets ...secrets
], ],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}, },
[`${id}-realtime`]: { [`${id}-realtime`]: {
image: `${image}:${version}`, image: `${image}:${version}`,
@@ -2024,7 +2013,7 @@ async function startAppWriteService(request: FastifyRequest<ServiceStartStop>) {
`_APP_DB_PASS=${mariadbPassword}`, `_APP_DB_PASS=${mariadbPassword}`,
...secrets ...secrets
], ],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}, },
[`${id}-worker-audits`]: { [`${id}-worker-audits`]: {
@@ -2048,7 +2037,7 @@ async function startAppWriteService(request: FastifyRequest<ServiceStartStop>) {
`_APP_DB_PASS=${mariadbPassword}`, `_APP_DB_PASS=${mariadbPassword}`,
...secrets ...secrets
], ],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}, },
[`${id}-worker-webhooks`]: { [`${id}-worker-webhooks`]: {
image: `${image}:${version}`, image: `${image}:${version}`,
@@ -2066,7 +2055,7 @@ async function startAppWriteService(request: FastifyRequest<ServiceStartStop>) {
"_APP_REDIS_PORT=6379", "_APP_REDIS_PORT=6379",
...secrets ...secrets
], ],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}, },
[`${id}-worker-deletes`]: { [`${id}-worker-deletes`]: {
image: `${image}:${version}`, image: `${image}:${version}`,
@@ -2099,7 +2088,7 @@ async function startAppWriteService(request: FastifyRequest<ServiceStartStop>) {
`_APP_EXECUTOR_HOST=http://${id}-executor/v1`, `_APP_EXECUTOR_HOST=http://${id}-executor/v1`,
...secrets ...secrets
], ],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}, },
[`${id}-worker-databases`]: { [`${id}-worker-databases`]: {
image: `${image}:${version}`, image: `${image}:${version}`,
@@ -2122,7 +2111,7 @@ async function startAppWriteService(request: FastifyRequest<ServiceStartStop>) {
`_APP_DB_PASS=${mariadbPassword}`, `_APP_DB_PASS=${mariadbPassword}`,
...secrets ...secrets
], ],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}, },
[`${id}-worker-builds`]: { [`${id}-worker-builds`]: {
image: `${image}:${version}`, image: `${image}:${version}`,
@@ -2147,7 +2136,7 @@ async function startAppWriteService(request: FastifyRequest<ServiceStartStop>) {
`_APP_DB_PASS=${mariadbPassword}`, `_APP_DB_PASS=${mariadbPassword}`,
...secrets ...secrets
], ],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}, },
[`${id}-worker-certificates`]: { [`${id}-worker-certificates`]: {
image: `${image}:${version}`, image: `${image}:${version}`,
@@ -2176,7 +2165,7 @@ async function startAppWriteService(request: FastifyRequest<ServiceStartStop>) {
`_APP_DB_PASS=${mariadbPassword}`, `_APP_DB_PASS=${mariadbPassword}`,
...secrets ...secrets
], ],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}, },
[`${id}-worker-functions`]: { [`${id}-worker-functions`]: {
image: `${image}:${version}`, image: `${image}:${version}`,
@@ -2202,7 +2191,7 @@ async function startAppWriteService(request: FastifyRequest<ServiceStartStop>) {
`_APP_EXECUTOR_HOST=http://${id}-executor/v1`, `_APP_EXECUTOR_HOST=http://${id}-executor/v1`,
...secrets ...secrets
], ],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}, },
[`${id}-executor`]: { [`${id}-executor`]: {
image: `${image}:${version}`, image: `${image}:${version}`,
@@ -2226,7 +2215,7 @@ async function startAppWriteService(request: FastifyRequest<ServiceStartStop>) {
`_APP_EXECUTOR_SECRET=${executorSecret}`, `_APP_EXECUTOR_SECRET=${executorSecret}`,
...secrets ...secrets
], ],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}, },
[`${id}-worker-mails`]: { [`${id}-worker-mails`]: {
image: `${image}:${version}`, image: `${image}:${version}`,
@@ -2243,7 +2232,7 @@ async function startAppWriteService(request: FastifyRequest<ServiceStartStop>) {
"_APP_REDIS_PORT=6379", "_APP_REDIS_PORT=6379",
...secrets ...secrets
], ],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}, },
[`${id}-worker-messaging`]: { [`${id}-worker-messaging`]: {
image: `${image}:${version}`, image: `${image}:${version}`,
@@ -2259,7 +2248,7 @@ async function startAppWriteService(request: FastifyRequest<ServiceStartStop>) {
"_APP_REDIS_PORT=6379", "_APP_REDIS_PORT=6379",
...secrets ...secrets
], ],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}, },
[`${id}-maintenance`]: { [`${id}-maintenance`]: {
image: `${image}:${version}`, image: `${image}:${version}`,
@@ -2283,7 +2272,7 @@ async function startAppWriteService(request: FastifyRequest<ServiceStartStop>) {
`_APP_DB_PASS=${mariadbPassword}`, `_APP_DB_PASS=${mariadbPassword}`,
...secrets ...secrets
], ],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}, },
[`${id}-schedule`]: { [`${id}-schedule`]: {
image: `${image}:${version}`, image: `${image}:${version}`,
@@ -2299,7 +2288,7 @@ async function startAppWriteService(request: FastifyRequest<ServiceStartStop>) {
"_APP_REDIS_PORT=6379", "_APP_REDIS_PORT=6379",
...secrets ...secrets
], ],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}, },
[`${id}-mariadb`]: { [`${id}-mariadb`]: {
"image": "mariadb:10.7", "image": "mariadb:10.7",
@@ -2316,7 +2305,7 @@ async function startAppWriteService(request: FastifyRequest<ServiceStartStop>) {
`MYSQL_DATABASE=${mariadbDatabase}` `MYSQL_DATABASE=${mariadbDatabase}`
], ],
"command": "mysqld --innodb-flush-method=fsync", "command": "mysqld --innodb-flush-method=fsync",
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}, },
[`${id}-redis`]: { [`${id}-redis`]: {
"image": "redis:6.2-alpine", "image": "redis:6.2-alpine",
@@ -2325,7 +2314,7 @@ async function startAppWriteService(request: FastifyRequest<ServiceStartStop>) {
"volumes": [ "volumes": [
`${id}-redis:/data:rw` `${id}-redis:/data:rw`
], ],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
}, },
}; };
@@ -2354,7 +2343,7 @@ async function startAppWriteService(request: FastifyRequest<ServiceStartStop>) {
"_APP_REDIS_PORT=6379", "_APP_REDIS_PORT=6379",
...secrets ...secrets
], ],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
} }
dockerCompose[`${id}-influxdb`] = { dockerCompose[`${id}-influxdb`] = {
"image": "appwrite/influxdb:1.5.0", "image": "appwrite/influxdb:1.5.0",
@@ -2362,7 +2351,7 @@ async function startAppWriteService(request: FastifyRequest<ServiceStartStop>) {
"volumes": [ "volumes": [
`${id}-influxdb:/var/lib/influxdb:rw` `${id}-influxdb:/var/lib/influxdb:rw`
], ],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
} }
dockerCompose[`${id}-telegraf`] = { dockerCompose[`${id}-telegraf`] = {
"image": "appwrite/telegraf:1.4.0", "image": "appwrite/telegraf:1.4.0",
@@ -2371,7 +2360,7 @@ async function startAppWriteService(request: FastifyRequest<ServiceStartStop>) {
`_APP_INFLUXDB_HOST=${id}-influxdb`, `_APP_INFLUXDB_HOST=${id}-influxdb`,
"_APP_INFLUXDB_PORT=8086", "_APP_INFLUXDB_PORT=8086",
], ],
...defaultServiceComposeConfiguration(network), ...defaultComposeConfiguration(network),
} }
} }

View File

@@ -33,12 +33,13 @@ export async function saveSettings(request: FastifyRequest<SaveSettings>, reply:
minPort, minPort,
maxPort, maxPort,
isAutoUpdateEnabled, isAutoUpdateEnabled,
isDNSCheckEnabled isDNSCheckEnabled,
DNSServers
} = request.body } = request.body
const { id } = await listSettings(); const { id } = await listSettings();
await prisma.setting.update({ await prisma.setting.update({
where: { id }, where: { id },
data: { isRegistrationEnabled, dualCerts, isAutoUpdateEnabled, isDNSCheckEnabled } data: { isRegistrationEnabled, dualCerts, isAutoUpdateEnabled, isDNSCheckEnabled, DNSServers }
}); });
if (fqdn) { if (fqdn) {
await prisma.setting.update({ where: { id }, data: { fqdn } }); await prisma.setting.update({ where: { id }, data: { fqdn } });
@@ -54,6 +55,10 @@ export async function saveSettings(request: FastifyRequest<SaveSettings>, reply:
export async function deleteDomain(request: FastifyRequest<DeleteDomain>, reply: FastifyReply) { export async function deleteDomain(request: FastifyRequest<DeleteDomain>, reply: FastifyReply) {
try { try {
const { fqdn } = request.body const { fqdn } = request.body
const { DNSServers } = await listSettings();
if (DNSServers) {
dns.setServers([DNSServers]);
}
let ip; let ip;
try { try {
ip = await dns.resolve(fqdn); ip = await dns.resolve(fqdn);

View File

@@ -8,7 +8,8 @@ export interface SaveSettings {
minPort: number, minPort: number,
maxPort: number, maxPort: number,
isAutoUpdateEnabled: boolean, isAutoUpdateEnabled: boolean,
isDNSCheckEnabled: boolean isDNSCheckEnabled: boolean,
DNSServers: string
} }
} }
export interface DeleteDomain { export interface DeleteDomain {

View File

@@ -484,7 +484,6 @@ export async function traefikOtherConfiguration(request: FastifyRequest<TraefikO
} }
throw { status: 500 } throw { status: 500 }
} catch ({ status, message }) { } catch ({ status, message }) {
console.log(status, message);
return errorHandler({ status, message }) return errorHandler({ status, message })
} }
} }

View File

@@ -83,7 +83,7 @@
disabled={updateStatus.success === false} disabled={updateStatus.success === false}
on:click={update} on:click={update}
class="icons tooltip tooltip-right tooltip-primary bg-gradient-to-r from-purple-500 via-pink-500 to-red-500 text-white duration-75 hover:scale-105" class="icons tooltip tooltip-right tooltip-primary bg-gradient-to-r from-purple-500 via-pink-500 to-red-500 text-white duration-75 hover:scale-105"
data-tip="Update available!" data-tip="Update Available!"
> >
{#if updateStatus.loading} {#if updateStatus.loading}
<svg <svg

View File

@@ -4,7 +4,7 @@
"wait_new_version_startup": "Waiting for the new version to start...", "wait_new_version_startup": "Waiting for the new version to start...",
"new_version": "New version reachable. Reloading...", "new_version": "New version reachable. Reloading...",
"switch_to_a_different_team": "Switch to a different team...", "switch_to_a_different_team": "Switch to a different team...",
"update_available": "Update available" "update_available": "Update Available"
}, },
"error": { "error": {
"you_can_find_your_way_back": "You can find your way back", "you_can_find_your_way_back": "You can find your way back",
@@ -159,13 +159,13 @@
"storage_saved": "Storage saved.", "storage_saved": "Storage saved.",
"storage_updated": "Storage updated.", "storage_updated": "Storage updated.",
"storage_deleted": "Storage deleted.", "storage_deleted": "Storage deleted.",
"persistent_storage_explainer": "You can specify any folder that you want to be persistent across deployments. <br>This is useful for storing data such as a database (SQLite) or a cache." "persistent_storage_explainer": "You can specify any folder that you want to be persistent across deployments.<br><span class='text-green-500 font-bold'>/example</span> means it will preserve <span class='text-green-500 font-bold'>/app/example</span> in the container as <span class='text-green-500 font-bold'>/app</span> is <span class='text-green-500 font-bold'>the root directory</span> for your application.<br><br>This is useful for storing data such as a <span class='text-green-500 font-bold'>database (SQLite)</span> or a <span class='text-green-500 font-bold'>cache</span>."
}, },
"deployment_queued": "Deployment queued.", "deployment_queued": "Deployment queued.",
"confirm_to_delete": "Are you sure you would like to delete '{{name}}'?", "confirm_to_delete": "Are you sure you would like to delete '{{name}}'?",
"stop_application": "Stop application", "stop_application": "Stop Application",
"permission_denied_stop_application": "You do not have permission to stop the application.", "permission_denied_stop_application": "You do not have permission to stop the application.",
"rebuild_application": "Rebuild application", "rebuild_application": "Rebuild Application",
"permission_denied_rebuild_application": "You do not have permission to rebuild application.", "permission_denied_rebuild_application": "You do not have permission to rebuild application.",
"build_and_start_application": "Deploy", "build_and_start_application": "Deploy",
"permission_denied_build_and_start_application": "You do not have permission to deploy application.", "permission_denied_build_and_start_application": "You do not have permission to deploy application.",

View File

@@ -1,3 +1,4 @@
import { dev } from '$app/env';
import cuid from 'cuid'; import cuid from 'cuid';
import { writable, readable, type Writable } from 'svelte/store'; import { writable, readable, type Writable } from 'svelte/store';
@@ -71,8 +72,9 @@ export const features = readable({
export const location: Writable<null | string> = writable(null) export const location: Writable<null | string> = writable(null)
export const setLocation = (resource: any, settings?: any) => { export const setLocation = (resource: any, settings?: any) => {
if (resource.settings.isBot) { if (resource.settings.isBot && resource.exposePort) {
return location.set(`http://${settings.ipv4}:${resource.exposePort}`) disabledButton.set(false);
return location.set(`http://${dev ? 'localhost' : settings.ipv4}:${resource.exposePort}`)
} }
if (GITPOD_WORKSPACE_URL && resource.exposePort) { if (GITPOD_WORKSPACE_URL && resource.exposePort) {
const { href } = new URL(GITPOD_WORKSPACE_URL); const { href } = new URL(GITPOD_WORKSPACE_URL);
@@ -84,7 +86,12 @@ export const setLocation = (resource: any, settings?: any) => {
const newURL = `https://${CODESANDBOX_HOST.replace(/\$PORT/, resource.exposePort)}` const newURL = `https://${CODESANDBOX_HOST.replace(/\$PORT/, resource.exposePort)}`
return location.set(newURL) return location.set(newURL)
} }
return location.set(resource.fqdn) if (resource.fqdn) {
return location.set(resource.fqdn)
} else {
location.set(null);
disabledButton.set(false);
}
} }
export const toasts: any = writable([]) export const toasts: any = writable([])

View File

@@ -77,9 +77,9 @@
const { id } = $page.params; const { id } = $page.params;
async function handleDeploySubmit() { async function handleDeploySubmit(forceRebuild = false) {
try { try {
const { buildId } = await post(`/applications/${id}/deploy`, { ...application }); const { buildId } = await post(`/applications/${id}/deploy`, { ...application, forceRebuild });
addToast({ addToast({
message: $t('application.deployment_queued'), message: $t('application.deployment_queued'),
type: 'success' type: 'success'
@@ -141,8 +141,7 @@
if ( if (
application.gitSourceId && application.gitSourceId &&
application.destinationDockerId && application.destinationDockerId &&
application.fqdn && (application.fqdn || application.settings.isBot)
!application.settings.isBot
) { ) {
await getStatus(); await getStatus();
statusInterval = setInterval(async () => { statusInterval = setInterval(async () => {
@@ -179,9 +178,10 @@
<polyline points="15 4 20 4 20 9" /> <polyline points="15 4 20 4 20 9" />
</svg></a </svg></a
> >
<div class="border border-coolgray-500 h-8" />
{/if} {/if}
<div class="border border-coolgray-500 h-8" />
{#if $status.application.isExited} {#if $status.application.isExited}
<a <a
href={!$disabledButton ? `/applications/${id}/logs` : null} href={!$disabledButton ? `/applications/${id}/logs` : null}
@@ -256,7 +256,7 @@
<rect x="14" y="5" width="4" height="14" rx="1" /> <rect x="14" y="5" width="4" height="14" rx="1" />
</svg> </svg>
</button> </button>
<form on:submit|preventDefault={handleDeploySubmit}> <form on:submit|preventDefault={() => handleDeploySubmit(true)}>
<button <button
type="submit" type="submit"
disabled={$disabledButton || !isQueueActive} disabled={$disabledButton || !isQueueActive}
@@ -264,7 +264,7 @@
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 ? isQueueActive
? 'Rebuild application' ? 'Force Rebuild Application'
: 'Autoupdate inprogress. Cannot rebuild application.' : 'Autoupdate inprogress. Cannot rebuild application.'
: 'You do not have permission to rebuild application.'} : 'You do not have permission to rebuild application.'}
> >
@@ -409,37 +409,39 @@
</svg> </svg>
</button></a </button></a
> >
<a {#if !application.settings.isBot}
href={!$disabledButton ? `/applications/${id}/previews` : null} <a
sveltekit:prefetch href={!$disabledButton ? `/applications/${id}/previews` : null}
class="hover:text-orange-500 rounded" sveltekit:prefetch
class:text-orange-500={$page.url.pathname === `/applications/${id}/previews`} class="hover:text-orange-500 rounded"
class:bg-coolgray-500={$page.url.pathname === `/applications/${id}/previews`} class:text-orange-500={$page.url.pathname === `/applications/${id}/previews`}
> class:bg-coolgray-500={$page.url.pathname === `/applications/${id}/previews`}
<button
disabled={$disabledButton}
class="icons bg-transparent tooltip tooltip-primary tooltip-bottom text-sm"
data-tip="Previews"
> >
<svg <button
xmlns="http://www.w3.org/2000/svg" disabled={$disabledButton}
class="w-6 h-6" class="icons bg-transparent tooltip tooltip-primary tooltip-bottom text-sm"
viewBox="0 0 24 24" data-tip="Previews"
stroke-width="1.5"
stroke="currentColor"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
> >
<path stroke="none" d="M0 0h24v24H0z" fill="none" /> <svg
<circle cx="7" cy="18" r="2" /> xmlns="http://www.w3.org/2000/svg"
<circle cx="7" cy="6" r="2" /> class="w-6 h-6"
<circle cx="17" cy="12" r="2" /> viewBox="0 0 24 24"
<line x1="7" y1="8" x2="7" y2="16" /> stroke-width="1.5"
<path d="M7 8a4 4 0 0 0 4 4h4" /> stroke="currentColor"
</svg></button fill="none"
></a stroke-linecap="round"
> stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<circle cx="7" cy="18" r="2" />
<circle cx="7" cy="6" r="2" />
<circle cx="17" cy="12" r="2" />
<line x1="7" y1="8" x2="7" y2="16" />
<path d="M7 8a4 4 0 0 0 4 4h4" />
</svg></button
></a
>
{/if}
<div class="border border-coolgray-500 h-8" /> <div class="border border-coolgray-500 h-8" />
<a <a
href={!$disabledButton && $status.application.isRunning ? `/applications/${id}/logs` : null} href={!$disabledButton && $status.application.isRunning ? `/applications/${id}/logs` : null}

View File

@@ -26,7 +26,7 @@
delete tempBuildPack.color; delete tempBuildPack.color;
delete tempBuildPack.hoverColor; delete tempBuildPack.hoverColor;
if (foundConfig.buildPack !== name) { if (foundConfig?.buildPack !== name) {
await post(`/applications/${id}`, { ...tempBuildPack, buildPack: name }); await post(`/applications/${id}`, { ...tempBuildPack, buildPack: name });
} }
await post(`/applications/${id}/configuration/buildpack`, { buildPack: name }); await post(`/applications/${id}/configuration/buildpack`, { buildPack: name });

View File

@@ -0,0 +1,199 @@
<script lang="ts">
import { get, post } from '$lib/api';
import { t } from '$lib/translations';
import { page } from '$app/stores';
import Select from 'svelte-select';
import Explainer from '$lib/components/Explainer.svelte';
import { goto } from '$app/navigation';
import { errorNotification } from '$lib/common';
const { id } = $page.params;
let publicRepositoryLink: string;
let projectId: number;
let repositoryName: string;
let branchName: string;
let ownerName: string;
let type: string;
let branchSelectOptions: any = [];
let loading = {
branches: false
};
async function loadBranches() {
try {
loading.branches = true;
const protocol = publicRepositoryLink.split(':')[0];
const gitUrl = publicRepositoryLink.replace('http://', '').replace('https://', '');
let [host, ...path] = gitUrl.split('/');
const [owner, repository, ...branch] = path;
ownerName = owner;
repositoryName = repository;
if (host === 'github.com') {
host = 'api.github.com';
type = 'github';
if (branch[0] === 'tree' && branch[1]) {
branchName = branch[1];
}
}
if (host === 'gitlab.com') {
host = 'gitlab.com/api/v4';
type = 'gitlab';
if (branch[1] === 'tree' && branch[2]) {
branchName = branch[2];
}
}
const apiUrl = `${protocol}://${host}`;
if (type === 'github') {
const repositoryDetails = await get(`${apiUrl}/repos/${ownerName}/${repositoryName}`);
projectId = repositoryDetails.id.toString();
}
if (type === 'gitlab') {
const repositoryDetails = await get(`${apiUrl}/projects/${ownerName}%2F${repositoryName}`);
projectId = repositoryDetails.id.toString();
}
if (type === 'github' && branchName) {
try {
await get(`${apiUrl}/repos/${ownerName}/${repositoryName}/branches/${branchName}`);
await saveRepository();
loading.branches = false;
return;
} catch (error) {
errorNotification(error);
}
}
if (type === 'gitlab' && branchName) {
try {
await get(
`${apiUrl}/projects/${ownerName}%2F${repositoryName}/repository/branches/${branchName}`
);
await saveRepository();
loading.branches = false;
return;
} catch (error) {
errorNotification(error);
}
}
let branches: any[] = [];
let page = 1;
let branchCount = 0;
const loadedBranches = await loadBranchesByPage(
apiUrl,
ownerName,
repositoryName,
page,
type
);
branches = branches.concat(loadedBranches);
branchCount = branches.length;
if (branchCount === 100) {
while (branchCount === 100) {
page = page + 1;
const nextBranches = await loadBranchesByPage(
apiUrl,
ownerName,
repositoryName,
page,
type
);
branches = branches.concat(nextBranches);
branchCount = nextBranches.length;
}
}
loading.branches = false;
branchSelectOptions = branches.map((branch: any) => ({
value: branch.name,
label: branch.name
}));
} catch (error) {
return errorNotification(error);
} finally {
loading.branches = false;
}
}
async function loadBranchesByPage(
apiUrl: string,
owner: string,
repository: string,
page = 1,
type: string
) {
if (type === 'github') {
return await get(`${apiUrl}/repos/${owner}/${repository}/branches?per_page=100&page=${page}`);
}
if (type === 'gitlab') {
return await get(
`${apiUrl}/projects/${ownerName}%2F${repositoryName}/repository/branches?page=${page}`
);
}
}
async function saveRepository(event?: any) {
try {
if (event?.detail?.value) {
branchName = event.detail.value;
}
await post(`/applications/${id}/configuration/source`, {
gitSourceId: null,
forPublic: true,
type
});
await post(`/applications/${id}/configuration/repository`, {
repository: `${ownerName}/${repositoryName}`,
branch: branchName,
projectId,
autodeploy: false,
webhookToken: null,
isPublicRepository: true
});
return await goto(`/applications/${id}/configuration/destination`);
} catch (error) {
return errorNotification(error);
}
}
</script>
<div class="mx-auto max-w-5xl">
<div class="grid grid-flow-row gap-2 px-10">
<div class="flex">
<form class="flex" on:submit|preventDefault={loadBranches}>
<div class="space-y-4">
<input
placeholder="eg: https://github.com/coollabsio/nodejs-example/tree/main"
class="text-xs"
bind:value={publicRepositoryLink}
/>
{#if branchSelectOptions.length > 0}
<div class="custom-select-wrapper">
<Select
placeholder={loading.branches
? $t('application.configuration.loading_branches')
: !publicRepositoryLink
? $t('application.configuration.select_a_repository_first')
: $t('application.configuration.select_a_branch')}
isWaiting={loading.branches}
showIndicator={!!publicRepositoryLink && !loading.branches}
id="branches"
on:select={saveRepository}
items={branchSelectOptions}
isDisabled={loading.branches || !!!publicRepositoryLink}
isClearable={false}
/>
</div>
{/if}
</div>
<button class="btn mx-4 bg-orange-600" class:loading={loading.branches} type="submit"
>Load Repository</button
>
</form>
</div>
</div>
<Explainer
text="Examples:<br><br>https://github.com/coollabsio/nodejs-example<br>https://github.com/coollabsio/nodejs-example/tree/main<br>https://gitlab.com/aleveha/fastify-example<br>https://gitlab.com/aleveha/fastify-example/-/tree/master<br><br>Only works with Github.com and Gitlab.com."
/>
</div>

View File

@@ -47,6 +47,7 @@
export let branch: any; export let branch: any;
export let type: any; export let type: any;
export let application: any; export let application: any;
export let isPublicRepository: boolean;
function checkPackageJSONContents({ key, json }: { key: any; json: any }) { function checkPackageJSONContents({ key, json }: { key: any; json: any }) {
return json?.dependencies?.hasOwnProperty(key) || json?.devDependencies?.hasOwnProperty(key); return json?.dependencies?.hasOwnProperty(key) || json?.devDependencies?.hasOwnProperty(key);
@@ -236,7 +237,7 @@
if (error.message === 'Bad credentials') { if (error.message === 'Bad credentials') {
const { token } = await get(`/applications/${id}/configuration/githubToken`); const { token } = await get(`/applications/${id}/configuration/githubToken`);
$appSession.tokens.github = token; $appSession.tokens.github = token;
return await scanRepository() return await scanRepository();
} }
return errorNotification(error); return errorNotification(error);
} finally { } finally {
@@ -245,7 +246,11 @@
} }
} }
onMount(async () => { onMount(async () => {
await scanRepository(); if (!isPublicRepository) {
await scanRepository();
} else {
scanning = false;
}
}); });
</script> </script>
@@ -262,27 +267,25 @@
</div> </div>
</div> </div>
{:else} {:else}
<div class="max-w-5xl mx-auto ">
<div class="title pb-2">Coolify</div>
<div class="max-w-7xl mx-auto ">
<div class="title pb-2">Coolify Buildpacks</div>
<div class="flex flex-wrap justify-center"> <div class="flex flex-wrap justify-center">
{#each buildPacks.filter(bp => bp.isCoolifyBuildPack === true) as buildPack} {#each buildPacks.filter((bp) => bp.isCoolifyBuildPack === true) as buildPack}
<div class="p-2"> <div class="p-2">
<BuildPack {packageManager} {buildPack} {scanning} bind:foundConfig /> <BuildPack {packageManager} {buildPack} {scanning} bind:foundConfig />
</div> </div>
{/each} {/each}
</div> </div>
</div> </div>
<div class="max-w-7xl mx-auto "> <div class="max-w-5xl mx-auto ">
<div class="title pb-2">Heroku</div> <div class="title pb-2">Other</div>
<div class="flex flex-wrap justify-center"> <div class="flex flex-wrap justify-center">
{#each buildPacks.filter(bp => bp.isHerokuBuildPack === true) as buildPack} {#each buildPacks.filter((bp) => bp.isHerokuBuildPack === true) as buildPack}
<div class="p-2"> <div class="p-2">
<BuildPack {packageManager} {buildPack} {scanning} bind:foundConfig /> <BuildPack {packageManager} {buildPack} {scanning} bind:foundConfig />
</div> </div>
{/each} {/each}
</div> </div>
</div> </div>
{/if} {/if}

View File

@@ -48,3 +48,4 @@
<GitlabRepositories {application} {appId} {settings} /> <GitlabRepositories {application} {appId} {settings} />
{/if} {/if}
</div> </div>

View File

@@ -31,6 +31,8 @@
import { t } from '$lib/translations'; import { t } from '$lib/translations';
import { errorNotification } from '$lib/common'; import { errorNotification } from '$lib/common';
import { appSession } from '$lib/store'; import { appSession } from '$lib/store';
import PublicRepository from './_PublicRepository.svelte';
import Explainer from '$lib/components/Explainer.svelte';
const { id } = $page.params; const { id } = $page.params;
const from = $page.url.searchParams.get('from'); const from = $page.url.searchParams.get('from');
@@ -71,120 +73,126 @@
{$t('application.configuration.select_a_git_source')} {$t('application.configuration.select_a_git_source')}
</div> </div>
</div> </div>
<div class="flex flex-col justify-center"> <div class="max-w-5xl mx-auto ">
{#if !filteredSources || ownSources.length === 0} <div class="title pb-8">Git App</div>
<div class="flex-col"> <div class="flex flex-wrap justify-center">
<div class="pb-2 text-center font-bold"> {#if !filteredSources || ownSources.length === 0}
{$t('application.configuration.no_configurable_git')} <div class="flex-col">
</div> <div class="pb-2 text-center font-bold">
<div class="flex justify-center"> {$t('application.configuration.no_configurable_git')}
<a </div>
href="/sources/new?from={$page.url.pathname}" <div class="flex justify-center">
class="add-icon bg-orange-600 hover:bg-orange-500" <a
> href="/sources/new?from={$page.url.pathname}"
<svg class="add-icon bg-orange-600 hover:bg-orange-500"
class="w-6"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
><path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 6v6m0 0v6m0-6h6m-6 0H6"
/></svg
> >
</a> <svg
class="w-6"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
><path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 6v6m0 0v6m0-6h6m-6 0H6"
/></svg
>
</a>
</div>
</div> </div>
</div> {:else}
{:else} <div class="flex flex-col flex-wrap justify-center px-2 md:flex-row ">
<div class="flex flex-col flex-wrap justify-center px-2 md:flex-row "> {#each ownSources as source}
{#each ownSources as source} <div class="p-2 relative">
<div class="p-2 relative"> <div class="absolute -m-4">
<div class="absolute -m-4"> {#if source?.type === 'gitlab'}
{#if source?.type === 'gitlab'} <svg viewBox="0 0 128 128" class="w-8">
<svg viewBox="0 0 128 128" class="w-8"> <path
<path fill="#FC6D26"
fill="#FC6D26" d="M126.615 72.31l-7.034-21.647L105.64 7.76c-.716-2.206-3.84-2.206-4.556 0l-13.94 42.903H40.856L26.916 7.76c-.717-2.206-3.84-2.206-4.557 0L8.42 50.664 1.385 72.31a4.792 4.792 0 001.74 5.358L64 121.894l60.874-44.227a4.793 4.793 0 001.74-5.357"
d="M126.615 72.31l-7.034-21.647L105.64 7.76c-.716-2.206-3.84-2.206-4.556 0l-13.94 42.903H40.856L26.916 7.76c-.717-2.206-3.84-2.206-4.557 0L8.42 50.664 1.385 72.31a4.792 4.792 0 001.74 5.358L64 121.894l60.874-44.227a4.793 4.793 0 001.74-5.357" /><path fill="#E24329" d="M64 121.894l23.144-71.23H40.856L64 121.893z" /><path
/><path fill="#E24329" d="M64 121.894l23.144-71.23H40.856L64 121.893z" /><path fill="#FC6D26"
fill="#FC6D26" d="M64 121.894l-23.144-71.23H8.42L64 121.893z"
d="M64 121.894l-23.144-71.23H8.42L64 121.893z"
/><path
fill="#FCA326"
d="M8.42 50.663L1.384 72.31a4.79 4.79 0 001.74 5.357L64 121.894 8.42 50.664z"
/><path
fill="#E24329"
d="M8.42 50.663h32.436L26.916 7.76c-.717-2.206-3.84-2.206-4.557 0L8.42 50.664z"
/><path fill="#FC6D26" d="M64 121.894l23.144-71.23h32.437L64 121.893z" /><path
fill="#FCA326"
d="M119.58 50.663l7.035 21.647a4.79 4.79 0 01-1.74 5.357L64 121.894l55.58-71.23z"
/><path
fill="#E24329"
d="M119.58 50.663H87.145l13.94-42.902c.717-2.206 3.84-2.206 4.557 0l13.94 42.903z"
/>
</svg>
{:else if source?.type === 'github'}
<svg viewBox="0 0 128 128" class="w-8">
<g fill="#ffffff"
><path
fill-rule="evenodd"
clip-rule="evenodd"
d="M64 5.103c-33.347 0-60.388 27.035-60.388 60.388 0 26.682 17.303 49.317 41.297 57.303 3.017.56 4.125-1.31 4.125-2.905 0-1.44-.056-6.197-.082-11.243-16.8 3.653-20.345-7.125-20.345-7.125-2.747-6.98-6.705-8.836-6.705-8.836-5.48-3.748.413-3.67.413-3.67 6.063.425 9.257 6.223 9.257 6.223 5.386 9.23 14.127 6.562 17.573 5.02.542-3.903 2.107-6.568 3.834-8.076-13.413-1.525-27.514-6.704-27.514-29.843 0-6.593 2.36-11.98 6.223-16.21-.628-1.52-2.695-7.662.584-15.98 0 0 5.07-1.623 16.61 6.19C53.7 35 58.867 34.327 64 34.304c5.13.023 10.3.694 15.127 2.033 11.526-7.813 16.59-6.19 16.59-6.19 3.287 8.317 1.22 14.46.593 15.98 3.872 4.23 6.215 9.617 6.215 16.21 0 23.194-14.127 28.3-27.574 29.796 2.167 1.874 4.097 5.55 4.097 11.183 0 8.08-.07 14.583-.07 16.572 0 1.607 1.088 3.49 4.148 2.897 23.98-7.994 41.263-30.622 41.263-57.294C124.388 32.14 97.35 5.104 64 5.104z"
/><path /><path
d="M26.484 91.806c-.133.3-.605.39-1.035.185-.44-.196-.685-.605-.543-.906.13-.31.603-.395 1.04-.188.44.197.69.61.537.91zm2.446 2.729c-.287.267-.85.143-1.232-.28-.396-.42-.47-.983-.177-1.254.298-.266.844-.14 1.24.28.394.426.472.984.17 1.255zM31.312 98.012c-.37.258-.976.017-1.35-.52-.37-.538-.37-1.183.01-1.44.373-.258.97-.025 1.35.507.368.545.368 1.19-.01 1.452zm3.261 3.361c-.33.365-1.036.267-1.552-.23-.527-.487-.674-1.18-.343-1.544.336-.366 1.045-.264 1.564.23.527.486.686 1.18.333 1.543zm4.5 1.951c-.147.473-.825.688-1.51.486-.683-.207-1.13-.76-.99-1.238.14-.477.823-.7 1.512-.485.683.206 1.13.756.988 1.237zm4.943.361c.017.498-.563.91-1.28.92-.723.017-1.308-.387-1.315-.877 0-.503.568-.91 1.29-.924.717-.013 1.306.387 1.306.88zm4.598-.782c.086.485-.413.984-1.126 1.117-.7.13-1.35-.172-1.44-.653-.086-.498.422-.997 1.122-1.126.714-.123 1.354.17 1.444.663zm0 0" fill="#FCA326"
/></g d="M8.42 50.663L1.384 72.31a4.79 4.79 0 001.74 5.357L64 121.894 8.42 50.664z"
> /><path
</svg> fill="#E24329"
{/if} d="M8.42 50.663h32.436L26.916 7.76c-.717-2.206-3.84-2.206-4.557 0L8.42 50.664z"
/><path fill="#FC6D26" d="M64 121.894l23.144-71.23h32.437L64 121.893z" /><path
fill="#FCA326"
d="M119.58 50.663l7.035 21.647a4.79 4.79 0 01-1.74 5.357L64 121.894l55.58-71.23z"
/><path
fill="#E24329"
d="M119.58 50.663H87.145l13.94-42.902c.717-2.206 3.84-2.206 4.557 0l13.94 42.903z"
/>
</svg>
{:else if source?.type === 'github'}
<svg viewBox="0 0 128 128" class="w-8">
<g fill="#ffffff"
><path
fill-rule="evenodd"
clip-rule="evenodd"
d="M64 5.103c-33.347 0-60.388 27.035-60.388 60.388 0 26.682 17.303 49.317 41.297 57.303 3.017.56 4.125-1.31 4.125-2.905 0-1.44-.056-6.197-.082-11.243-16.8 3.653-20.345-7.125-20.345-7.125-2.747-6.98-6.705-8.836-6.705-8.836-5.48-3.748.413-3.67.413-3.67 6.063.425 9.257 6.223 9.257 6.223 5.386 9.23 14.127 6.562 17.573 5.02.542-3.903 2.107-6.568 3.834-8.076-13.413-1.525-27.514-6.704-27.514-29.843 0-6.593 2.36-11.98 6.223-16.21-.628-1.52-2.695-7.662.584-15.98 0 0 5.07-1.623 16.61 6.19C53.7 35 58.867 34.327 64 34.304c5.13.023 10.3.694 15.127 2.033 11.526-7.813 16.59-6.19 16.59-6.19 3.287 8.317 1.22 14.46.593 15.98 3.872 4.23 6.215 9.617 6.215 16.21 0 23.194-14.127 28.3-27.574 29.796 2.167 1.874 4.097 5.55 4.097 11.183 0 8.08-.07 14.583-.07 16.572 0 1.607 1.088 3.49 4.148 2.897 23.98-7.994 41.263-30.622 41.263-57.294C124.388 32.14 97.35 5.104 64 5.104z"
/><path
d="M26.484 91.806c-.133.3-.605.39-1.035.185-.44-.196-.685-.605-.543-.906.13-.31.603-.395 1.04-.188.44.197.69.61.537.91zm2.446 2.729c-.287.267-.85.143-1.232-.28-.396-.42-.47-.983-.177-1.254.298-.266.844-.14 1.24.28.394.426.472.984.17 1.255zM31.312 98.012c-.37.258-.976.017-1.35-.52-.37-.538-.37-1.183.01-1.44.373-.258.97-.025 1.35.507.368.545.368 1.19-.01 1.452zm3.261 3.361c-.33.365-1.036.267-1.552-.23-.527-.487-.674-1.18-.343-1.544.336-.366 1.045-.264 1.564.23.527.486.686 1.18.333 1.543zm4.5 1.951c-.147.473-.825.688-1.51.486-.683-.207-1.13-.76-.99-1.238.14-.477.823-.7 1.512-.485.683.206 1.13.756.988 1.237zm4.943.361c.017.498-.563.91-1.28.92-.723.017-1.308-.387-1.315-.877 0-.503.568-.91 1.29-.924.717-.013 1.306.387 1.306.88zm4.598-.782c.086.485-.413.984-1.126 1.117-.7.13-1.35-.172-1.44-.653-.086-.498.422-.997 1.122-1.126.714-.123 1.354.17 1.444.663zm0 0"
/></g
>
</svg>
{/if}
</div>
<form on:submit|preventDefault={() => handleSubmit(source.id)}>
<button
disabled={source.gitlabApp && !source.gitlabAppId}
type="submit"
class="disabled:opacity-95 bg-coolgray-200 disabled:text-white box-selection hover:bg-orange-700 group"
class:border-red-500={source.gitlabApp && !source.gitlabAppId}
class:border-0={source.gitlabApp && !source.gitlabAppId}
class:border-l-4={source.gitlabApp && !source.gitlabAppId}
>
<div class="font-bold text-xl text-center truncate">{source.name}</div>
{#if source.gitlabApp && !source.gitlabAppId}
<div class="font-bold text-center truncate text-red-500 group-hover:text-white">
Configuration missing
</div>
{/if}
</button>
</form>
</div> </div>
<form on:submit|preventDefault={() => handleSubmit(source.id)}> {/each}
<button </div>
disabled={source.gitlabApp && !source.gitlabAppId}
type="submit"
class="disabled:opacity-95 bg-coolgray-200 disabled:text-white box-selection hover:bg-orange-700 group"
class:border-red-500={source.gitlabApp && !source.gitlabAppId}
class:border-0={source.gitlabApp && !source.gitlabAppId}
class:border-l-4={source.gitlabApp && !source.gitlabAppId}
>
<div class="font-bold text-xl text-center truncate">{source.name}</div>
{#if source.gitlabApp && !source.gitlabAppId}
<div class="font-bold text-center truncate text-red-500 group-hover:text-white">
Configuration missing
</div>
{/if}
</button>
</form>
</div>
{/each}
</div>
{#if otherSources.length > 0 && $appSession.teamId === '0'} {#if otherSources.length > 0 && $appSession.teamId === '0'}
<div class="px-6 pb-5 pt-10 text-xl font-bold">Other Sources</div> <div class="px-6 pb-5 pt-10 text-xl font-bold">Other Sources</div>
{/if}
<div class="flex flex-col flex-wrap justify-center px-2 md:flex-row">
{#each otherSources as source}
<div class="p-2">
<form on:submit|preventDefault={() => handleSubmit(source.id)}>
<button
disabled={source.gitlabApp && !source.gitlabAppId}
type="submit"
class="disabled:opacity-95 bg-coolgray-200 disabled:text-white box-selection hover:bg-orange-700 group"
class:border-red-500={source.gitlabApp && !source.gitlabAppId}
class:border-0={source.gitlabApp && !source.gitlabAppId}
class:border-l-4={source.gitlabApp && !source.gitlabAppId}
>
<div class="font-bold text-xl text-center truncate">{source.name}</div>
{#if source.gitlabApp && !source.gitlabAppId}
<div class="font-bold text-center truncate text-red-500 group-hover:text-white">
{$t('application.configuration.configuration_missing')}
</div>
{/if}
</button>
</form>
</div>
{/each}
</div>
{/if} {/if}
<div class="flex flex-col flex-wrap justify-center px-2 md:flex-row"> </div>
{#each otherSources as source} <div class="title py-4">Public Repository</div>
<div class="p-2">
<form on:submit|preventDefault={() => handleSubmit(source.id)}> <PublicRepository />
<button
disabled={source.gitlabApp && !source.gitlabAppId}
type="submit"
class="disabled:opacity-95 bg-coolgray-200 disabled:text-white box-selection hover:bg-orange-700 group"
class:border-red-500={source.gitlabApp && !source.gitlabAppId}
class:border-0={source.gitlabApp && !source.gitlabAppId}
class:border-l-4={source.gitlabApp && !source.gitlabAppId}
>
<div class="font-bold text-xl text-center truncate">{source.name}</div>
{#if source.gitlabApp && !source.gitlabAppId}
<div class="font-bold text-center truncate text-red-500 group-hover:text-white">
{$t('application.configuration.configuration_missing')}
</div>
{/if}
</button>
</form>
</div>
{/each}
</div>
{/if}
</div> </div>

View File

@@ -133,7 +133,9 @@
autodeploy = !autodeploy; autodeploy = !autodeploy;
} }
if (name === 'isBot') { if (name === 'isBot') {
if ($status.application.isRunning) return;
isBot = !isBot; isBot = !isBot;
application.settings.isBot = isBot;
setLocation(application, settings); setLocation(application, settings);
} }
try { try {
@@ -344,8 +346,11 @@
<label for="gitSource" class="text-base font-bold text-stone-100" <label for="gitSource" class="text-base font-bold text-stone-100"
>{$t('application.git_source')}</label >{$t('application.git_source')}</label
> >
{#if isDisabled} {#if isDisabled || application.settings.isPublicRepository}
<input disabled={isDisabled} value={application.gitSource.name} /> <input
disabled={isDisabled || application.settings.isPublicRepository}
value={application.gitSource.name}
/>
{:else} {:else}
<a <a
href={`/applications/${id}/configuration/source?from=/applications/${id}`} href={`/applications/${id}/configuration/source?from=/applications/${id}`}
@@ -362,8 +367,11 @@
<label for="repository" class="text-base font-bold text-stone-100" <label for="repository" class="text-base font-bold text-stone-100"
>{$t('application.git_repository')}</label >{$t('application.git_repository')}</label
> >
{#if isDisabled} {#if isDisabled || application.settings.isPublicRepository}
<input disabled={isDisabled} value="{application.repository}/{application.branch}" /> <input
disabled={isDisabled || application.settings.isPublicRepository}
value="{application.repository}/{application.branch}"
/>
{:else} {:else}
<a <a
href={`/applications/${id}/configuration/repository?from=/applications/${id}&to=/applications/${id}/configuration/buildpack`} href={`/applications/${id}/configuration/repository?from=/applications/${id}&to=/applications/${id}/configuration/buildpack`}
@@ -486,7 +494,8 @@
bind:setting={isBot} bind:setting={isBot}
on:click={() => changeSettings('isBot')} on:click={() => changeSettings('isBot')}
title="Is your application a bot?" title="Is your application a bot?"
description="You can deploy applications without domains. <br>They will listen on <span class='text-green-500 font-bold'>IP:PORT</span> instead.<br></Setting><br>Useful for <span class='text-green-500 font-bold'>example bots.</span>" description="You can deploy applications without domains. <br>You can also make them to listen on <span class='text-green-500 font-bold'>IP:EXPOSEDPORT</span> as well.<br></Setting><br>Useful to host <span class='text-green-500 font-bold'>Twitch bots, regular jobs, or anything that does not require an incoming connection.</span>"
disabled={$status.application.isRunning}
/> />
</div> </div>
{#if !isBot} {#if !isBot}
@@ -611,7 +620,7 @@
</div> </div>
{/if} {/if}
{/if} {/if}
{#if !staticDeployments.includes(application.buildPack) && !isBot} {#if !staticDeployments.includes(application.buildPack)}
<div class="grid grid-cols-2 items-center"> <div class="grid grid-cols-2 items-center">
<label for="port" class="text-base font-bold text-stone-100">{$t('forms.port')}</label> <label for="port" class="text-base font-bold text-stone-100">{$t('forms.port')}</label>
<input <input
@@ -622,6 +631,9 @@
bind:value={application.port} bind:value={application.port}
placeholder="{$t('forms.default')}: 'python' ? '8000' : '3000'" placeholder="{$t('forms.default')}: 'python' ? '8000' : '3000'"
/> />
<Explainer
text={'The port your application listens on.'}
/>
</div> </div>
{/if} {/if}
<div class="grid grid-cols-2 items-center"> <div class="grid grid-cols-2 items-center">
@@ -632,7 +644,6 @@
name="exposePort" name="exposePort"
id="exposePort" id="exposePort"
bind:value={application.exposePort} bind:value={application.exposePort}
required={isBot}
placeholder="12345" placeholder="12345"
/> />
<Explainer <Explainer
@@ -769,24 +780,28 @@
<div class="title">{$t('application.features')}</div> <div class="title">{$t('application.features')}</div>
</div> </div>
<div class="px-10 pb-10"> <div class="px-10 pb-10">
<div class="grid grid-cols-2 items-center"> {#if !application.settings.isPublicRepository}
<Setting <div class="grid grid-cols-2 items-center">
isCenter={false} <Setting
bind:setting={autodeploy} isCenter={false}
on:click={() => changeSettings('autodeploy')} bind:setting={autodeploy}
title={$t('application.enable_automatic_deployment')} on:click={() => changeSettings('autodeploy')}
description={$t('application.enable_auto_deploy_webhooks')} title={$t('application.enable_automatic_deployment')}
/> description={$t('application.enable_auto_deploy_webhooks')}
</div> />
<div class="grid grid-cols-2 items-center"> </div>
<Setting {/if}
isCenter={false} {#if !application.settings.isBot}
bind:setting={previews} <div class="grid grid-cols-2 items-center">
on:click={() => changeSettings('previews')} <Setting
title={$t('application.enable_mr_pr_previews')} isCenter={false}
description={$t('application.enable_preview_deploy_mr_pr_requests')} bind:setting={previews}
/> on:click={() => changeSettings('previews')}
</div> title={$t('application.enable_mr_pr_previews')}
description={$t('application.enable_preview_deploy_mr_pr_requests')}
/>
</div>
{/if}
<div class="grid grid-cols-2 items-center"> <div class="grid grid-cols-2 items-center">
<Setting <Setting
isCenter={false} isCenter={false}

View File

@@ -109,7 +109,7 @@
<div class="flex justify-end sticky top-0 p-2 mx-1"> <div class="flex justify-end sticky top-0 p-2 mx-1">
<button <button
on:click={followBuild} on:click={followBuild}
class="bg-transparent btn btn-sm tooltip tooltip-primary tooltip-bottom hover:text-green-500 hover:bg-coolgray-500" class="bg-transparent btn btn-sm btn-link tooltip tooltip-primary tooltip-bottom hover:text-green-500 hover:bg-coolgray-500"
data-tip="Follow logs" data-tip="Follow logs"
class:text-green-500={followingBuild} class:text-green-500={followingBuild}
> >

View File

@@ -147,7 +147,7 @@
<div class="flex justify-end sticky top-0 p-1 mx-1"> <div class="flex justify-end sticky top-0 p-1 mx-1">
<button <button
on:click={followBuild} on:click={followBuild}
class="bg-transparent btn btn-sm tooltip tooltip-primary tooltip-bottom" class="bg-transparent btn btn-sm btn-link tooltip tooltip-primary tooltip-bottom"
data-tip="Follow logs" data-tip="Follow logs"
class:text-green-500={followingLogs} class:text-green-500={followingLogs}
> >

View File

@@ -87,9 +87,7 @@
</div> </div>
<div class="mx-auto max-w-6xl rounded-xl px-6 pt-4"> <div class="mx-auto max-w-6xl rounded-xl px-6 pt-4">
<div class="flex justify-center py-4 text-center">
<Explainer customClass="w-full" text={$t('application.storage.persistent_storage_explainer')} />
</div>
<table class="mx-auto border-separate text-left"> <table class="mx-auto border-separate text-left">
<thead> <thead>
<tr class="h-12"> <tr class="h-12">
@@ -109,4 +107,7 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<div class="flex justify-center py-4 text-center">
<Explainer customClass="w-full" text={$t('application.storage.persistent_storage_explainer')} />
</div>
</div> </div>

View File

@@ -87,6 +87,9 @@
{#if application.fqdn} {#if application.fqdn}
<div class="truncate text-center">{getDomain(application.fqdn) || ''}</div> <div class="truncate text-center">{getDomain(application.fqdn) || ''}</div>
{/if} {/if}
{#if application.settings.isBot}
<div class="truncate text-center">BOT</div>
{/if}
{#if application.destinationDocker?.name} {#if application.destinationDocker?.name}
<div class="truncate text-center">{application.destinationDocker.name}</div> <div class="truncate text-center">{application.destinationDocker.name}</div>
{/if} {/if}
@@ -98,7 +101,7 @@
<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">
Destination Missing Destination Missing
</div> </div>
{:else if !application.fqdn} {:else if !application.fqdn && !application.settings.isBot}
<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">
URL Missing URL Missing
</div> </div>

View File

@@ -20,35 +20,38 @@
</script> </script>
<script lang="ts"> <script lang="ts">
export let applications: any;
export let databases: any;
export let services: any;
export let settings: any;
import { get, post } from '$lib/api'; import { get, post } from '$lib/api';
import Usage from '$lib/components/Usage.svelte'; import Usage from '$lib/components/Usage.svelte';
import { t } from '$lib/translations'; import { t } from '$lib/translations';
import { errorNotification, asyncSleep } from '$lib/common'; import { errorNotification, asyncSleep } from '$lib/common';
import { addToast, appSession } from '$lib/store'; import { addToast, appSession } from '$lib/store';
import ApplicationsIcons from '$lib/components/svg/applications/ApplicationIcons.svelte'; import ApplicationsIcons from '$lib/components/svg/applications/ApplicationIcons.svelte';
import DatabaseIcons from '$lib/components/svg/databases/DatabaseIcons.svelte'; import DatabaseIcons from '$lib/components/svg/databases/DatabaseIcons.svelte';
import ServiceIcons from '$lib/components/svg/services/ServiceIcons.svelte'; import ServiceIcons from '$lib/components/svg/services/ServiceIcons.svelte';
import { dev } from '$app/env';
let loading = { let loading = {
cleanup: false cleanup: false
}; };
export let applications: any; let numberOfGetStatus = 0;
export let databases: any;
export let services: any; function getRndInteger(min: number, max: number) {
let numberOfGetStatus = 0; return Math.floor(Math.random() * (max - min + 1)) + min;
}
function getRndInteger(min: number, max: number) {
return Math.floor(Math.random() * (max - min + 1) ) + min;
}
async function getStatus(resources: any) { async function getStatus(resources: any) {
while (numberOfGetStatus > 1){ while (numberOfGetStatus > 1) {
await asyncSleep(getRndInteger(100,200)); await asyncSleep(getRndInteger(100, 200));
} }
try { try {
numberOfGetStatus++; numberOfGetStatus++;
const { id, buildPack, dualCerts } = resources; const { id, buildPack, dualCerts } = resources;
let isRunning = false; let isRunning = false;
if (buildPack) { if (buildPack) {
@@ -69,8 +72,8 @@
} catch (error) { } catch (error) {
return 'Error'; return 'Error';
} finally { } finally {
numberOfGetStatus--; numberOfGetStatus--;
} }
} }
async function manuallyCleanupStorage() { async function manuallyCleanupStorage() {
try { try {
@@ -98,40 +101,90 @@
<div class="mx-auto px-10"> <div class="mx-auto px-10">
<div class="flex flex-col justify-center xl:flex-row"> <div class="flex flex-col justify-center xl:flex-row">
{#if applications.length > 0} {#if applications.length > 0}
<div> <div>
<div class="title">Resources</div> <div class="title">Resources</div>
<div class="flex items-start justify-center p-8"> <div class="flex items-start justify-center p-8">
<table class="rounded-none text-base"> <table class="rounded-none text-base">
<tbody> <tbody>
{#each applications as application} {#each applications as application}
<tr> <tr>
<td class="space-x-2 items-center tracking-tight font-bold"> <td class="space-x-2 items-center tracking-tight font-bold">
{#await getStatus(application)} {#await getStatus(application)}
<div class="inline-flex w-2 h-2 bg-yellow-500 rounded-full" /> <div class="inline-flex w-2 h-2 bg-yellow-500 rounded-full" />
{:then status} {:then status}
{#if status === 'Running'} {#if status === 'Running'}
<div class="inline-flex w-2 h-2 bg-success rounded-full" /> <div class="inline-flex w-2 h-2 bg-success rounded-full" />
{:else} {:else}
<div class="inline-flex w-2 h-2 bg-error rounded-full" /> <div class="inline-flex w-2 h-2 bg-error rounded-full" />
{/if}
{/await}
<div class="inline-flex">{application.name}</div>
</td>
<td class="px-10 inline-flex">
<ApplicationsIcons {application} isAbsolute={false} />
</td>
<td class="px-10">
<div
class="badge badge-outline text-xs border-applications rounded text-white"
>
Application
{#if application.settings.isBot}
| BOT
{/if}
</div></td
>
<td class="flex justify-end">
{#if application.fqdn}
<a
href={application.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}
{#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} {/if}
{/await}
<div class="inline-flex">{application.name}</div>
</td>
<td class="px-10 inline-flex">
<ApplicationsIcons {application} isAbsolute={false} />
</td>
<td class="px-10">
<div class="badge badge-outline text-xs border-applications rounded text-white">
Application
</div></td
>
<td class="flex justify-end">
{#if application.fqdn}
<a <a
href={application.fqdn} href={`/applications/${application.id}`}
target="_blank"
class="icons bg-transparent text-sm inline-flex" class="icons bg-transparent text-sm inline-flex"
><svg >
<svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6" class="h-6 w-6"
viewBox="0 0 24 24" viewBox="0 0 24 24"
@@ -142,72 +195,72 @@
stroke-linejoin="round" stroke-linejoin="round"
> >
<path stroke="none" d="M0 0h24v24H0z" fill="none" /> <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" /> <rect x="4" y="8" width="4" height="4" />
<line x1="10" y1="14" x2="20" y2="4" /> <line x1="6" y1="4" x2="6" y2="8" />
<polyline points="15 4 20 4 20 9" /> <line x1="6" y1="12" x2="6" y2="20" />
</svg></a <rect x="10" y="14" width="4" height="4" />
> <line x1="12" y1="4" x2="12" y2="14" />
{/if} <line x1="12" y1="18" x2="12" y2="20" />
<a <rect x="16" y="5" width="4" height="4" />
href={`/applications/${application.id}`} <line x1="18" y1="4" x2="18" y2="5" />
class="icons bg-transparent text-sm inline-flex" <line x1="18" y1="9" x2="18" y2="20" />
> </svg>
<svg </a>
xmlns="http://www.w3.org/2000/svg" </td>
class="h-6 w-6" </tr>
viewBox="0 0 24 24" {/each}
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 services as service} {#each services as service}
<tr> <tr>
<td class="space-x-2 items-center tracking-tight font-bold"> <td class="space-x-2 items-center tracking-tight font-bold">
{#await getStatus(service)} {#await getStatus(service)}
<div class="inline-flex w-2 h-2 bg-yellow-500 rounded-full" /> <div class="inline-flex w-2 h-2 bg-yellow-500 rounded-full" />
{:then status} {:then status}
{#if status === 'Running'} {#if status === 'Running'}
<div class="inline-flex w-2 h-2 bg-success rounded-full" /> <div class="inline-flex w-2 h-2 bg-success rounded-full" />
{:else} {:else}
<div class="inline-flex w-2 h-2 bg-error rounded-full" /> <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} {/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 <a
href={service.fqdn} href={`/services/${service.id}`}
target="_blank"
class="icons bg-transparent text-sm inline-flex" class="icons bg-transparent text-sm inline-flex"
><svg >
<svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6" class="h-6 w-6"
viewBox="0 0 24 24" viewBox="0 0 24 24"
@@ -218,97 +271,76 @@
stroke-linejoin="round" stroke-linejoin="round"
> >
<path stroke="none" d="M0 0h24v24H0z" fill="none" /> <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" /> <rect x="4" y="8" width="4" height="4" />
<line x1="10" y1="14" x2="20" y2="4" /> <line x1="6" y1="4" x2="6" y2="8" />
<polyline points="15 4 20 4 20 9" /> <line x1="6" y1="12" x2="6" y2="20" />
</svg></a <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"
> >
{/if} <svg
<a xmlns="http://www.w3.org/2000/svg"
href={`/services/${service.id}`} class="h-6 w-6"
class="icons bg-transparent text-sm inline-flex" viewBox="0 0 24 24"
> stroke-width="1.5"
<svg stroke="currentColor"
xmlns="http://www.w3.org/2000/svg" fill="none"
class="h-6 w-6" stroke-linecap="round"
viewBox="0 0 24 24" stroke-linejoin="round"
stroke-width="1.5" >
stroke="currentColor" <path stroke="none" d="M0 0h24v24H0z" fill="none" />
fill="none" <rect x="4" y="8" width="4" height="4" />
stroke-linecap="round" <line x1="6" y1="4" x2="6" y2="8" />
stroke-linejoin="round" <line x1="6" y1="12" x2="6" y2="20" />
> <rect x="10" y="14" width="4" height="4" />
<path stroke="none" d="M0 0h24v24H0z" fill="none" /> <line x1="12" y1="4" x2="12" y2="14" />
<rect x="4" y="8" width="4" height="4" /> <line x1="12" y1="18" x2="12" y2="20" />
<line x1="6" y1="4" x2="6" y2="8" /> <rect x="16" y="5" width="4" height="4" />
<line x1="6" y1="12" x2="6" y2="20" /> <line x1="18" y1="4" x2="18" y2="5" />
<rect x="10" y="14" width="4" height="4" /> <line x1="18" y1="9" x2="18" y2="20" />
<line x1="12" y1="4" x2="12" y2="14" /> </svg>
<line x1="12" y1="18" x2="12" y2="20" /> </a>
<rect x="16" y="5" width="4" height="4" /> </td>
<line x1="18" y1="4" x2="18" y2="5" /> </tr>
<line x1="18" y1="9" x2="18" y2="20" /> {/each}
</svg> </tbody>
</a> </table>
</td> </div>
</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>
{/if} {/if}
{#if $appSession.teamId === '0'} {#if $appSession.teamId === '0'}
<Usage /> <Usage />

View File

@@ -1,12 +1,14 @@
<script lang="ts"> <script lang="ts">
import CopyPasswordField from '$lib/components/CopyPasswordField.svelte'; import CopyPasswordField from '$lib/components/CopyPasswordField.svelte';
import Explainer from '$lib/components/Explainer.svelte';
import { t } from '$lib/translations'; import { t } from '$lib/translations';
export let readOnly: any; export let readOnly: any;
export let service: any; export let service: any;
</script> </script>
<div class="flex space-x-1 py-5 font-bold"> <div class="flex space-x-1 py-5">
<div class="title">Ghost</div> <div class="title">Ghost</div>
<Explainer text={'You can change these values in the Ghost admin panel.'} />
</div> </div>
<div class="grid grid-cols-2 items-center px-10"> <div class="grid grid-cols-2 items-center px-10">
<label for="email">{$t('forms.default_email_address')}</label> <label for="email">{$t('forms.default_email_address')}</label>

View File

@@ -31,7 +31,7 @@
let dualCerts = settings.dualCerts; let dualCerts = settings.dualCerts;
let isAutoUpdateEnabled = settings.isAutoUpdateEnabled; let isAutoUpdateEnabled = settings.isAutoUpdateEnabled;
let isDNSCheckEnabled = settings.isDNSCheckEnabled; let isDNSCheckEnabled = settings.isDNSCheckEnabled;
let DNSServers = settings.DNSServers;
let minPort = settings.minPort; let minPort = settings.minPort;
let maxPort = settings.maxPort; let maxPort = settings.maxPort;
@@ -105,6 +105,10 @@
settings.minPort = minPort; settings.minPort = minPort;
settings.maxPort = maxPort; settings.maxPort = maxPort;
} }
if (DNSServers !== settings.DNSServers) {
await post(`/settings`, { DNSServers });
settings.DNSServers = DNSServers;
}
forceSave = false; forceSave = false;
return addToast({ return addToast({
message: 'Configuration saved.', message: 'Configuration saved.',
@@ -275,6 +279,17 @@
on:click={() => changeSettings('isDNSCheckEnabled')} on:click={() => changeSettings('isDNSCheckEnabled')}
/> />
</div> </div>
<div class="grid grid-cols-2 items-center">
<div class="flex-col">
<div class="pt-2 text-base font-bold text-stone-100">
Custom DNS servers
</div>
<Explainer text="You can specify a custom DNS server to verify your domains all over Coolify.<br><br>By default, the OS defined DNS servers are used." />
</div>
<div class="mx-auto flex-row items-center justify-center space-y-2">
<input placeholder="1.1.1.1,8.8.8.8" bind:value={DNSServers} />
</div>
</div>
<div class="grid grid-cols-2 items-center"> <div class="grid grid-cols-2 items-center">
<Setting <Setting
dataTooltip={$t('setting.must_remove_domain_before_changing')} dataTooltip={$t('setting.must_remove_domain_before_changing')}

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.5.0", "version": "3.6.0",
"license": "Apache-2.0", "license": "Apache-2.0",
"repository": "github:coollabsio/coolify", "repository": "github:coollabsio/coolify",
"scripts": { "scripts": {