From 692665d0da963c4e38e3e7d9584857ff7a63280f Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 16 Aug 2022 14:46:24 +0200 Subject: [PATCH 1/7] fix: dns button ui --- apps/api/src/lib/common.ts | 2 +- apps/ui/src/routes/applications/[id]/index.svelte | 8 ++++---- .../src/routes/services/[id]/_Services/_Services.svelte | 8 ++++---- package.json | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.ts index d67125db3..6d4ea900d 100644 --- a/apps/api/src/lib/common.ts +++ b/apps/api/src/lib/common.ts @@ -17,7 +17,7 @@ import { checkContainer, removeContainer } from './docker'; import { day } from './dayjs'; import * as serviceFields from './serviceFields' -export const version = '3.4.0'; +export const version = '3.4.1'; export const isDev = process.env.NODE_ENV === 'development'; const algorithm = 'aes-256-ctr'; diff --git a/apps/ui/src/routes/applications/[id]/index.svelte b/apps/ui/src/routes/applications/[id]/index.svelte index fa9a94375..a0d5c3bd0 100644 --- a/apps/ui/src/routes/applications/[id]/index.svelte +++ b/apps/ui/src/routes/applications/[id]/index.svelte @@ -496,13 +496,13 @@
{#if isNonWWWDomainOK} {:else} @@ -510,14 +510,14 @@ {#if dualCerts} {#if isWWWDomainOK} {:else} {#if isNonWWWDomainOK} {:else} @@ -336,13 +336,13 @@ {#if dualCerts} {#if isWWWDomainOK} {:else} diff --git a/package.json b/package.json index f9ea8e763..02ca63859 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "coolify", "description": "An open-source & self-hostable Heroku / Netlify alternative.", - "version": "3.4.0", + "version": "3.4.1", "license": "Apache-2.0", "repository": "github:coollabsio/coolify", "scripts": { From 9b519361316fd31657c9359121cab09769d29583 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 16 Aug 2022 15:49:33 +0200 Subject: [PATCH 2/7] feat: deploy bots (no domains) --- .../migration.sql | 20 ++ apps/api/prisma/schema.prisma | 1 + apps/api/src/jobs/deployApplication.ts | 1 - apps/api/src/lib/common.ts | 2 +- .../routes/api/v1/applications/handlers.ts | 11 +- .../src/routes/api/v1/applications/types.ts | 2 +- apps/ui/src/lib/locales/en.json | 12 +- apps/ui/src/lib/locales/fr.json | 10 +- .../routes/applications/[id]/__layout.svelte | 32 ++-- .../src/routes/applications/[id]/index.svelte | 181 ++++++++++-------- package.json | 2 +- 11 files changed, 163 insertions(+), 111 deletions(-) create mode 100644 apps/api/prisma/migrations/20220816133447_bot_deployments/migration.sql diff --git a/apps/api/prisma/migrations/20220816133447_bot_deployments/migration.sql b/apps/api/prisma/migrations/20220816133447_bot_deployments/migration.sql new file mode 100644 index 000000000..3d6d92d0e --- /dev/null +++ b/apps/api/prisma/migrations/20220816133447_bot_deployments/migration.sql @@ -0,0 +1,20 @@ +-- RedefineTables +PRAGMA foreign_keys=OFF; +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, + "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", "previews", "updatedAt") SELECT "applicationId", "autodeploy", "createdAt", "debug", "dualCerts", "id", "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; diff --git a/apps/api/prisma/schema.prisma b/apps/api/prisma/schema.prisma index 4877c6ffb..f67424a53 100644 --- a/apps/api/prisma/schema.prisma +++ b/apps/api/prisma/schema.prisma @@ -124,6 +124,7 @@ model ApplicationSettings { debug Boolean @default(false) previews Boolean @default(false) autodeploy Boolean @default(true) + isBot Boolean @default(false) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt application Application @relation(fields: [applicationId], references: [id]) diff --git a/apps/api/src/jobs/deployApplication.ts b/apps/api/src/jobs/deployApplication.ts index ff87ebe7c..a8c46d594 100644 --- a/apps/api/src/jobs/deployApplication.ts +++ b/apps/api/src/jobs/deployApplication.ts @@ -298,7 +298,6 @@ import * as buildpacks from '../lib/buildPacks'; } }; }); - console.log({port}) const composeFile = { version: '3.8', services: { diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.ts index 6d4ea900d..75ad6ff86 100644 --- a/apps/api/src/lib/common.ts +++ b/apps/api/src/lib/common.ts @@ -17,7 +17,7 @@ import { checkContainer, removeContainer } from './docker'; import { day } from './dayjs'; import * as serviceFields from './serviceFields' -export const version = '3.4.1'; +export const version = '3.5.0'; export const isDev = process.env.NODE_ENV === 'development'; const algorithm = 'aes-256-ctr'; diff --git a/apps/api/src/routes/api/v1/applications/handlers.ts b/apps/api/src/routes/api/v1/applications/handlers.ts index b3ef49133..cea2ca294 100644 --- a/apps/api/src/routes/api/v1/applications/handlers.ts +++ b/apps/api/src/routes/api/v1/applications/handlers.ts @@ -5,7 +5,7 @@ import axios from 'axios'; import { FastifyReply } from 'fastify'; import { day } from '../../../../lib/dayjs'; import { setDefaultBaseImage, setDefaultConfiguration } from '../../../../lib/buildPacks/common'; -import { checkDomainsIsValidInDNS, checkDoubleBranch, decrypt, encrypt, errorHandler, executeDockerCmd, generateSshKeyPair, getContainerUsage, getDomain, getFreeExposedPort, isDev, isDomainConfigured, prisma, stopBuild, uniqueName } from '../../../../lib/common'; +import { checkDomainsIsValidInDNS, checkDoubleBranch, 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 { scheduler } from '../../../../lib/scheduler'; @@ -90,10 +90,11 @@ export async function getApplication(request: FastifyRequest) { const { teamId } = request.user const appId = process.env['COOLIFY_APP_ID']; const application: any = await getApplicationFromDB(id, teamId); - + const settings = await listSettings(); return { application, - appId + appId, + settings }; } catch ({ status, message }) { @@ -275,7 +276,7 @@ export async function saveApplication(request: FastifyRequest, export async function saveApplicationSettings(request: FastifyRequest, reply: FastifyReply) { try { const { id } = request.params - const { debug, previews, dualCerts, autodeploy, branch, projectId } = request.body + const { debug, previews, dualCerts, autodeploy, branch, projectId, isBot } = request.body const isDouble = await checkDoubleBranch(branch, projectId); if (isDouble && autodeploy) { await prisma.applicationSettings.updateMany({ where: { application: { branch, projectId } }, data: { autodeploy: false } }) @@ -283,7 +284,7 @@ export async function saveApplicationSettings(request: FastifyRequestUseful for creating staging environments.", - "values_overwriting_app_secrets": "These values overwrite application secrets in PR/MR deployments. Useful for creating staging environments.", + "setup_secret_app_first": "You can add secrets to PR/MR deployments. Please add secrets to the application first.
Useful for creating staging environments.", + "values_overwriting_app_secrets": "These values overwrite application secrets in PR/MR deployments. Useful for creating staging environments.", "redeploy": "Redeploy", "no_previews_available": "No previews available" }, @@ -194,14 +194,14 @@ "application": "Application", "url_fqdn": "URL (FQDN)", "domain_fqdn": "Domain (FQDN)", - "https_explainer": "If you specify https, the application will be accessible only over https. SSL certificate will be generated for you.
If you specify www, the application will be redirected (302) from non-www and vice versa.

To modify the domain, you must first stop the application.

You must set your DNS to point to the server IP in advance.", + "https_explainer": "If you specify https, the application will be accessible only over https. SSL certificate will be generated for you.
If you specify www, the application will be redirected (302) from non-www and vice versa.

To modify the domain, you must first stop the application.

You must set your DNS to point to the server IP in advance.", "ssl_www_and_non_www": "Generate SSL for www and non-www?", - "ssl_explainer": "It will generate certificates for both www and non-www.
You need to have both DNS entries set in advance.

Useful if you expect to have visitors on both.", + "ssl_explainer": "It will generate certificates for both www and non-www.
You need to have both DNS entries set in advance.

Useful if you expect to have visitors on both.", "install_command": "Install Command", "build_command": "Build Command", "start_command": "Start Command", - "directory_to_use_explainer": "Directory to use as the base for all commands.
Could be useful with monorepos.", - "publish_directory_explainer": "Directory containing all the assets for deployment.
For example: dist,_site or public.", + "directory_to_use_explainer": "Directory to use as the base for all commands.
Could be useful with monorepos.", + "publish_directory_explainer": "Directory containing all the assets for deployment.
For example: dist,_site or public.", "features": "Features", "enable_automatic_deployment": "Enable Automatic Deployment", "enable_auto_deploy_webhooks": "Enable automatic deployment through webhooks.", diff --git a/apps/ui/src/lib/locales/fr.json b/apps/ui/src/lib/locales/fr.json index 418f72526..9dc5aa8c4 100644 --- a/apps/ui/src/lib/locales/fr.json +++ b/apps/ui/src/lib/locales/fr.json @@ -65,7 +65,7 @@ "features": "Caractéristiques", "git_repository": "Dépôt Git", "git_source": "Source Git", - "https_explainer": "Si vous spécifiez https, l'application sera accessible uniquement via https. \nUn certificat SSL sera généré pour vous.
Si vous spécifiez www, l'application sera redirigée (302) à partir de non-www et vice versa \n.

Pour modifier le domaine, vous devez d'abord arrêter l'application.

Vous devez configurer, en avance, votre DNS pour pointer vers l'IP du serveur.", + "https_explainer": "Si vous spécifiez https, l'application sera accessible uniquement via https. \nUn certificat SSL sera généré pour vous.
Si vous spécifiez www, l'application sera redirigée (302) à partir de non-www et vice versa \n.

Pour modifier le domaine, vous devez d'abord arrêter l'application.

Vous devez configurer, en avance, votre DNS pour pointer vers l'IP du serveur.", "install_command": "Commande d'installation", "logs": "Journaux des applications", "no_applications_found": "Aucune application trouvée", @@ -78,11 +78,11 @@ "need_during_buildtime": "Besoin pendant la build ?", "no_previews_available": "Aucun aperçu disponible", "redeploy": "Redéployer", - "setup_secret_app_first": "Vous pouvez ajouter des secrets aux déploiements PR/MR. \nVeuillez d'abord ajouter des secrets à l'application. \n
Utile pour créer des environnements de mise en scène.", - "values_overwriting_app_secrets": "Ces valeurs remplacent les secrets d'application dans les déploiements PR/MR. \nUtile pour créer des environnements de mise en scène." + "setup_secret_app_first": "Vous pouvez ajouter des secrets aux déploiements PR/MR. \nVeuillez d'abord ajouter des secrets à l'application. \n
Utile pour créer des environnements de mise en scène.", + "values_overwriting_app_secrets": "Ces valeurs remplacent les secrets d'application dans les déploiements PR/MR. \nUtile pour créer des environnements de mise en scène." }, "previews": "Aperçus", - "publish_directory_explainer": "Répertoire contenant tous les actifs à déployer. \n
Par exemple : dist,_site ou public.", + "publish_directory_explainer": "Répertoire contenant tous les actifs à déployer. \n
Par exemple : dist,_site ou public.", "rebuild_application": "Re-build l'application", "secret": "secrets", "secrets": { @@ -91,7 +91,7 @@ "use_isbuildsecret": "Utiliser isBuildSecret" }, "settings_saved": "Paramètres sauvegardés.", - "ssl_explainer": "Il générera des certificats pour www et non-www. \n
Vous devez avoir les deux entrées DNS définies à l'avance.

Utile si vous prévoyez d'avoir des visiteurs sur les deux.", + "ssl_explainer": "Il générera des certificats pour www et non-www. \n
Vous devez avoir les deux entrées DNS définies à l'avance.

Utile si vous prévoyez d'avoir des visiteurs sur les deux.", "ssl_www_and_non_www": "Générer SSL pour www et non-www ?", "start_command": "Démarrer la commande", "stop_application": "Arrêter l'application", diff --git a/apps/ui/src/routes/applications/[id]/__layout.svelte b/apps/ui/src/routes/applications/[id]/__layout.svelte index 4cb126eda..e5b15bd97 100644 --- a/apps/ui/src/routes/applications/[id]/__layout.svelte +++ b/apps/ui/src/routes/applications/[id]/__layout.svelte @@ -16,7 +16,7 @@ export const load: Load = async ({ fetch, url, params }) => { try { const response = await get(`/applications/${params.id}`); - let { application, appId, settings, isQueueActive } = response; + let { application, appId, settings } = response; if (!application || Object.entries(application).length === 0) { return { status: 302, @@ -36,7 +36,8 @@ return { props: { - application + application, + settings }, stuff: { application, @@ -52,7 +53,7 @@