lasthourcloud/CONTRIBUTING.md

118 lines
5.4 KiB
Markdown
Raw Normal View History

2022-03-28 11:26:38 +00:00
# Welcome
2022-04-16 20:28:17 +00:00
First of all, thank you for considering contributing to my project! It means a lot 💜.
2022-03-28 11:26:38 +00:00
# Technical skills required
- Node.js / Javascript
- Svelte / SvelteKit
2022-04-16 20:31:30 +00:00
- Prisma.io / SQL
2022-03-28 11:26:38 +00:00
# Recommended Pull Request Guideline
- Fork the project
- Clone your fork repo to local
- Create a new branch
- Push to your fork repo
2022-03-28 13:04:00 +00:00
- Create a pull request: https://github.com/coollabsio/compare
2022-03-28 11:26:38 +00:00
- Write a proper description
2022-04-07 22:28:10 +00:00
- Open the pull request to review
2022-03-28 11:26:38 +00:00
2022-04-16 20:31:30 +00:00
---
2022-03-28 11:26:38 +00:00
# How to start after you set up your local fork?
2022-04-16 20:28:17 +00:00
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!
2022-03-28 11:26:38 +00:00
You need to have [Docker Engine](https://docs.docker.com/engine/install/) installed locally.
## Setup development environment
- Copy `.env.template` to `.env` and set the `COOLIFY_APP_ID` environment variable to something cool.
- Install dependencies with `pnpm install`.
- Need to create a local SQlite database with `pnpm db:push`.
2022-04-03 17:15:26 +00:00
- This will apply all migrations at `db/dev.db`.
- Seed the database with base entities with `pnpm db:seed`
2022-03-28 11:26:38 +00:00
- You can start coding after starting `pnpm dev`.
## Database migrations
During development, if you change the database layout, you need to run `pnpm db:push` to migrate the database and create types for Prisma. You also need to restart the development process.
If the schema is finalized, you need to create a migration file with `pnpm db:migrate <nameOfMigration>` where `nameOfMigration` is given by you. Make it sense. :)
## Tricky parts
2022-04-16 20:28:17 +00:00
- BullMQ, the queue system Coolify uses, cannot be hot reloaded. So if you change anything in the files related to it, you need to restart the development process. I'm actively looking for a different queue/scheduler library. I'm open to discussion!
2022-04-16 20:16:47 +00:00
2022-04-16 20:19:41 +00:00
---
2022-04-16 20:31:30 +00:00
# How to add new services
2022-04-16 20:16:47 +00:00
2022-04-16 20:28:17 +00:00
You can add any open-source and self-hostable software (service/application) to Coolify if the following statements are true:
2022-04-16 20:16:47 +00:00
- Self-hostable (obviously)
- Open-source
2022-04-16 20:28:17 +00:00
- Maintained (I do not want to add software full of bugs)
2022-04-16 20:16:47 +00:00
2022-04-16 20:19:41 +00:00
## Backend
2022-04-16 20:16:47 +00:00
2022-04-16 20:19:41 +00:00
I use MinIO as an example.
2022-04-16 20:16:47 +00:00
2022-04-16 20:19:41 +00:00
You need to add a new folder to [src/routes/services/[id]](src/routes/services/[id]) with the low-capital name of the service. It should have three files with the following properties:
2022-04-16 20:16:47 +00:00
2022-04-16 20:19:41 +00:00
1. `index.json.ts`: A POST endpoint that updates Coolify's database about the service.
2022-04-16 20:16:47 +00:00
2022-04-16 20:28:17 +00:00
Basic services only require updating the URL(fqdn) and the name of the service.
2022-04-16 20:16:47 +00:00
2022-04-16 20:19:41 +00:00
2. `start.json.ts`: A start endpoint that setups the docker-compose file (for Local Docker Engines) and starts the service.
2022-04-16 20:16:47 +00:00
- To start a service, you need to know Coolify supported images and tags of the service. For that you need to update `supportedServiceTypesAndVersions` function at [src/lib/components/common.ts](src/lib/components/common.ts).
Example JSON:
2022-04-16 20:21:42 +00:00
```js
2022-04-16 20:16:47 +00:00
{
// Name used to identify the service in Coolify
name: 'minio',
// Fancier name to show to the user
fancyName: 'MinIO',
// Docker base image for the service
baseImage: 'minio/minio',
// Usable tags
versions: ['latest'],
// Which tag is the recommended
recommendedVersion: 'latest',
// Application's default port, MinIO listens on 9001 (and 9000, more details later on)
ports: {
main: 9001
}
},
```
2022-04-16 20:28:17 +00:00
- You need to define a compose file as `const composeFile: ComposeFile` found in [src/routes/services/[id]/minio/start.json.ts](src/routes/services/[id]/minio/start.json.ts)
2022-04-16 20:16:47 +00:00
2022-04-16 20:31:30 +00:00
**IMPORTANT:** It should contain `all the default environment variables` that are required for the service to function correctly and `all the volumes to persist data` in restarts.
2022-04-16 20:16:47 +00:00
2022-04-16 21:04:29 +00:00
- You could also define an `HTTP` or `TCP` proxy for every other port that should be proxied to your server. (See `startHttpProxy` and `startTcpProxy` functions in [src/lib/haproxy/index.ts](src/lib/haproxy/index.ts))
2022-04-16 20:16:47 +00:00
2022-04-16 20:28:17 +00:00
3. `stop.json.ts` A stop endpoint that stops the service.
2022-04-16 20:16:47 +00:00
2022-04-16 21:04:29 +00:00
It needs to stop all the services by their container name and proxies (if applicable).
2022-04-16 20:16:47 +00:00
2022-04-16 21:04:29 +00:00
4. You need to add the automatically generated variables (passwords, users, etc.) for the new service at [src/lib/database/services.ts](src/lib/database/services.ts), `configureServiceType` function.
2022-04-16 20:16:47 +00:00
2022-04-16 20:19:41 +00:00
## Frontend
2022-04-16 20:16:47 +00:00
2022-04-16 20:28:17 +00:00
1. You need to add a custom logo at [src/lib/components/svg/services/](src/lib/components/svg/services/) as a svelte component.
2022-04-16 20:16:47 +00:00
2022-04-16 20:28:17 +00:00
SVG is recommended, but you can use PNG as well. It should have the `isAbsolute` variable with the suitable CSS classes, primarily for sizing and positioning.
2022-04-16 20:16:47 +00:00
2022-04-16 20:28:17 +00:00
2. You need to include it the logo at [src/routes/services/index.svelte](src/routes/services/index.svelte) with `isAbsolute` and [src/lib/components/ServiceLinks.svelte](src/lib/components/ServiceLinks.svelte) with a link to the docs/main site of the service.
2022-04-16 20:16:47 +00:00
3. By default the URL and the name frontend forms are included in [src/routes/services/[id]/\_Services/\_Services.svelte](src/routes/services/[id]/_Services/_Services.svelte).
2022-04-16 20:28:17 +00:00
If you need to show more details on the frontend, such as users/passwords, you need to add Svelte component to [src/routes/services/[id]/\_Services](src/routes/services/[id]/_Services) with an underscore. For example, see other files in that folder.
2022-04-16 20:16:47 +00:00
You also need to add the new inputs to the `index.json.ts` file of the specific service, like for MinIO here: [src/routes/services/[id]/minio/index.json.ts](src/routes/services/[id]/minio/index.json.ts)