From 0ea1e718083409322d25145798e1f0f66c67b0b7 Mon Sep 17 00:00:00 2001 From: Gabriel Engel Date: Mon, 7 Nov 2022 18:44:47 -0300 Subject: [PATCH 1/7] Organizing contributing --- CONTRIBUTION.md | 76 ++++++++++++----------------- docs/contribution/GettingStarted.md | 21 ++++++++ docs/dev_setup/Container.md | 10 ++++ docs/dev_setup/DockerContiner.md | 2 + docs/dev_setup/GitPod.md | 19 ++++++++ docs/dev_setup/GithubCodespaces.md | 8 +++ docs/dev_setup/LocalMachine.md | 17 +++++++ docs/dev_setup/Mac.md | 2 + docs/dev_setup/mac_arm.sh | 1 + 9 files changed, 111 insertions(+), 45 deletions(-) create mode 100644 docs/contribution/GettingStarted.md create mode 100644 docs/dev_setup/Container.md create mode 100644 docs/dev_setup/DockerContiner.md create mode 100644 docs/dev_setup/GitPod.md create mode 100644 docs/dev_setup/GithubCodespaces.md create mode 100644 docs/dev_setup/LocalMachine.md create mode 100644 docs/dev_setup/Mac.md create mode 100644 docs/dev_setup/mac_arm.sh diff --git a/CONTRIBUTION.md b/CONTRIBUTION.md index 3825ddaf3..63640d348 100644 --- a/CONTRIBUTION.md +++ b/CONTRIBUTION.md @@ -1,57 +1,43 @@ -# Contribution +# Contributing -First, thanks for considering to contribute to my project. It really means a lot! :) +> "First, thanks for considering to contribute to my project. + It really means a lot! 😁" - [@andrasbacsai](https://github.com/andrasbacsai) -You can ask for guidance anytime on our Discord server in the #contribution channel. +You can ask for guidance anytime on our +[Discord server](https://coollabs.io/discord) in the `#contribution` channel. -## Setup your development environment -### Container based development flow (recommended and the easiest) -All you need is to intall [Docker Engine 20.11+](https://docs.docker.com/engine/install/) on your local machine and run `pnpm dev:container`. It will build the base image for Coolify and start the development server inside Docker. All required ports (3000, 3001) will be exposed to your host. +## 1) Setup your development environment -### Github codespaces +- 🌟 [Container based](docs/dev_setup/Container.md) ← *Recomended* +- 📦 [DockerContainer](docs/dev_setup/DockerContiner.md) *WIP +- 🐙 [Github Codespaces](docs/dev_setup/GithubCodespaces.md) +- ☁️ [GitPod](docs/dev_setup/GitPod.md) +- 🍏 [Local Mac](docs/dev_setup/Mac.md) -If you have github codespaces enabled then you can just create a codespace and run `pnpm dev` to run your the dev environment. All the required dependencies and packages has been configured for you already. +## 2) Basic requirements -### Gitpod -1. Use [container based development flow](#container-based-development-flow-easiest) -2. Or setup your workspace manually: +- [Install Pnpm](https://pnpm.io/installation) -Create a workspace from this repository, run `pnpm install && pnpm db:push && pnpm db:seed` and then `pnpm dev`. All the required dependencies and packages has been configured for you already. +## 3) Setup Coolify -> Some packages, just `pack` are not installed in this way. You cannot test all the features. Please use the [container based development flow](#container-based-development-flow-easiest). +- Copy `apps/api/.env.example` to `apps/api/.env` +- Edit `apps/api/.env`, set the `COOLIFY_APP_ID` environment variable to something cool. +- Run `pnpm install` to install dependencies. +- Run `pnpm db:push` to o create a local SQlite database. This will apply all migrations at `db/dev.db`. +- Run `pnpm db:seed` seed the database. +- Run `pnpm dev` start coding. -### Local Machine -> At the moment, Coolify `doesn't support Windows`. You must use `Linux` or `MacOS` or consider using Gitpod or Github Codespaces. +```sh +# Or... Copy and paste commands bellow: +cp apps/api/.env.example apps/api.env +pnpm install +pnpm db:push +pnpm db:seed +pnpm dev +``` -Install all the prerequisites manually to your host system. If you would not like to install anything, I suggest to use the [container based development flow](#container-based-development-flow-easiest). +## 4) Start Coding -- Due to the lock file, this repository is best with [pnpm](https://pnpm.io). I recommend you try and use `pnpm` because it is cool and efficient! -- You need to have [Docker Engine](https://docs.docker.com/engine/install/) installed locally. -- You need to have [Docker Compose Plugin](https://docs.docker.com/compose/install/compose-plugin/) installed locally. -- You need to have [GIT LFS Support](https://git-lfs.github.com/) installed locally. +You should be able to access `http://localhost:3000`. -Optional: -- To test Heroku buildpacks, you need [pack](https://github.com/buildpacks/pack) binary installed locally. - -### Inside a Docker container -`WIP` - -## Setup Coolify -- Copy `apps/api/.env.template` to `apps/api/.env.template` and set the `COOLIFY_APP_ID` environment variable to something cool. -- `pnpm install` to install dependencies. -- `pnpm db:push` to o create a local SQlite database. - - This will apply all migrations at `db/dev.db`. - -- `pnpm db:seed` seed the database. -- `pnpm dev` start coding. - -## Technical skills required - -- **Languages**: Node.js / Javascript / Typescript -- **Framework JS/TS**: [SvelteKit](https://kit.svelte.dev/) & [Fastify](https://www.fastify.io/) -- **Database ORM**: [Prisma.io](https://www.prisma.io/) -- **Docker Engine API** - -## How to add a new service? -You can find all details [here](https://github.com/coollabsio/coolify-community-templates) \ No newline at end of file +1. Click `Register` and setup your first user. \ No newline at end of file diff --git a/docs/contribution/GettingStarted.md b/docs/contribution/GettingStarted.md new file mode 100644 index 000000000..1c278a6f7 --- /dev/null +++ b/docs/contribution/GettingStarted.md @@ -0,0 +1,21 @@ +## Getting Started + +To contribute to `Coolify` development, you'll benefit from knowing the following: + +- **Languages** + - [Node.js]() - 📚 [Introduction](https://nodejs.dev/en/learn/introduction-to-nodejs/) + - Javascript - 📚 [Learn Javascript](https://learnjavascript.online/) + - Typescript - 📚 [Learn@FreecodeCamp](https://www.freecodecamp.org/news/learn-typescript-beginners-guide/) + +- **Framework JS/TS** + - [SvelteKit](https://kit.svelte.dev/) - 📚 [Tutorial](https://svelte.dev/tutorial/basics) + - [Fastify](https://www.fastify.io/) + +- **Database ORM** + - [Prisma.io](https://www.prisma.io/) - 📚 [Quickstart](https://www.prisma.io/docs/getting-started/quickstart) + +- **Docker** + - [Docker Engine API](https://docs.docker.com/engine/api/) + +## How to add a new service? +You can find all details [here](https://github.com/coollabsio/coolify-community-templates) \ No newline at end of file diff --git a/docs/dev_setup/Container.md b/docs/dev_setup/Container.md new file mode 100644 index 000000000..5d5fe96f2 --- /dev/null +++ b/docs/dev_setup/Container.md @@ -0,0 +1,10 @@ +### Container based development flow (recommended and the easiest) + +All you need is to + +1. Install [Docker Engine 20.11+](https://docs.docker.com/engine/install/) on your local machine +2. Run `pnpm dev:container`. + +It will build the base image for Coolify and start the development server inside Docker. + +All required ports (3000, 3001) will be exposed to your host. \ No newline at end of file diff --git a/docs/dev_setup/DockerContiner.md b/docs/dev_setup/DockerContiner.md new file mode 100644 index 000000000..76dde53d1 --- /dev/null +++ b/docs/dev_setup/DockerContiner.md @@ -0,0 +1,2 @@ +### Inside a Docker container +# `WIP` \ No newline at end of file diff --git a/docs/dev_setup/GitPod.md b/docs/dev_setup/GitPod.md new file mode 100644 index 000000000..3293154f9 --- /dev/null +++ b/docs/dev_setup/GitPod.md @@ -0,0 +1,19 @@ +### Gitpod + +#### Option 1 - Prefered: + +Follow the same steps as [container based development flow](./Container.md) + +#### Option 2 - Manual setup: + +1. Create a workspace from this repository, +1. run `pnpm install && pnpm db:push && pnpm db:seed` +1. and then `pnpm dev`. + +All the required dependencies and packages has been configured for you already. + +--- + +> Some packages, just `pack` are not installed in this way. + You cannot test all the features. + Please use the [container based development flow](./Container.md). \ No newline at end of file diff --git a/docs/dev_setup/GithubCodespaces.md b/docs/dev_setup/GithubCodespaces.md new file mode 100644 index 000000000..64b7c4e9d --- /dev/null +++ b/docs/dev_setup/GithubCodespaces.md @@ -0,0 +1,8 @@ +### Github codespaces + +If you have github codespaces enabled then you can just: + +1. create a codespace and +2. run `pnpm dev` to run your the dev environment. + +All the required dependencies and packages has been configured for you already. \ No newline at end of file diff --git a/docs/dev_setup/LocalMachine.md b/docs/dev_setup/LocalMachine.md new file mode 100644 index 000000000..d902f8871 --- /dev/null +++ b/docs/dev_setup/LocalMachine.md @@ -0,0 +1,17 @@ +### Local Machine + +At the moment, Coolify `doesn't support Windows`. + +You must use `Linux` or `MacOS` or consider using Gitpod or Github Codespaces. + +Install all the prerequisites manually to your host system. +If you would not like to install anything, +I suggest to use the [container based development flow](#container-based-development-flow-easiest). + +- Due to the lock file, this repository is best with [pnpm](https://pnpm.io). I recommend you try and use `pnpm` because it is cool and efficient! +- You need to have [Docker Engine](https://docs.docker.com/engine/install/) installed locally. +- You need to have [Docker Compose Plugin](https://docs.docker.com/compose/install/compose-plugin/) installed locally. +- You need to have [GIT LFS Support](https://git-lfs.github.com/) installed locally. + +Optional: +- To test Heroku buildpacks, you need [pack](https://github.com/buildpacks/pack) binary installed locally. diff --git a/docs/dev_setup/Mac.md b/docs/dev_setup/Mac.md new file mode 100644 index 000000000..5e22c966d --- /dev/null +++ b/docs/dev_setup/Mac.md @@ -0,0 +1,2 @@ +### Mac Setup + diff --git a/docs/dev_setup/mac_arm.sh b/docs/dev_setup/mac_arm.sh new file mode 100644 index 000000000..c63d70b6f --- /dev/null +++ b/docs/dev_setup/mac_arm.sh @@ -0,0 +1 @@ +### Mac Setup \ No newline at end of file From 832107e0b86dfb472c737d4ae85a836eddc1f168 Mon Sep 17 00:00:00 2001 From: Gabriel Engel Date: Mon, 7 Nov 2022 18:56:14 -0300 Subject: [PATCH 2/7] Requirements --- CONTRIBUTION.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CONTRIBUTION.md b/CONTRIBUTION.md index 63640d348..23c09ace5 100644 --- a/CONTRIBUTION.md +++ b/CONTRIBUTION.md @@ -17,6 +17,9 @@ ## 1) Setup your development environment ## 2) Basic requirements - [Install Pnpm](https://pnpm.io/installation) +- [Install Docker Engine](https://docs.docker.com/engine/install/) +- [Setup Docker Compose Plugin](https://docs.docker.com/compose/install/compose-plugin/) +- [Setup GIT LFS Support](https://git-lfs.github.com/) ## 3) Setup Coolify From adf3ef61b82f4f06c1895c8becf5a3da4615e884 Mon Sep 17 00:00:00 2001 From: Gabriel Engel Date: Mon, 7 Nov 2022 18:58:06 -0300 Subject: [PATCH 3/7] Link GettingStarted.md --- CONTRIBUTION.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTION.md b/CONTRIBUTION.md index 23c09ace5..cf691c3c3 100644 --- a/CONTRIBUTION.md +++ b/CONTRIBUTION.md @@ -6,6 +6,8 @@ # Contributing You can ask for guidance anytime on our [Discord server](https://coollabs.io/discord) in the `#contribution` channel. +You'll need a set of skills go [get started](docs/contribution/GettingStarted.md). + ## 1) Setup your development environment - 🌟 [Container based](docs/dev_setup/Container.md) ← *Recomended* From 9ff44ed46b268a4725775dfa5d37ebfcb2b534eb Mon Sep 17 00:00:00 2001 From: Gabriel Engel Date: Mon, 7 Nov 2022 18:58:54 -0300 Subject: [PATCH 4/7] Fix Typo --- CONTRIBUTION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTION.md b/CONTRIBUTION.md index cf691c3c3..886e0e441 100644 --- a/CONTRIBUTION.md +++ b/CONTRIBUTION.md @@ -6,7 +6,7 @@ # Contributing You can ask for guidance anytime on our [Discord server](https://coollabs.io/discord) in the `#contribution` channel. -You'll need a set of skills go [get started](docs/contribution/GettingStarted.md). +You'll need a set of skills to [get started](docs/contribution/GettingStarted.md). ## 1) Setup your development environment From 6d6f2454a770d36dc62c7df1a995e9b387e21131 Mon Sep 17 00:00:00 2001 From: Gabriel Engel Date: Mon, 7 Nov 2022 19:02:59 -0300 Subject: [PATCH 5/7] Link Contribution on Readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 2c106d047..a2fa60c87 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,10 @@ ## Support - Email: [andras@coollabs.io](mailto:andras@coollabs.io) - Discord: [Invitation](https://coollabs.io/discord) +## Development Contributions + +Coolify is developed under the Apache License and you can help to make it grow → [Start coding!](./CONTRIBUTION.md) + ## Financial Contributors Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/coollabsio/contribute)] From 0ebc0217f38b3ed6bc9612ac3f1dd560df6aa5a0 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 8 Nov 2022 14:42:04 +0100 Subject: [PATCH 6/7] fix: umami + ghost issues --- apps/api/src/index.ts | 6 +++ apps/api/src/lib.ts | 54 +++++++++++-------- apps/api/src/lib/common.ts | 2 +- apps/api/src/routes/api/v1/handlers.ts | 9 ---- apps/api/src/routes/api/v1/index.ts | 6 +-- .../src/routes/services/[id]/__layout.svelte | 26 +-------- package.json | 2 +- 7 files changed, 42 insertions(+), 63 deletions(-) diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts index c760116b0..b9d0fb884 100644 --- a/apps/api/src/index.ts +++ b/apps/api/src/index.ts @@ -173,7 +173,13 @@ const host = '0.0.0.0'; // Refresh and check templates setInterval(async () => { await refreshTemplates() + }, 60000) + + setInterval(async () => { await refreshTags() + }, 60000) + + setInterval(async () => { await migrateServicesToNewTemplate() }, 60000) diff --git a/apps/api/src/lib.ts b/apps/api/src/lib.ts index 135ccd255..0d2fdec13 100644 --- a/apps/api/src/lib.ts +++ b/apps/api/src/lib.ts @@ -1,5 +1,5 @@ import cuid from "cuid"; -import { decrypt, encrypt, fixType, generatePassword, getDomain, prisma } from "./lib/common"; +import { decrypt, encrypt, fixType, generatePassword, prisma } from "./lib/common"; import { getTemplates } from "./lib/services"; export async function migrateServicesToNewTemplate() { @@ -253,6 +253,8 @@ async function umami(service: any, template: any) { await migrateSettings(settings, service, template); await migrateSecrets(secrets, service); + await prisma.service.update({ where: { id: service.id }, data: { type: "umami-postgresql" } }) + // Disconnect old service data // await prisma.service.update({ where: { id: service.id }, data: { umami: { disconnect: true } } }) } @@ -440,33 +442,41 @@ async function plausibleAnalytics(service: any, template: any) { async function migrateSettings(settings: any[], service: any, template: any) { for (const setting of settings) { - if (!setting) continue; - let [name, value] = setting.split('@@@') - let minio = name - if (name === 'MINIO_SERVER_URL') { - name = 'coolify_fqdn_minio_console' + try { + if (!setting) continue; + let [name, value] = setting.split('@@@') + let minio = name + if (name === 'MINIO_SERVER_URL') { + name = 'coolify_fqdn_minio_console' + } + if (!value || value === 'null') { + continue; + } + let variableName = template.variables.find((v: any) => v.name === name)?.id + if (!variableName) { + variableName = `$$config_${name.toLowerCase()}` + } + // console.log('Migrating setting', name, value, 'for service', service.id, ', service name:', service.name, 'variableName: ', variableName) + + await prisma.serviceSetting.findFirst({ where: { name: minio, serviceId: service.id } }) || await prisma.serviceSetting.create({ data: { name: minio, value, variableName, service: { connect: { id: service.id } } } }) + } catch(error) { + console.log(error) } - if (!value || value === 'null') { - continue; - } - let variableName = template.variables.find((v: any) => v.name === name)?.id - if (!variableName) { - variableName = `$$config_${name.toLowerCase()}` - } - // console.log('Migrating setting', name, value, 'for service', service.id, ', service name:', service.name, 'variableName: ', variableName) - - await prisma.serviceSetting.findFirst({ where: { name: minio, serviceId: service.id } }) || await prisma.serviceSetting.create({ data: { name: minio, value, variableName, service: { connect: { id: service.id } } } }) } } async function migrateSecrets(secrets: any[], service: any) { for (const secret of secrets) { - if (!secret) continue; - let [name, value] = secret.split('@@@') - if (!value || value === 'null') { - continue + try { + if (!secret) continue; + let [name, value] = secret.split('@@@') + if (!value || value === 'null') { + continue + } + // console.log('Migrating secret', name, value, 'for service', service.id, ', service name:', service.name) + await prisma.serviceSecret.findFirst({ where: { name, serviceId: service.id } }) || await prisma.serviceSecret.create({ data: { name, value, service: { connect: { id: service.id } } } }) + } catch(error) { + console.log(error) } - // console.log('Migrating secret', name, value, 'for service', service.id, ', service name:', service.name) - await prisma.serviceSecret.findFirst({ where: { name, serviceId: service.id } }) || await prisma.serviceSecret.create({ data: { name, value, service: { connect: { id: service.id } } } }) } } async function createVolumes(service: any, template: any) { diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.ts index bef6a6c43..d0e296ce6 100644 --- a/apps/api/src/lib/common.ts +++ b/apps/api/src/lib/common.ts @@ -17,7 +17,7 @@ import { day } from './dayjs'; import { saveBuildLog } from './buildPacks/common'; import { scheduler } from './scheduler'; -export const version = '3.11.1'; +export const version = '3.11.2'; export const isDev = process.env.NODE_ENV === 'development'; const algorithm = 'aes-256-ctr'; diff --git a/apps/api/src/routes/api/v1/handlers.ts b/apps/api/src/routes/api/v1/handlers.ts index eff8532a3..ffd3ddb05 100644 --- a/apps/api/src/routes/api/v1/handlers.ts +++ b/apps/api/src/routes/api/v1/handlers.ts @@ -49,10 +49,6 @@ export async function refreshTags() { } } catch (error) { console.log(error) - throw { - status: 500, - message: 'Could not fetch templates from get.coollabs.io' - }; } return {}; @@ -73,12 +69,7 @@ export async function refreshTemplates() { } } catch (error) { console.log(error) - throw { - status: 500, - message: 'Could not fetch templates from get.coollabs.io' - }; } - return {}; } catch ({ status, message }) { return errorHandler({ status, message }); diff --git a/apps/api/src/routes/api/v1/index.ts b/apps/api/src/routes/api/v1/index.ts index 7f0c6c61c..6ec94e479 100644 --- a/apps/api/src/routes/api/v1/index.ts +++ b/apps/api/src/routes/api/v1/index.ts @@ -1,5 +1,5 @@ import { FastifyPluginAsync } from 'fastify'; -import { checkUpdate, login, showDashboard, update, resetQueue, getCurrentUser, cleanupManually, restartCoolify, refreshTemplates } from './handlers'; +import { checkUpdate, login, showDashboard, update, resetQueue, getCurrentUser, cleanupManually, restartCoolify } from './handlers'; import { GetCurrentUser } from './types'; export interface Update { @@ -52,10 +52,6 @@ const root: FastifyPluginAsync = async (fastify): Promise => { fastify.post('/internal/cleanup', { onRequest: [fastify.authenticate] }, async (request) => await cleanupManually(request)); - - fastify.post('/internal/refreshTemplates', { - onRequest: [fastify.authenticate] - }, async () => await refreshTemplates()); }; export default root; diff --git a/apps/ui/src/routes/services/[id]/__layout.svelte b/apps/ui/src/routes/services/[id]/__layout.svelte index 536b8ab75..788c4dc94 100644 --- a/apps/ui/src/routes/services/[id]/__layout.svelte +++ b/apps/ui/src/routes/services/[id]/__layout.svelte @@ -79,9 +79,7 @@ $isDeploymentEnabled = checkIfDeploymentEnabledServices($appSession.isAdmin, service); let statusInterval: any; - let loading = { - refreshTemplates: false - }; + async function deleteService() { const sure = confirm($t('application.confirm_to_delete', { name: service.name })); @@ -106,20 +104,6 @@ await startService(); } } - async function refreshTemplate() { - try { - loading.refreshTemplates = true; - await post(`/internal/refreshTemplates`, {}); - addToast({ - message: 'Services refreshed.', - type: 'success' - }); - } catch (error) { - return errorNotification(error); - } finally { - loading.refreshTemplates = false; - } - } async function stopService(skip = false) { if (skip) { $status.service.initialLoading = true; @@ -278,14 +262,6 @@ Delete Service {/if} - {#if $page.url.pathname === `/services/${id}/configuration/type` && dev} - - {/if}
Date: Tue, 8 Nov 2022 14:44:54 +0100 Subject: [PATCH 7/7] fix: remove contribution docs --- docs/dev_setup/{mac_arm.sh => MacArm.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/dev_setup/{mac_arm.sh => MacArm.md} (100%) diff --git a/docs/dev_setup/mac_arm.sh b/docs/dev_setup/MacArm.md similarity index 100% rename from docs/dev_setup/mac_arm.sh rename to docs/dev_setup/MacArm.md