An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat(layout): added drawer when user is in mobile
Kaname95c942f477ca
diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.tsindex cba9012557..4f4f289175 100644--- a/apps/api/src/lib/common.ts+++ b/apps/api/src/lib/common.ts@@ -1,4 +1,4 @@-import { exec } from 'node:child_process'+import { exec } from 'node:child_process';import util from 'util';import fs from 'fs/promises';import yaml from 'js-yaml';@@ -11,11 +11,11 @@ import { promises as dns } from 'dns';import { PrismaClient } from '@prisma/client';import cuid from 'cuid';import os from 'os';-import sshConfig from 'ssh-config'+import sshConfig from 'ssh-config';import { checkContainer, removeContainer } from './docker';import { day } from './dayjs';-import * as serviceFields from './services/serviceFields'+import * as serviceFields from './services/serviceFields';import { saveBuildLog } from './buildPacks/common';import { scheduler } from './scheduler';import { supportedServiceTypesAndVersions } from './services/supportedVersions';@@ -38,26 +38,28 @@ export const defaultProxyImageHttp = `coolify-haproxy-http-alpine:latest`;export const defaultTraefikImage = `traefik:v2.8`;export function getAPIUrl() {if (process.env.GITPOD_WORKSPACE_URL) {- const { href } = new URL(process.env.GITPOD_WORKSPACE_URL)- const newURL = href.replace('https://', 'https://3001-').replace(/\/$/, '')- return newURL+ const { href } = new URL(process.env.GITPOD_WORKSPACE_URL);+ const newURL = href.replace('https://', 'https://3001-').replace(/\/$/, '');+ return newURL;}if (process.env.CODESANDBOX_HOST) {- return `https://${process.env.CODESANDBOX_HOST.replace(/\$PORT/, '3001')}`+ return `https://${process.env.CODESANDBOX_HOST.replace(/\$PORT/, '3001')}`;}- return isDev ? 'http://localhost:3001' : 'http://localhost:3000';+ return isDev+ ? 'https://kaname-png-coolify-vrgj9w6jq5x2xxxv-3001.githubpreview.dev'+ : 'https://kaname-png-coolify-vrgj9w6jq5x2xxxv-3000.githubpreview.dev';}export function getUIUrl() {if (process.env.GITPOD_WORKSPACE_URL) {- const { href } = new URL(process.env.GITPOD_WORKSPACE_URL)- const newURL = href.replace('https://', 'https://3000-').replace(/\/$/, '')- return newURL+ const { href } = new URL(process.env.GITPOD_WORKSPACE_URL);+ const newURL = href.replace('https://', 'https://3000-').replace(/\/$/, '');+ return newURL;}if (process.env.CODESANDBOX_HOST) {- return `https://${process.env.CODESANDBOX_HOST.replace(/\$PORT/, '3000')}`+ return `https://${process.env.CODESANDBOX_HOST.replace(/\$PORT/, '3000')}`;}- return 'http://localhost:3000';+ return 'https://kaname-png-coolify-vrgj9w6jq5x2xxxv-3000.githubpreview.dev';}const mainTraefikEndpoint = isDev@@ -68,17 +70,30 @@ const otherTraefikEndpoint = isDev? `${getAPIUrl()}/webhooks/traefik/other.json`: 'http://coolify:3000/webhooks/traefik/other.json';-export const uniqueName = (): string => uniqueNamesGenerator(customConfig);export const asyncExecShell = util.promisify(exec);-export const asyncExecShellStream = async ({ debug, buildId, applicationId, command, engine }: { debug: boolean, buildId: string, applicationId: string, command: string, engine: string }) => {+export const asyncExecShellStream = async ({+ debug,+ buildId,+ applicationId,+ command,+ engine+}: {+ debug: boolean;+ buildId: string;+ applicationId: string;+ command: string;+ engine: string;+}) => {return await new Promise(async (resolve, reject) => {- const { execaCommand } = await import('execa')- const subprocess = execaCommand(command, { env: { DOCKER_BUILDKIT: "1", DOCKER_HOST: engine } })+ const { execaCommand } = await import('execa');+ const subprocess = execaCommand(command, {+ env: { DOCKER_BUILDKIT: '1', DOCKER_HOST: engine }+ });if (debug) {subprocess.stdout.on('data', async (data) => {const stdout = data.toString();- const array = stdout.split('\n')+ const array = stdout.split('\n');for (const line of array) {if (line !== '\n' && line !== '') {await saveBuildLog({@@ -88,10 +103,10 @@ export const asyncExecShellStream = async ({ debug, buildId, applicationId, comm});}}- })+ });subprocess.stderr.on('data', async (data) => {const stderr = data.toString();- const array = stderr.split('\n')+ const array = stderr.split('\n');for (const line of array) {if (line !== '\n' && line !== '') {await saveBuildLog({@@ -101,23 +116,23 @@ export const asyncExecShellStream = async ({ debug, buildId, applicationId, comm});}}- })+ });}subprocess.on('exit', async (code) => {await asyncSleep(1000);if (code === 0) {- resolve(code)+ resolve(code);} else {- reject(code)+ reject(code);}- })- })-}+ });+ });+};export const asyncSleep = (delay: number): Promise<unknown> =>new Promise((resolve) => setTimeout(resolve, delay));export const prisma = new PrismaClient({- errorFormat: 'minimal',+ errorFormat: 'minimal'// log: [// {// emit: 'event',@@ -165,10 +180,9 @@ export const decrypt = (hashString: string) => {]);return decrpyted.toString();} catch (error) {- console.log({ decryptionError: error.message })- return hashString+ console.log({ decryptionError: error.message });+ return hashString;}-}};export const encrypt = (text: string) => {@@ -183,8 +197,6 @@ export const encrypt = (text: string) => {}};--export async function checkDoubleBranch(branch: string, projectId: number): Promise<boolean> {const applications = await prisma.application.findMany({ where: { branch, projectId } });return applications.length > 1;@@ -203,7 +215,7 @@ export async function isDNSValid(hostname: any, domain: string): Promise<any> {resolves = await dns.resolve4(hostname);}} catch (error) {- throw 'Invalid DNS.'+ throw 'Invalid DNS.';}try {@@ -218,11 +230,10 @@ export async function isDNSValid(hostname: any, domain: string): Promise<any> {}if (!ipDomainFound) throw false;} catch (error) {- throw 'DNS not set'+ throw 'DNS not set';}}-export function getDomain(domain: string): string {return domain?.replace('https://', '').replace('http://', '');}@@ -248,7 +259,7 @@ export async function isDomainConfigured({],id: { not: id },destinationDocker: {- remoteIpAddress,+ remoteIpAddress}},select: { fqdn: true }@@ -284,7 +295,10 @@ export async function isDomainConfigured({export async function getContainerUsage(dockerId: string, container: string): Promise<any> {try {- const { stdout } = await executeDockerCmd({ dockerId, command: `docker container stats ${container} --no-stream --no-trunc --format "{{json .}}"` })+ const { stdout } = await executeDockerCmd({+ dockerId,+ command: `docker container stats ${container} --no-stream --no-trunc --format "{{json .}}"`+ });return JSON.parse(stdout);} catch (err) {return {@@ -313,7 +327,7 @@ export async function checkDomainsIsValidInDNS({ hostname, fqdn, dualCerts }): Presolves = await dns.resolve4(hostname);}} catch (error) {- throw { status: 500, message: `Could not determine IP address for ${hostname}.` }+ throw { status: 500, message: `Could not determine IP address for ${hostname}.` };}if (dualCerts) {@@ -335,9 +349,15 @@ export async function checkDomainsIsValidInDNS({ hostname, fqdn, dualCerts }): P}}if (ipDomainFound && ipDomainDualCertFound) return { status: 200 };- throw { status: 500, message: `DNS not set correctly or propogated.<br>Please check your DNS settings.` }+ throw {+ status: 500,+ message: `DNS not set correctly or propogated.<br>Please check your DNS settings.`+ };} catch (error) {- throw { status: 500, message: `DNS not set correctly or propogated.<br>Please check your DNS settings.` }+ throw {+ status: 500,+ message: `DNS not set correctly or propogated.<br>Please check your DNS settings.`+ };}} else {try {@@ -349,9 +369,15 @@ export async function checkDomainsIsValidInDNS({ hostname, fqdn, dualCerts }): P}}if (ipDomainFound) return { status: 200 };- throw { status: 500, message: `DNS not set correctly or propogated.<br>Please check your DNS settings.` }+ throw {+ status: 500,+ message: `DNS not set correctly or propogated.<br>Please check your DNS settings.`+ };} catch (error) {- throw { status: 500, message: `DNS not set correctly or propogated.<br>Please check your DNS settings.` }+ throw {+ status: 500,+ message: `DNS not set correctly or propogated.<br>Please check your DNS settings.`+ };}}}@@ -419,63 +445,85 @@ export const supportedDatabaseTypesAndVersions = [export async function getFreeSSHLocalPort(id: string): Promise<number | boolean> {const { default: isReachable } = await import('is-port-reachable');- const { remoteIpAddress, sshLocalPort } = await prisma.destinationDocker.findUnique({ where: { id } })+ const { remoteIpAddress, sshLocalPort } = await prisma.destinationDocker.findUnique({+ where: { id }+ });if (sshLocalPort) {- return Number(sshLocalPort)+ return Number(sshLocalPort);}const data = await prisma.setting.findFirst();const { minPort, maxPort } = data;- const ports = await prisma.destinationDocker.findMany({ where: { sshLocalPort: { not: null }, remoteIpAddress: { not: remoteIpAddress } } })+ const ports = await prisma.destinationDocker.findMany({+ where: { sshLocalPort: { not: null }, remoteIpAddress: { not: remoteIpAddress } }+ });const alreadyConfigured = await prisma.destinationDocker.findFirst({where: {- remoteIpAddress, id: { not: id }, sshLocalPort: { not: null }+ remoteIpAddress,+ id: { not: id },+ sshLocalPort: { not: null }}- })+ });if (alreadyConfigured?.sshLocalPort) {- await prisma.destinationDocker.update({ where: { id }, data: { sshLocalPort: alreadyConfigured.sshLocalPort } })- return Number(alreadyConfigured.sshLocalPort)+ await prisma.destinationDocker.update({+ where: { id },+ data: { sshLocalPort: alreadyConfigured.sshLocalPort }+ });+ return Number(alreadyConfigured.sshLocalPort);}- const range = generateRangeArray(minPort, maxPort)- const availablePorts = range.filter(port => !ports.map(p => p.sshLocalPort).includes(port))+ const range = generateRangeArray(minPort, maxPort);+ const availablePorts = range.filter((port) => !ports.map((p) => p.sshLocalPort).includes(port));for (const port of availablePorts) {- const found = await isReachable(port, { host: 'localhost' })+ const found = await isReachable(port, { host: 'localhost' });if (!found) {- await prisma.destinationDocker.update({ where: { id }, data: { sshLocalPort: Number(port) } })- return Number(port)+ await prisma.destinationDocker.update({+ where: { id },+ data: { sshLocalPort: Number(port) }+ });+ return Number(port);}}- return false+ return false;}export async function createRemoteEngineConfiguration(id: string) {const homedir = os.homedir();- const sshKeyFile = `/tmp/id_rsa-${id}`+ const sshKeyFile = `/tmp/id_rsa-${id}`;const localPort = await getFreeSSHLocalPort(id);- const { sshKey: { privateKey }, remoteIpAddress, remotePort, remoteUser } = await prisma.destinationDocker.findFirst({ where: { id }, include: { sshKey: true } })- await fs.writeFile(sshKeyFile, decrypt(privateKey) + '\n', { encoding: 'utf8', mode: 400 })+ const {+ sshKey: { privateKey },+ remoteIpAddress,+ remotePort,+ remoteUser+ } = await prisma.destinationDocker.findFirst({ where: { id }, include: { sshKey: true } });+ await fs.writeFile(sshKeyFile, decrypt(privateKey) + '\n', { encoding: 'utf8', mode: 400 });// Needed for remote docker compose- const { stdout: numberOfSSHAgentsRunning } = await asyncExecShell(`ps ax | grep [s]sh-agent | grep coolify-ssh-agent.pid | grep -v grep | wc -l`)+ const { stdout: numberOfSSHAgentsRunning } = await asyncExecShell(+ `ps ax | grep [s]sh-agent | grep coolify-ssh-agent.pid | grep -v grep | wc -l`+ );if (numberOfSSHAgentsRunning !== '' && Number(numberOfSSHAgentsRunning.trim()) == 0) {try {- await fs.stat(`/tmp/coolify-ssh-agent.pid`)- await fs.rm(`/tmp/coolify-ssh-agent.pid`)- } catch (error) { }- await asyncExecShell(`eval $(ssh-agent -sa /tmp/coolify-ssh-agent.pid)`)+ await fs.stat(`/tmp/coolify-ssh-agent.pid`);+ await fs.rm(`/tmp/coolify-ssh-agent.pid`);+ } catch (error) {}+ await asyncExecShell(`eval $(ssh-agent -sa /tmp/coolify-ssh-agent.pid)`);}- await asyncExecShell(`SSH_AUTH_SOCK=/tmp/coolify-ssh-agent.pid ssh-add -q ${sshKeyFile}`)+ await asyncExecShell(`SSH_AUTH_SOCK=/tmp/coolify-ssh-agent.pid ssh-add -q ${sshKeyFile}`);- const { stdout: numberOfSSHTunnelsRunning } = await asyncExecShell(`ps ax | grep 'ssh -F /dev/null -o StrictHostKeyChecking no -fNL ${localPort}:localhost:${remotePort}' | grep -v grep | wc -l`)+ const { stdout: numberOfSSHTunnelsRunning } = await asyncExecShell(+ `ps ax | grep 'ssh -F /dev/null -o StrictHostKeyChecking no -fNL ${localPort}:localhost:${remotePort}' | grep -v grep | wc -l`+ );if (numberOfSSHTunnelsRunning !== '' && Number(numberOfSSHTunnelsRunning.trim()) == 0) {try {- await asyncExecShell(`SSH_AUTH_SOCK=/tmp/coolify-ssh-agent.pid ssh -F /dev/null -o "StrictHostKeyChecking no" -fNL ${localPort}:localhost:${remotePort} ${remoteUser}@${remoteIpAddress}`)- } catch (error) { }-+ await asyncExecShell(+ `SSH_AUTH_SOCK=/tmp/coolify-ssh-agent.pid ssh -F /dev/null -o "StrictHostKeyChecking no" -fNL ${localPort}:localhost:${remotePort} ${remoteUser}@${remoteIpAddress}`+ );+ } catch (error) {}}- const config = sshConfig.parse('')- const found = config.find({ Host: remoteIpAddress })+ const config = sshConfig.parse('');+ const found = config.find({ Host: remoteIpAddress });if (!found) {config.append({Host: remoteIpAddress,@@ -484,58 +532,79 @@ export async function createRemoteEngineConfiguration(id: string) {User: remoteUser,IdentityFile: sshKeyFile,StrictHostKeyChecking: 'no'- })+ });}try {- await fs.stat(`${homedir}/.ssh/`)+ await fs.stat(`${homedir}/.ssh/`);} catch (error) {- await fs.mkdir(`${homedir}/.ssh/`)+ await fs.mkdir(`${homedir}/.ssh/`);}- return await fs.writeFile(`${homedir}/.ssh/config`, sshConfig.stringify(config))+ return await fs.writeFile(`${homedir}/.ssh/config`, sshConfig.stringify(config));}-export async function executeDockerCmd({ debug, buildId, applicationId, dockerId, command }: { debug?: boolean, buildId?: string, applicationId?: string, dockerId: string, command: string }): Promise<any> {- let { remoteEngine, remoteIpAddress, engine } = await prisma.destinationDocker.findUnique({ where: { id: dockerId } })+export async function executeDockerCmd({+ debug,+ buildId,+ applicationId,+ dockerId,+ command+}: {+ debug?: boolean;+ buildId?: string;+ applicationId?: string;+ dockerId: string;+ command: string;+}): Promise<any> {+ let { remoteEngine, remoteIpAddress, engine } = await prisma.destinationDocker.findUnique({+ where: { id: dockerId }+ });if (remoteEngine) {- await createRemoteEngineConfiguration(dockerId)- engine = `ssh://${remoteIpAddress}`+ await createRemoteEngineConfiguration(dockerId);+ engine = `ssh://${remoteIpAddress}`;} else {- engine = 'unix:///var/run/docker.sock'+ engine = 'unix:///var/run/docker.sock';}if (process.env.CODESANDBOX_HOST) {if (command.startsWith('docker compose')) {- command = command.replace(/docker compose/gi, 'docker-compose')+ command = command.replace(/docker compose/gi, 'docker-compose');}}if (command.startsWith(`docker build --progress plain`)) {return await asyncExecShellStream({ debug, buildId, applicationId, command, engine });}- return await asyncExecShell(- `DOCKER_BUILDKIT=1 DOCKER_HOST="${engine}" ${command}`- );-+ return await asyncExecShell(`DOCKER_BUILDKIT=1 DOCKER_HOST="${engine}" ${command}`);}export async function startTraefikProxy(id: string): Promise<void> {- const { engine, network, remoteEngine, remoteIpAddress } = await prisma.destinationDocker.findUnique({ where: { id } })+ const { engine, network, remoteEngine, remoteIpAddress } =+ await prisma.destinationDocker.findUnique({ where: { id } });const found = await checkContainer({ dockerId: id, container: 'coolify-proxy', remove: true });const { id: settingsId, ipv4, ipv6 } = await listSettings();if (!found) {- const { stdout: coolifyNetwork } = await executeDockerCmd({ dockerId: id, command: `docker network ls --filter 'name=coolify-infra' --no-trunc --format "{{json .}}"` })+ const { stdout: coolifyNetwork } = await executeDockerCmd({+ dockerId: id,+ command: `docker network ls --filter 'name=coolify-infra' --no-trunc --format "{{json .}}"`+ });if (!coolifyNetwork) {- await executeDockerCmd({ dockerId: id, command: `docker network create --attachable coolify-infra` })+ await executeDockerCmd({+ dockerId: id,+ command: `docker network create --attachable coolify-infra`+ });}- const { stdout: Config } = await executeDockerCmd({ dockerId: id, command: `docker network inspect ${network} --format '{{json .IPAM.Config }}'` })+ const { stdout: Config } = await executeDockerCmd({+ dockerId: id,+ command: `docker network inspect ${network} --format '{{json .IPAM.Config }}'`+ });const ip = JSON.parse(Config)[0].Gateway;- let traefikUrl = mainTraefikEndpoint+ let traefikUrl = mainTraefikEndpoint;if (remoteEngine) {- let ip = null+ let ip = null;if (isDev) {- ip = getAPIUrl()+ ip = getAPIUrl();} else {- ip = `http://${ipv4 || ipv6}:3000`+ ip = `http://${ipv4 || ipv6}:3000`;}- traefikUrl = `${ip}/webhooks/traefik/remote/${id}`+ traefikUrl = `${ip}/webhooks/traefik/remote/${id}`;}await executeDockerCmd({dockerId: id,@@ -561,7 +630,7 @@ export async function startTraefikProxy(id: string): Promise<void> {--certificatesresolvers.letsencrypt.acme.storage=/etc/traefik/acme/acme.json \--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web \--log.level=error`- })+ });await prisma.setting.update({ where: { id: settingsId }, data: { proxyHash: null } });await prisma.destinationDocker.update({where: { id },@@ -585,15 +654,17 @@ export async function startTraefikProxy(id: string): Promise<void> {}export async function configureNetworkTraefikProxy(destination: any): Promise<void> {- const { id } = destination+ const { id } = destination;const { stdout: networks } = await executeDockerCmd({dockerId: id,- command:- `docker ps -a --filter name=coolify-proxy --format '{{json .Networks}}'`+ command: `docker ps -a --filter name=coolify-proxy --format '{{json .Networks}}'`});const configuredNetworks = networks.replace(/"/g, '').replace('\n', '').split(',');if (!configuredNetworks.includes(destination.network)) {- await executeDockerCmd({ dockerId: destination.id, command: `docker network connect ${destination.network} coolify-proxy` })+ await executeDockerCmd({+ dockerId: destination.id,+ command: `docker network connect ${destination.network} coolify-proxy`+ });}}@@ -611,10 +682,8 @@ export async function stopTraefikProxy(if (found) {await executeDockerCmd({dockerId: id,- command:- `docker stop -t 0 coolify-proxy && docker rm coolify-proxy`+ command: `docker stop -t 0 coolify-proxy && docker rm coolify-proxy`});-}} catch (error) {return error;@@ -627,10 +696,13 @@ export async function listSettings(): Promise<any> {return settings;}--export function generatePassword({ length = 24, symbols = false, isHex = false }: { length?: number, symbols?: boolean, isHex?: boolean } | null): string {+export function generatePassword({+ length = 24,+ symbols = false,+ isHex = false+}: { length?: number; symbols?: boolean; isHex?: boolean } | null): string {if (isHex) {- return crypto.randomBytes(length).toString("hex");+ return crypto.randomBytes(length).toString('hex');}const password = generator.generate({length,@@ -642,95 +714,98 @@ export function generatePassword({ length = 24, symbols = false, isHex = false }return password;}-export function generateDatabaseConfiguration(database: any, arch: string):+export function generateDatabaseConfiguration(+ database: any,+ arch: string+):| {- volume: string;- image: string;- command?: string;- ulimits: Record<string, unknown>;- privatePort: number;- environmentVariables: {- MYSQL_DATABASE: string;- MYSQL_PASSWORD: string;- MYSQL_ROOT_USER: string;- MYSQL_USER: string;- MYSQL_ROOT_PASSWORD: string;- };- }+ volume: string;+ image: string;+ command?: string;+ ulimits: Record<string, unknown>;+ privatePort: number;+ environmentVariables: {+ MYSQL_DATABASE: string;+ MYSQL_PASSWORD: string;+ MYSQL_ROOT_USER: string;+ MYSQL_USER: string;+ MYSQL_ROOT_PASSWORD: string;+ };+ }| {- volume: string;- image: string;- command?: string;- ulimits: Record<string, unknown>;- privatePort: number;- environmentVariables: {- MONGO_INITDB_ROOT_USERNAME?: string;- MONGO_INITDB_ROOT_PASSWORD?: string;- MONGODB_ROOT_USER?: string;- MONGODB_ROOT_PASSWORD?: string;- };- }+ volume: string;+ image: string;+ command?: string;+ ulimits: Record<string, unknown>;+ privatePort: number;+ environmentVariables: {+ MONGO_INITDB_ROOT_USERNAME?: string;+ MONGO_INITDB_ROOT_PASSWORD?: string;+ MONGODB_ROOT_USER?: string;+ MONGODB_ROOT_PASSWORD?: string;+ };+ }| {- volume: string;- image: string;- command?: string;- ulimits: Record<string, unknown>;- privatePort: number;- environmentVariables: {- MARIADB_ROOT_USER: string;- MARIADB_ROOT_PASSWORD: string;- MARIADB_USER: string;- MARIADB_PASSWORD: string;- MARIADB_DATABASE: string;- };- }+ volume: string;+ image: string;+ command?: string;+ ulimits: Record<string, unknown>;+ privatePort: number;+ environmentVariables: {+ MARIADB_ROOT_USER: string;+ MARIADB_ROOT_PASSWORD: string;+ MARIADB_USER: string;+ MARIADB_PASSWORD: string;+ MARIADB_DATABASE: string;+ };+ }| {- volume: string;- image: string;- command?: string;- ulimits: Record<string, unknown>;- privatePort: number;- environmentVariables: {- POSTGRESQL_POSTGRES_PASSWORD: string;- POSTGRESQL_USERNAME: string;- POSTGRESQL_PASSWORD: string;- POSTGRESQL_DATABASE: string;- };- }+ volume: string;+ image: string;+ command?: string;+ ulimits: Record<string, unknown>;+ privatePort: number;+ environmentVariables: {+ POSTGRESQL_POSTGRES_PASSWORD: string;+ POSTGRESQL_USERNAME: string;+ POSTGRESQL_PASSWORD: string;+ POSTGRESQL_DATABASE: string;+ };+ }| {- volume: string;- image: string;- command?: string;- ulimits: Record<string, unknown>;- privatePort: number;- environmentVariables: {- POSTGRES_USER: string;- POSTGRES_PASSWORD: string;- POSTGRES_DB: string;- };- }+ volume: string;+ image: string;+ command?: string;+ ulimits: Record<string, unknown>;+ privatePort: number;+ environmentVariables: {+ POSTGRES_USER: string;+ POSTGRES_PASSWORD: string;+ POSTGRES_DB: string;+ };+ }| {- volume: string;- image: string;- command?: string;- ulimits: Record<string, unknown>;- privatePort: number;- environmentVariables: {- REDIS_AOF_ENABLED: string;- REDIS_PASSWORD: string;- };- }+ volume: string;+ image: string;+ command?: string;+ ulimits: Record<string, unknown>;+ privatePort: number;+ environmentVariables: {+ REDIS_AOF_ENABLED: string;+ REDIS_PASSWORD: string;+ };+ }| {- volume: string;- image: string;- command?: string;- ulimits: Record<string, unknown>;- privatePort: number;- environmentVariables: {- COUCHDB_PASSWORD: string;- COUCHDB_USER: string;- };- } {+ volume: string;+ image: string;+ command?: string;+ ulimits: Record<string, unknown>;+ privatePort: number;+ environmentVariables: {+ COUCHDB_PASSWORD: string;+ COUCHDB_USER: string;+ };+ } {const {id,dbUser,@@ -756,11 +831,11 @@ export function generateDatabaseConfiguration(database: any, arch: string):image: `${baseImage}:${version}`,volume: `${id}-${type}-data:/bitnami/mysql/data`,ulimits: {}- }+ };if (isARM(arch)) {configuration.volume = `${id}-${type}-data:/var/lib/mysql`;}- return configuration+ return configuration;} else if (type === 'mariadb') {const configuration = {privatePort: 3306,@@ -778,7 +853,7 @@ export function generateDatabaseConfiguration(database: any, arch: string):if (isARM(arch)) {configuration.volume = `${id}-${type}-data:/var/lib/mysql`;}- return configuration+ return configuration;} else if (type === 'mongodb') {const configuration = {privatePort: 27017,@@ -794,10 +869,10 @@ export function generateDatabaseConfiguration(database: any, arch: string):configuration.environmentVariables = {MONGO_INITDB_ROOT_USERNAME: rootUser,MONGO_INITDB_ROOT_PASSWORD: rootUserPassword- }+ };configuration.volume = `${id}-${type}-data:/data/db`;}- return configuration+ return configuration;} else if (type === 'postgresql') {const configuration = {privatePort: 5432,@@ -810,16 +885,16 @@ export function generateDatabaseConfiguration(database: any, arch: string):image: `${baseImage}:${version}`,volume: `${id}-${type}-data:/bitnami/postgresql`,ulimits: {}- }+ };if (isARM(arch)) {configuration.volume = `${id}-${type}-data:/var/lib/postgresql`;configuration.environmentVariables = {POSTGRES_PASSWORD: dbUserPassword,POSTGRES_USER: dbUser,POSTGRES_DB: defaultDatabase- }+ };}- return configuration+ return configuration;} else if (type === 'redis') {const configuration = {privatePort: 6379,@@ -834,9 +909,11 @@ export function generateDatabaseConfiguration(database: any, arch: string):};if (isARM(arch)) {configuration.volume = `${id}-${type}-data:/data`;- configuration.command = `/usr/local/bin/redis-server --appendonly ${appendOnly ? 'yes' : 'no'} --requirepass ${dbUserPassword}`;+ configuration.command = `/usr/local/bin/redis-server --appendonly ${+ appendOnly ? 'yes' : 'no'+ } --requirepass ${dbUserPassword}`;}- return configuration+ return configuration;} else if (type === 'couchdb') {const configuration = {privatePort: 5984,@@ -851,20 +928,20 @@ export function generateDatabaseConfiguration(database: any, arch: string):if (isARM(arch)) {configuration.volume = `${id}-${type}-data:/opt/couchdb/data`;}- return configuration+ return configuration;}}export function isARM(arch: string) {if (arch === 'arm' || arch === 'arm64') {- return true+ return true;}- return false+ return false;}export function getDatabaseImage(type: string, arch: string): string {const found = supportedDatabaseTypesAndVersions.find((t) => t.name === type);if (found) {if (isARM(arch)) {- return found.baseImageARM || found.baseImage+ return found.baseImageARM || found.baseImage;}return found.baseImage;}@@ -875,14 +952,13 @@ export function getDatabaseVersions(type: string, arch: string): string[] {const found = supportedDatabaseTypesAndVersions.find((t) => t.name === type);if (found) {if (isARM(arch)) {- return found.versionsARM || found.versions+ return found.versionsARM || found.versions;}return found.versions;}return [];}-export type ComposeFile = {version: ComposerFileVersion;services: Record<string, ComposeFileService>;@@ -904,11 +980,13 @@ export type ComposeFileService = {depends_on?: string[];command?: string;ports?: string[];- build?: {- context: string;- dockerfile: string;- args?: Record<string, unknown>;- } | string;+ build?:+ | {+ context: string;+ dockerfile: string;+ args?: Record<string, unknown>;+ }+ | string;deploy?: {restart_policy?: {condition?: string;@@ -977,7 +1055,7 @@ export const createDirectories = async ({let workdirFound = false;try {workdirFound = !!(await fs.stat(workdir));- } catch (error) { }+ } catch (error) {}if (workdirFound) {await asyncExecShell(`rm -fr ${workdir}`);}@@ -988,10 +1066,7 @@ export const createDirectories = async ({};};--export async function stopDatabaseContainer(- database: any-): Promise<boolean> {+export async function stopDatabaseContainer(database: any): Promise<boolean> {let everStarted = false;const {id,@@ -1000,7 +1075,10 @@ export async function stopDatabaseContainer(} = database;if (destinationDockerId) {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}`+ });if (stdout) {everStarted = true;@@ -1013,7 +1091,6 @@ export async function stopDatabaseContainer(return everStarted;}-export async function stopTcpHttpProxy(id: string,destinationDocker: any,@@ -1028,17 +1105,14 @@ export async function stopTcpHttpProxy(if (found) {return await executeDockerCmd({dockerId,- command:- `docker stop -t 0 ${container} && docker rm ${container}`+ command: `docker stop -t 0 ${container} && docker rm ${container}`});-}} catch (error) {return error;}}-export async function updatePasswordInDb(database, user, newPassword, isRoot) {const {id,@@ -1056,55 +1130,64 @@ export async function updatePasswordInDb(database, user, newPassword, isRoot) {await executeDockerCmd({dockerId,command: `docker exec ${id} mysql -u ${rootUser} -p${rootUserPassword} -e \"ALTER USER '${user}'@'%' IDENTIFIED WITH caching_sha2_password BY '${newPassword}';\"`- })+ });} else if (type === 'mariadb') {await executeDockerCmd({dockerId,command: `docker exec ${id} mysql -u ${rootUser} -p${rootUserPassword} -e \"SET PASSWORD FOR '${user}'@'%' = PASSWORD('${newPassword}');\"`- })-+ });} else if (type === 'postgresql') {if (isRoot) {await executeDockerCmd({dockerId,command: `docker exec ${id} psql postgresql://postgres:${rootUserPassword}@${id}:5432/${defaultDatabase} -c "ALTER role postgres WITH PASSWORD '${newPassword}'"`- })+ });} else {await executeDockerCmd({dockerId,command: `docker exec ${id} psql postgresql://${dbUser}:${dbUserPassword}@${id}:5432/${defaultDatabase} -c "ALTER role ${user} WITH PASSWORD '${newPassword}'"`- })+ });}} else if (type === 'mongodb') {await executeDockerCmd({dockerId,command: `docker exec ${id} mongo 'mongodb://${rootUser}:${rootUserPassword}@${id}:27017/admin?readPreference=primary&ssl=false' --eval "db.changeUserPassword('${user}','${newPassword}')"`- })-+ });} else if (type === 'redis') {await executeDockerCmd({dockerId,command: `docker exec ${id} redis-cli -u redis://${dbUserPassword}@${id}:6379 --raw CONFIG SET requirepass ${newPassword}`- })-+ });}}}-export async function checkExposedPort({ id, configuredPort, exposePort, dockerId, remoteIpAddress }: { id: string, configuredPort?: number, exposePort: number, dockerId: string, remoteIpAddress?: string }) {+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.` }+ 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.` }+ 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.` }+ throw { status: 500, message: `Port ${exposePort} is already in use.` };}}}@@ -1124,17 +1207,16 @@ export async function getFreeExposedPort(id, exposePort, dockerId, remoteIpAddre).map((a) => a.exposePort);const usedPorts = [...applicationUsed, ...serviceUsed];if (usedPorts.includes(exposePort)) {- return false+ return false;}const found = await checkPort(exposePort, { host: remoteIpAddress || 'localhost' });if (!found) {- return exposePort+ return exposePort;}- return false-+ return false;}export function generateRangeArray(start, end) {- return Array.from({ length: (end - start) }, (v, k) => k + start);+ return Array.from({ length: end - start }, (v, k) => k + start);}export async function getFreePublicPort(id, dockerId) {const { default: isReachable } = await import('is-port-reachable');@@ -1148,32 +1230,44 @@ export async function getFreePublicPort(id, dockerId) {).map((a) => a.publicPort);const wpFtpUsed = await (await prisma.wordpress.findMany({- where: { ftpPublicPort: { not: null }, id: { not: id }, service: { destinationDockerId: dockerId } },+ where: {+ ftpPublicPort: { not: null },+ id: { not: id },+ service: { destinationDockerId: dockerId }+ },select: { ftpPublicPort: true }})).map((a) => a.ftpPublicPort);const wpUsed = await (await prisma.wordpress.findMany({- where: { mysqlPublicPort: { not: null }, id: { not: id }, service: { destinationDockerId: dockerId } },+ where: {+ mysqlPublicPort: { not: null },+ id: { not: id },+ service: { destinationDockerId: dockerId }+ },select: { mysqlPublicPort: true }})).map((a) => a.mysqlPublicPort);const minioUsed = await (await prisma.minio.findMany({- where: { publicPort: { not: null }, id: { not: id }, service: { destinationDockerId: dockerId } },+ where: {+ publicPort: { not: null },+ id: { not: id },+ service: { destinationDockerId: dockerId }+ },select: { publicPort: true }})).map((a) => a.publicPort);const usedPorts = [...dbUsed, ...wpFtpUsed, ...wpUsed, ...minioUsed];- const range = generateRangeArray(minPort, maxPort)- const availablePorts = range.filter(port => !usedPorts.includes(port))+ const range = generateRangeArray(minPort, maxPort);+ const availablePorts = range.filter((port) => !usedPorts.includes(port));for (const port of availablePorts) {- const found = await isReachable(port, { host: 'localhost' })+ const found = await isReachable(port, { host: 'localhost' });if (!found) {- return port+ return port;}}- return false+ return false;}export async function startTraefikTCPProxy(@@ -1190,24 +1284,28 @@ export async function startTraefikTCPProxy(let dependentId = id;if (type === 'wordpressftp') dependentId = `${id}-ftp`;- const foundDependentContainer = await checkContainer({ dockerId, container: dependentId, remove: true });+ const foundDependentContainer = await checkContainer({+ dockerId,+ container: dependentId,+ remove: true+ });try {if (foundDependentContainer && !found) {const { stdout: Config } = await executeDockerCmd({dockerId,command: `docker network inspect ${network} --format '{{json .IPAM.Config }}'`- })+ });const ip = JSON.parse(Config)[0].Gateway;- let traefikUrl = otherTraefikEndpoint+ let traefikUrl = otherTraefikEndpoint;if (remoteEngine) {- let ip = null+ let ip = null;if (isDev) {- ip = getAPIUrl()+ ip = getAPIUrl();} else {- ip = `http://${ipv4 || ipv6}:3000`+ ip = `http://${ipv4 || ipv6}:3000`;}- traefikUrl = `${ip}/webhooks/traefik/other.json`+ traefikUrl = `${ip}/webhooks/traefik/other.json`;}const tcpProxy = {version: '3.8',@@ -1243,28 +1341,34 @@ export async function startTraefikTCPProxy(await executeDockerCmd({dockerId,command: `docker compose -f /tmp/docker-compose-${id}.yaml up -d`- })+ });await fs.rm(`/tmp/docker-compose-${id}.yaml`);}if (!foundDependentContainer && found) {await executeDockerCmd({dockerId,command: `docker stop -t 0 ${container} && docker rm ${container}`- })+ });}} catch (error) {return error;}}-export async function getServiceFromDB({ id, teamId }: { id: string; teamId: string }): Promise<any> {+export async function getServiceFromDB({+ id,+ teamId+}: {+ id: string;+ teamId: string;+}): Promise<any> {const settings = await prisma.setting.findFirst();const body = await prisma.service.findFirst({where: { id, teams: { some: { id: teamId === '0' ? undefined : teamId } } },include: includeServices});- let { type } = body- type = fixType(type)+ let { type } = body;+ type = fixType(type);if (body?.serviceSecret.length > 0) {body.serviceSecret = body.serviceSecret.map((s) => {@@ -1273,7 +1377,7 @@ export async function getServiceFromDB({ id, teamId }: { id: string; teamId: str});}- body[type] = { ...body[type], ...getUpdateableFields(type, body[type]) }+ body[type] = { ...body[type], ...getUpdateableFields(type, body[type]) };return { ...body, settings };}@@ -1297,52 +1401,52 @@ export function saveUpdateableFields(type: string, data: any) {const update = {};if (type && serviceFields[type]) {serviceFields[type].map((k) => {- let temp = data[k.name]+ let temp = data[k.name];if (temp) {if (k.isEncrypted) {- temp = encrypt(temp)+ temp = encrypt(temp);}if (k.isLowerCase) {- temp = temp.toLowerCase()+ temp = temp.toLowerCase();}if (k.isNumber) {- temp = Number(temp)+ temp = Number(temp);}if (k.isBoolean) {- temp = Boolean(temp)+ temp = Boolean(temp);}}if (k.isNumber && temp === '') {- temp = null+ temp = null;}- update[k.name] = temp+ update[k.name] = temp;});}- return update+ return update;}export function getUpdateableFields(type: string, data: any) {const update = {};if (type && serviceFields[type]) {serviceFields[type].map((k) => {- let temp = data[k.name]+ let temp = data[k.name];if (temp) {if (k.isEncrypted) {- temp = decrypt(temp)+ temp = decrypt(temp);}- update[k.name] = temp+ update[k.name] = temp;}- update[k.name] = temp+ update[k.name] = temp;});}- return update+ return update;}export function fixType(type) {// Hack to fix the type case sensitivity...if (type === 'plausibleanalytics') type = 'plausibleAnalytics';if (type === 'meilisearch') type = 'meiliSearch';- return type+ return type;}export const getServiceMainPort = (service: string) => {@@ -1353,7 +1457,6 @@ export const getServiceMainPort = (service: string) => {return null;};-export function makeLabelForServices(type) {return ['coolify.managed=true',@@ -1362,8 +1465,14 @@ export function makeLabelForServices(type) {`coolify.service.type=${type}`];}-export function errorHandler({ status = 500, message = 'Unknown error.' }: { status: number, message: string | any }) {- if (message.message) message = message.message+export function errorHandler({+ status = 500,+ message = 'Unknown error.'+}: {+ status: number;+ message: string | any;+}) {+ if (message.message) message = message.message;throw { status, message };}export async function generateSshKeyPair(): Promise<{ publicKey: string; privateKey: string }> {@@ -1384,8 +1493,12 @@ export async function generateSshKeyPair(): Promise<{ publicKey: string; privateexport async function stopBuild(buildId, applicationId) {let count = 0;await new Promise<void>(async (resolve, reject) => {- const { destinationDockerId, status } = await prisma.build.findFirst({ where: { id: buildId } });- const { id: dockerId } = await prisma.destinationDocker.findFirst({ where: { id: destinationDockerId } });+ const { destinationDockerId, status } = await prisma.build.findFirst({+ where: { id: buildId }+ });+ const { id: dockerId } = await prisma.destinationDocker.findFirst({+ where: { id: destinationDockerId }+ });const interval = setInterval(async () => {try {if (status === 'failed' || status === 'canceled') {@@ -1395,12 +1508,15 @@ export async function stopBuild(buildId, applicationId) {if (count > 15) {clearInterval(interval);if (scheduler.workers.has('deployApplication')) {- scheduler.workers.get('deployApplication').postMessage('cancel')+ scheduler.workers.get('deployApplication').postMessage('cancel');}await cleanupDB(buildId, applicationId);return reject(new Error('Deployment canceled.'));}- const { stdout: buildContainers } = await executeDockerCmd({ dockerId, command: `docker container ls --filter "label=coolify.buildId=${buildId}" --format '{{json .}}'` })+ const { stdout: buildContainers } = await executeDockerCmd({+ dockerId,+ command: `docker container ls --filter "label=coolify.buildId=${buildId}" --format '{{json .}}'`+ });if (buildContainers) {const containersArray = buildContainers.trim().split('\n');for (const container of containersArray) {@@ -1410,7 +1526,7 @@ export async function stopBuild(buildId, applicationId) {await removeContainer({ id, dockerId });clearInterval(interval);if (scheduler.workers.has('deployApplication')) {- scheduler.workers.get('deployApplication').postMessage('cancel')+ scheduler.workers.get('deployApplication').postMessage('cancel');}await cleanupDB(buildId, applicationId);return resolve();@@ -1418,7 +1534,7 @@ export async function stopBuild(buildId, applicationId) {}}count++;- } catch (error) { }+ } catch (error) {}}, 100);});}@@ -1433,38 +1549,44 @@ async function cleanupDB(buildId: string, applicationId: string) {export function convertTolOldVolumeNames(type) {if (type === 'nocodb') {- return 'nc'+ return 'nc';}}export async function cleanupDockerStorage(dockerId, lowDiskSpace, force) {// Cleanup old coolify imagestry {- let { stdout: images } = await executeDockerCmd({ dockerId, command: `docker images coollabsio/coolify --filter before="coollabsio/coolify:${version}" -q | xargs -r` })+ let { stdout: images } = await executeDockerCmd({+ dockerId,+ command: `docker images coollabsio/coolify --filter before="coollabsio/coolify:${version}" -q | xargs -r`+ });images = images.trim();if (images) {- await executeDockerCmd({ dockerId, command: `docker rmi -f ${images}" -q | xargs -r` })+ await executeDockerCmd({ dockerId, command: `docker rmi -f ${images}" -q | xargs -r` });}- } catch (error) { }+ } catch (error) {}if (lowDiskSpace || force) {if (isDev) {if (!force) console.log(`[DEV MODE] Low disk space: ${lowDiskSpace}`);- return+ return;}try {- await executeDockerCmd({ dockerId, command: `docker container prune -f --filter "label=coolify.managed=true"` })- } catch (error) { }+ await executeDockerCmd({+ dockerId,+ command: `docker container prune -f --filter "label=coolify.managed=true"`+ });+ } catch (error) {}try {- await executeDockerCmd({ dockerId, command: `docker image prune -f` })- } catch (error) { }+ await executeDockerCmd({ dockerId, command: `docker image prune -f` });+ } catch (error) {}try {- await executeDockerCmd({ dockerId, command: `docker image prune -a -f` })- } catch (error) { }+ await executeDockerCmd({ dockerId, command: `docker image prune -a -f` });+ } catch (error) {}// Cleanup build cachestry {- await executeDockerCmd({ dockerId, command: `docker builder prune -a -f` })- } catch (error) { }+ await executeDockerCmd({ dockerId, command: `docker builder prune -a -f` });+ } catch (error) {}}}@@ -1477,7 +1599,6 @@ export function persistentVolumes(id, persistentStorage, config) {volumeSet.add(volume);}}-}}const volumesArray = Array.from(volumeSet);@@ -1486,21 +1607,21 @@ export function persistentVolumes(id, persistentStorage, config) {return `${id}${storage.path.replace(/\//gi, '-')}:${storage.path}`;}) || [];- let volumes = [...persistentVolume]- if (volumesArray) volumes = [...volumesArray, ...volumes]- const composeVolumes = volumes.length > 0 && volumes.map((volume) => {- return {- [`${volume.split(':')[0]}`]: {- name: volume.split(':')[0]- }- };- }) || []+ let volumes = [...persistentVolume];+ if (volumesArray) volumes = [...volumesArray, ...volumes];+ const composeVolumes =+ (volumes.length > 0 &&+ volumes.map((volume) => {+ return {+ [`${volume.split(':')[0]}`]: {+ name: volume.split(':')[0]+ }+ };+ })) ||+ [];- const volumeMounts = Object.assign(- {},- ...composeVolumes- ) || {}- return { volumeMounts }+ const volumeMounts = Object.assign({}, ...composeVolumes) || {};+ return { volumeMounts };}export function defaultComposeConfiguration(network: string): any {return {@@ -1514,25 +1635,29 @@ export function defaultComposeConfiguration(network: string): any {window: '120s'}}- }+ };}export function decryptApplication(application: any) {if (application) {if (application?.gitSource?.githubApp?.clientSecret) {- application.gitSource.githubApp.clientSecret = decrypt(application.gitSource.githubApp.clientSecret) || null;+ application.gitSource.githubApp.clientSecret =+ decrypt(application.gitSource.githubApp.clientSecret) || null;}if (application?.gitSource?.githubApp?.webhookSecret) {- application.gitSource.githubApp.webhookSecret = decrypt(application.gitSource.githubApp.webhookSecret) || null;+ application.gitSource.githubApp.webhookSecret =+ decrypt(application.gitSource.githubApp.webhookSecret) || null;}if (application?.gitSource?.githubApp?.privateKey) {- application.gitSource.githubApp.privateKey = decrypt(application.gitSource.githubApp.privateKey) || null;+ application.gitSource.githubApp.privateKey =+ decrypt(application.gitSource.githubApp.privateKey) || null;}if (application?.gitSource?.gitlabApp?.appSecret) {- application.gitSource.gitlabApp.appSecret = decrypt(application.gitSource.gitlabApp.appSecret) || null;+ application.gitSource.gitlabApp.appSecret =+ decrypt(application.gitSource.gitlabApp.appSecret) || null;}if (application?.secrets.length > 0) {application.secrets = application.secrets.map((s: any) => {- s.value = decrypt(s.value) || null+ s.value = decrypt(s.value) || null;return s;});}diff --git a/apps/ui/src/lib/api.ts b/apps/ui/src/lib/api.tsindex 697a293381..bc7b4d9aca 100644--- a/apps/ui/src/lib/api.ts+++ b/apps/ui/src/lib/api.ts@@ -3,33 +3,35 @@ import Cookies from 'js-cookie';export function getAPIUrl() {if (GITPOD_WORKSPACE_URL) {- const { href } = new URL(GITPOD_WORKSPACE_URL)- const newURL = href.replace('https://', 'https://3001-').replace(/\/$/, '')- return newURL+ const { href } = new URL(GITPOD_WORKSPACE_URL);+ const newURL = href.replace('https://', 'https://3001-').replace(/\/$/, '');+ return newURL;}if (CODESANDBOX_HOST) {- return `https://${CODESANDBOX_HOST.replace(/\$PORT/,'3001')}`+ return `https://${CODESANDBOX_HOST.replace(/\$PORT/, '3001')}`;}- return dev ? 'http://localhost:3001' : 'http://localhost:3000';+ return dev+ ? 'https://kaname-png-coolify-vrgj9w6jq5x2xxxv-3001.githubpreview.dev'+ : 'https://kaname-png-coolify-vrgj9w6jq5x2xxxv-3000.githubpreview.dev';}export function getWebhookUrl(type: string) {if (GITPOD_WORKSPACE_URL) {- const { href } = new URL(GITPOD_WORKSPACE_URL)- const newURL = href.replace('https://', 'https://3001-').replace(/\/$/, '')+ const { href } = new URL(GITPOD_WORKSPACE_URL);+ const newURL = href.replace('https://', 'https://3001-').replace(/\/$/, '');if (type === 'github') {- return `${newURL}/webhooks/github/events`+ return `${newURL}/webhooks/github/events`;}if (type === 'gitlab') {- return `${newURL}/webhooks/gitlab/events`+ return `${newURL}/webhooks/gitlab/events`;}}if (CODESANDBOX_HOST) {- const newURL = `https://${CODESANDBOX_HOST.replace(/\$PORT/,'3001')}`+ const newURL = `https://${CODESANDBOX_HOST.replace(/\$PORT/, '3001')}`;if (type === 'github') {- return `${newURL}/webhooks/github/events`+ return `${newURL}/webhooks/github/events`;}if (type === 'gitlab') {- return `${newURL}/webhooks/gitlab/events`+ return `${newURL}/webhooks/gitlab/events`;}}return `https://webhook.site/0e5beb2c-4e9b-40e2-a89e-32295e570c21/events`;@@ -103,7 +105,11 @@ async function send({return {};}if (!response.ok) {- if (response.status === 401 && !path.startsWith('https://api.github') && !path.includes('/v4/user')) {+ if (+ response.status === 401 &&+ !path.startsWith('https://api.github') &&+ !path.includes('/v4/user')+ ) {Cookies.remove('token');}diff --git a/apps/ui/src/routes/__layout.svelte b/apps/ui/src/routes/__layout.svelteindex 901aedea53..5701cfa21b 100644--- a/apps/ui/src/routes/__layout.svelte+++ b/apps/ui/src/routes/__layout.svelte@@ -120,26 +120,329 @@<PageLoader /></div>{/if}-{#if $appSession.userId}- <nav class="nav-main">- <div class="flex h-screen w-full flex-col items-center transition-all duration-100">- {#if !$appSession.whiteLabeled}- <div class="mb-2 mt-4 h-10 w-10">- <img src="/favicon.png" alt="coolLabs logo" />- </div>- {:else if $appSession.whiteLabeledDetails.icon}- <div class="mb-2 mt-4 h-10 w-10">- <img src={$appSession.whiteLabeledDetails.icon} alt="White labeled logo" />+<div class="drawer">+ <input id="main-drawer" type="checkbox" class="drawer-toggle" />+ <div class="drawer-content">+ {#if $appSession.userId}+ <nav class="nav-main hidden lg:block">+ <div class="flex h-screen w-full flex-col items-center transition-all duration-100">+ {#if !$appSession.whiteLabeled}+ <div class="mb-2 mt-4 h-10 w-10">+ <img src="/favicon.png" alt="coolLabs logo" />+ </div>+ {:else if $appSession.whiteLabeledDetails.icon}+ <div class="mb-2 mt-4 h-10 w-10">+ <img src={$appSession.whiteLabeledDetails.icon} alt="White labeled logo" />+ </div>+ {/if}+ <div class="flex flex-col space-y-2 py-2" class:mt-2={$appSession.whiteLabeled}>+ <a+ id="dashboard"+ sveltekit:prefetch+ href="/"+ class="icons bg-coolgray-200 hover:text-white"+ class:text-white={$page.url.pathname === '/'}+ class:bg-coolgray-500={$page.url.pathname === '/'}+ >+ <svg+ xmlns="http://www.w3.org/2000/svg"+ class="h-9 w-9"+ 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="M19 8.71l-5.333 -4.148a2.666 2.666 0 0 0 -3.274 0l-5.334 4.148a2.665 2.665 0 0 0 -1.029 2.105v7.2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-7.2c0 -.823 -.38 -1.6 -1.03 -2.105"+ />+ <path d="M16 15c-2.21 1.333 -5.792 1.333 -8 0" />+ </svg>+ </a>++ <div class="border-t border-stone-700" />+ <a+ id="applications"+ sveltekit:prefetch+ href="/applications"+ class="icons bg-coolgray-200"+ class:text-applications={$page.url.pathname.startsWith('/applications') ||+ $page.url.pathname.startsWith('/new/application')}+ class:bg-coolgray-500={$page.url.pathname.startsWith('/applications') ||+ $page.url.pathname.startsWith('/new/application')}+ data-tip="Applications"+ >+ <svg+ xmlns="http://www.w3.org/2000/svg"+ class="h-9 w-9"+ 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="4" width="6" height="6" rx="1" />+ <rect x="4" y="14" width="6" height="6" rx="1" />+ <rect x="14" y="14" width="6" height="6" rx="1" />+ <line x1="14" y1="7" x2="20" y2="7" />+ <line x1="17" y1="4" x2="17" y2="10" />+ </svg>+ </a>++ <a+ id="sources"+ sveltekit:prefetch+ href="/sources"+ class="icons bg-coolgray-200"+ class:text-sources={$page.url.pathname.startsWith('/sources') ||+ $page.url.pathname.startsWith('/new/source')}+ class:bg-coolgray-500={$page.url.pathname.startsWith('/sources') ||+ $page.url.pathname.startsWith('/new/source')}+ data-tip="Git Sources"+ >+ <svg+ xmlns="http://www.w3.org/2000/svg"+ class="h-9 w-9"+ 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" />+ <circle cx="6" cy="6" r="2" />+ <circle cx="18" cy="18" r="2" />+ <path d="M11 6h5a2 2 0 0 1 2 2v8" />+ <polyline points="14 9 11 6 14 3" />+ <path d="M13 18h-5a2 2 0 0 1 -2 -2v-8" />+ <polyline points="10 15 13 18 10 21" />+ </svg>+ </a>+ <a+ id="destinations"+ sveltekit:prefetch+ href="/destinations"+ class="icons bg-coolgray-200"+ class:text-destinations={$page.url.pathname.startsWith('/destinations') ||+ $page.url.pathname.startsWith('/new/destination')}+ class:bg-coolgray-500={$page.url.pathname.startsWith('/destinations') ||+ $page.url.pathname.startsWith('/new/destination')}+ data-tip="Destinations"+ >+ <svg+ xmlns="http://www.w3.org/2000/svg"+ class="h-9 w-9"+ 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="M22 12.54c-1.804 -.345 -2.701 -1.08 -3.523 -2.94c-.487 .696 -1.102 1.568 -.92 2.4c.028 .238 -.32 1.002 -.557 1h-14c0 5.208 3.164 7 6.196 7c4.124 .022 7.828 -1.376 9.854 -5c1.146 -.101 2.296 -1.505 2.95 -2.46z"+ />+ <path d="M5 10h3v3h-3z" />+ <path d="M8 10h3v3h-3z" />+ <path d="M11 10h3v3h-3z" />+ <path d="M8 7h3v3h-3z" />+ <path d="M11 7h3v3h-3z" />+ <path d="M11 4h3v3h-3z" />+ <path d="M4.571 18c1.5 0 2.047 -.074 2.958 -.78" />+ <line x1="10" y1="16" x2="10" y2="16.01" />+ </svg>+ </a>+ <div class="border-t border-stone-700" />+ <a+ id="databases"+ sveltekit:prefetch+ href="/databases"+ class="icons bg-coolgray-200"+ class:text-databases={$page.url.pathname.startsWith('/databases') ||+ $page.url.pathname.startsWith('/new/database')}+ class:bg-coolgray-500={$page.url.pathname.startsWith('/databases') ||+ $page.url.pathname.startsWith('/new/database')}+ data-tip="Databases"+ >+ <svg+ xmlns="http://www.w3.org/2000/svg"+ class="h-9 w-9"+ 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" />+ <ellipse cx="12" cy="6" rx="8" ry="3" />+ <path d="M4 6v6a8 3 0 0 0 16 0v-6" />+ <path d="M4 12v6a8 3 0 0 0 16 0v-6" />+ </svg>+ </a>+ <a+ id="services"+ sveltekit:prefetch+ href="/services"+ class="icons bg-coolgray-200"+ class:text-services={$page.url.pathname.startsWith('/services') ||+ $page.url.pathname.startsWith('/new/service')}+ class:bg-coolgray-500={$page.url.pathname.startsWith('/services') ||+ $page.url.pathname.startsWith('/new/service')}+ data-tip="Services"+ >+ <svg+ xmlns="http://www.w3.org/2000/svg"+ class="h-9 w-9"+ 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="M7 18a4.6 4.4 0 0 1 0 -9a5 4.5 0 0 1 11 2h1a3.5 3.5 0 0 1 0 7h-12" />+ </svg>+ </a>+ </div>+ <div class="flex-1" />++ <UpdateAvailable />+ <div class="flex flex-col space-y-2 py-2">+ <a+ id="iam"+ sveltekit:prefetch+ href="/iam"+ class="icons bg-coolgray-200"+ class:text-iam={$page.url.pathname.startsWith('/iam')}+ class:bg-coolgray-500={$page.url.pathname.startsWith('/iam')}+ ><svg+ xmlns="http://www.w3.org/2000/svg"+ viewBox="0 0 24 24"+ class="h-9 w-9"+ stroke-width="1.5"+ stroke="currentColor"+ fill="none"+ stroke-linecap="round"+ stroke-linejoin="round"+ >+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />+ <circle cx="9" cy="7" r="4" />+ <path d="M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2" />+ <path d="M16 3.13a4 4 0 0 1 0 7.75" />+ <path d="M21 21v-2a4 4 0 0 0 -3 -3.85" />+ </svg>+ </a>+ <a+ id="settings"+ sveltekit:prefetch+ href={$appSession.teamId === '0' ? '/settings/global' : '/settings/ssh-keys'}+ class="icons bg-coolgray-200"+ class:text-settings={$page.url.pathname.startsWith('/settings')}+ class:bg-coolgray-500={$page.url.pathname.startsWith('/settings')}+ >+ <svg+ xmlns="http://www.w3.org/2000/svg"+ viewBox="0 0 24 24"+ class="h-9 w-9"+ stroke-width="1.5"+ stroke="currentColor"+ fill="none"+ stroke-linecap="round"+ stroke-linejoin="round"+ >+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />+ <path+ d="M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z"+ />+ <circle cx="12" cy="12" r="3" />+ </svg>+ </a>++ <div id="logout" class="icons bg-coolgray-200 hover:text-error" on:click={logout}>+ <svg+ xmlns="http://www.w3.org/2000/svg"+ class="ml-1 h-8 w-8"+ 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="M14 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2"+ />+ <path d="M7 12h14l-3 -3m0 6l3 -3" />+ </svg>+ </div>+ <div+ class="w-full text-center font-bold text-stone-400 hover:bg-coolgray-200 hover:text-white"+ >+ <a+ class="text-[10px] no-underline"+ href={`https://github.com/coollabsio/coolify/releases/tag/v${$appSession.version}`}+ target="_blank">v{$appSession.version}</a+ >+ </div>+ </div></div>+ </nav>+ {#if $appSession.whiteLabeled}+ <span class="fixed bottom-0 left-[50px] z-50 m-2 px-4 text-xs text-stone-700"+ >Powered by <a href="https://coolify.io" target="_blank">Coolify</a></span+ >{/if}- <div class="flex flex-col space-y-2 py-2" class:mt-2={$appSession.whiteLabeled}>+ {/if}+ <div+ class="navbar bg-neutral lg:hidden space-x-2 flex flex-row items-center"+ class:hidden={!$appSession.userId}+ >+ <label for="main-drawer" class="drawer-button btn btn-square btn-ghost">+ <svg+ xmlns="http://www.w3.org/2000/svg"+ fill="none"+ viewBox="0 0 24 24"+ class="inline-block w-5 h-5 stroke-current"+ ><path+ stroke-linecap="round"+ stroke-linejoin="round"+ stroke-width="2"+ d="M4 6h16M4 12h16M4 18h16"+ /></svg+ >+ </label>+ <div class="prose flex flex-row justify-between space-x-1 w-full items-center pr-3">+ <h3 class="mb-0">Coolify</h3>+ <UpdateAvailable />+ </div>+ </div>+ <main>+ <div class={$appSession.userId ? 'lg:px-20' : null}>+ <slot />+ </div>+ </main>+ </div>+ <div class="drawer-side">+ <label for="main-drawer" class="drawer-overlay w-full" />+ <ul class="menu bg-base-100 w-80 p-2 rounded-r-lg space-y-3">+ <li class="menu-title">+ <span>Main</span>+ </li>+ <li><a- id="dashboard"+ class="no-underline"sveltekit:prefetchhref="/"- class="icons bg-coolgray-200 hover:text-white"- class:text-white={$page.url.pathname === '/'}- class:bg-coolgray-500={$page.url.pathname === '/'}+ class:bg-primary={$page.url.pathname === '/'}><svgxmlns="http://www.w3.org/2000/svg"@@ -157,19 +460,19 @@/><path d="M16 15c-2.21 1.333 -5.792 1.333 -8 0" /></svg>+ Dashboard</a>-- <div class="border-t border-stone-700" />+ </li>+ <li class="menu-title">+ <span>Manage</span>+ </li>+ <li><a- id="applications"+ class="no-underline"sveltekit:prefetchhref="/applications"- class="icons bg-coolgray-200"- class:text-applications={$page.url.pathname.startsWith('/applications') ||+ class:bg-applications={$page.url.pathname.startsWith('/applications') ||$page.url.pathname.startsWith('/new/application')}- class:bg-coolgray-500={$page.url.pathname.startsWith('/applications') ||- $page.url.pathname.startsWith('/new/application')}- data-tip="Applications"><svgxmlns="http://www.w3.org/2000/svg"@@ -188,18 +491,16 @@<line x1="14" y1="7" x2="20" y2="7" /><line x1="17" y1="4" x2="17" y2="10" /></svg>+ Applications</a>-+ </li>+ <li><a- id="sources"+ class="no-underline"sveltekit:prefetchhref="/sources"- class="icons bg-coolgray-200"- class:text-sources={$page.url.pathname.startsWith('/sources') ||+ class:bg-sources={$page.url.pathname.startsWith('/sources') ||$page.url.pathname.startsWith('/new/source')}- class:bg-coolgray-500={$page.url.pathname.startsWith('/sources') ||- $page.url.pathname.startsWith('/new/source')}- data-tip="Git Sources"><svgxmlns="http://www.w3.org/2000/svg"@@ -219,17 +520,16 @@<path d="M13 18h-5a2 2 0 0 1 -2 -2v-8" /><polyline points="10 15 13 18 10 21" /></svg>+ Sources</a>+ </li>+ <li><a- id="destinations"+ class="no-underline"sveltekit:prefetchhref="/destinations"- class="icons bg-coolgray-200"- class:text-destinations={$page.url.pathname.startsWith('/destinations') ||- $page.url.pathname.startsWith('/new/destination')}- class:bg-coolgray-500={$page.url.pathname.startsWith('/destinations') ||+ class:bg-destinations={$page.url.pathname.startsWith('/destinations') ||$page.url.pathname.startsWith('/new/destination')}- data-tip="Destinations"><svgxmlns="http://www.w3.org/2000/svg"@@ -254,18 +554,19 @@<path d="M4.571 18c1.5 0 2.047 -.074 2.958 -.78" /><line x1="10" y1="16" x2="10" y2="16.01" /></svg>+ Destinations</a>- <div class="border-t border-stone-700" />+ </li>+ <li class="menu-title">+ <span>Data</span>+ </li>+ <li><a- id="databases"+ class="no-underline"sveltekit:prefetchhref="/databases"- class="icons bg-coolgray-200"- class:text-databases={$page.url.pathname.startsWith('/databases') ||+ class:bg-databases={$page.url.pathname.startsWith('/databases') ||$page.url.pathname.startsWith('/new/database')}- class:bg-coolgray-500={$page.url.pathname.startsWith('/databases') ||- $page.url.pathname.startsWith('/new/database')}- data-tip="Databases"><svgxmlns="http://www.w3.org/2000/svg"@@ -282,17 +583,15 @@<path d="M4 6v6a8 3 0 0 0 16 0v-6" /><path d="M4 12v6a8 3 0 0 0 16 0v-6" /></svg>+ Databases</a>+ </li>+ <li><a- id="services"- sveltekit:prefetch+ class="no-underline"href="/services"- class="icons bg-coolgray-200"- class:text-services={$page.url.pathname.startsWith('/services') ||- $page.url.pathname.startsWith('/new/service')}- class:bg-coolgray-500={$page.url.pathname.startsWith('/services') ||+ class:bg-services={$page.url.pathname.startsWith('/services') ||$page.url.pathname.startsWith('/new/service')}- data-tip="Services"><svgxmlns="http://www.w3.org/2000/svg"@@ -307,19 +606,14 @@<path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M7 18a4.6 4.4 0 0 1 0 -9a5 4.5 0 0 1 11 2h1a3.5 3.5 0 0 1 0 7h-12" /></svg>+ Services</a>- </div>- <div class="flex-1" />-- <UpdateAvailable />- <div class="flex flex-col space-y-2 py-2">- <a- id="iam"- sveltekit:prefetch- href="/iam"- class="icons bg-coolgray-200"- class:text-iam={$page.url.pathname.startsWith('/iam')}- class:bg-coolgray-500={$page.url.pathname.startsWith('/iam')}+ </li>+ <li class="menu-title">+ <span>Dashboard settings</span>+ </li>+ <li>+ <a class="no-underline" href="/iam" class:bg-iam={$page.url.pathname.startsWith('/iam')}><svgxmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"@@ -336,14 +630,15 @@<path d="M16 3.13a4 4 0 0 1 0 7.75" /><path d="M21 21v-2a4 4 0 0 0 -3 -3.85" /></svg>+ IAM</a>+ </li>+ <li><a- id="settings"- sveltekit:prefetch+ class="no-underline"href={$appSession.teamId === '0' ? '/settings/global' : '/settings/ssh-keys'}- class="icons bg-coolgray-200"- class:text-settings={$page.url.pathname.startsWith('/settings')}- class:bg-coolgray-500={$page.url.pathname.startsWith('/settings')}+ class:bg-settings={$page.url.pathname.startsWith('/settings')}+ class:text-black={$page.url.pathname.startsWith('/settings')}><svgxmlns="http://www.w3.org/2000/svg"@@ -361,13 +656,11 @@/><circle cx="12" cy="12" r="3" /></svg>+ Settings</a>-- <div- id="logout"- class="icons bg-coolgray-200 hover:text-error"- on:click={logout}- >+ </li>+ <li>+ <div class="no-underline hover:bg-error" on:click={logout} class:bg-iam={$page.url.pathname.startsWith('/iam')}><svgxmlns="http://www.w3.org/2000/svg"class="ml-1 h-8 w-8"@@ -384,30 +677,12 @@/><path d="M7 12h14l-3 -3m0 6l3 -3" /></svg>+ Logout</div>- <div- class="w-full text-center font-bold text-stone-400 hover:bg-coolgray-200 hover:text-white"- >- <a- class="text-[10px] no-underline"- href={`https://github.com/coollabsio/coolify/releases/tag/v${$appSession.version}`}- target="_blank">v{$appSession.version}</a- >- </div>- </div>- </div>- </nav>- {#if $appSession.whiteLabeled}- <span class="fixed bottom-0 left-[50px] z-50 m-2 px-4 text-xs text-stone-700"- >Powered by <a href="https://coolify.io" target="_blank">Coolify</a></span- >- {/if}-{/if}-<main>- <div class={$appSession.userId ? 'pl-14 lg:px-20' : null}>- <slot />+ </li>+ </ul></div>-</main>+</div><Tooltip triggeredBy="#dashboard" placement="right">Dashboard</Tooltip><Tooltip triggeredBy="#applications" placement="right" color="bg-applications">Applications</Tooltip