|
| 1 | +# Contributing to Coolify |
| 2 | +> "First, thanks for considering contributing to my project. It really means a lot!" - [@andrasbacsai](https://github.com/andrasbacsai) |
| 3 | +
|
| 4 | +You can ask for guidance anytime on our [Discord server](https://coollabs.io/discord) in the `#contribute` channel. |
| 5 | + |
| 6 | +To understand the tech stack, please refer to the [Tech Stack](TECH_STACK.md) document. |
| 7 | + |
| 8 | + |
| 9 | +## Table of Contents |
| 10 | +1. [Setup Development Environment](#1-setup-development-environment) |
| 11 | +2. [Verify Installation](#2-verify-installation-optional) |
| 12 | +3. [Fork and Setup Local Repository](#3-fork-and-setup-local-repository) |
| 13 | +4. [Set up Environment Variables](#4-set-up-environment-variables) |
| 14 | +5. [Start Coolify](#5-start-coolify) |
| 15 | +6. [Start Development](#6-start-development) |
| 16 | +7. [Create a Pull Request](#7-create-a-pull-request) |
| 17 | +8. [Development Notes](#development-notes) |
| 18 | +9. [Resetting Development Environment](#resetting-development-environment) |
| 19 | +10. [Additional Contribution Guidelines](#additional-contribution-guidelines) |
| 20 | + |
| 21 | + |
| 22 | +## 1. Setup Development Environment |
| 23 | +Follow the steps below for your operating system: |
| 24 | + |
| 25 | +<details> |
| 26 | +<summary><strong>Windows</strong></summary> |
| 27 | + |
| 28 | +1. Install `docker-ce`, Docker Desktop (or similar): |
| 29 | + - Docker CE (recommended): |
| 30 | + - Install Windows Subsystem for Linux v2 (WSL2) by following this guide: [Install WSL](https://learn.microsoft.com/en-us/windows/wsl/install?ref=coolify) |
| 31 | + - After installing WSL2, install Docker CE for your Linux distribution by following this guide: [Install Docker Engine](https://docs.docker.com/engine/install/?ref=coolify) |
| 32 | + - Make sure to choose the appropriate Linux distribution (e.g., Ubuntu) when following the Docker installation guide |
| 33 | + - Install Docker Desktop (easier): |
| 34 | + - Download and install [Docker Desktop for Windows](https://docs.docker.com/desktop/install/windows-install/?ref=coolify) |
| 35 | + - Ensure WSL2 backend is enabled in Docker Desktop settings |
| 36 | + |
| 37 | +2. Install Spin: |
| 38 | + - Follow the instructions to install Spin on Windows from the [Spin documentation](https://serversideup.net/open-source/spin/docs/installation/install-windows#download-and-install-spin-into-wsl2?ref=coolify) |
| 39 | + |
| 40 | +</details> |
| 41 | + |
| 42 | +<details> |
| 43 | +<summary><strong>MacOS</strong></summary> |
| 44 | + |
| 45 | +1. Install Orbstack, Docker Desktop (or similar): |
| 46 | + - Orbstack (recommended, as it is a faster and lighter alternative to Docker Desktop): |
| 47 | + - Download and install [Orbstack](https://docs.orbstack.dev/quick-start#installation?ref=coolify) |
| 48 | + - Docker Desktop: |
| 49 | + - Download and install [Docker Desktop for Mac](https://docs.docker.com/desktop/install/mac-install/?ref=coolify) |
| 50 | + |
| 51 | +2. Install Spin: |
| 52 | + - Follow the instructions to install Spin on MacOS from the [Spin documentation](https://serversideup.net/open-source/spin/docs/installation/install-macos/#download-and-install-spin?ref=coolify) |
| 53 | + |
| 54 | +</details> |
| 55 | + |
| 56 | +<details> |
| 57 | +<summary><strong>Linux</strong></summary> |
| 58 | + |
| 59 | +1. Install Docker Engine, Docker Desktop (or similar): |
| 60 | + - Docker Engine (recommended, as there is no VM overhead): |
| 61 | + - Follow the official [Docker Engine installation guide](https://docs.docker.com/engine/install/?ref=coolify) for your Linux distribution |
| 62 | + - Docker Desktop: |
| 63 | + - If you want a GUI, you can use [Docker Desktop for Linux](https://docs.docker.com/desktop/install/linux-install/?ref=coolify) |
| 64 | + |
| 65 | +2. Install Spin: |
| 66 | + - Follow the instructions to install Spin on Linux from the [Spin documentation](https://serversideup.net/open-source/spin/docs/installation/install-linux#configure-docker-permissions?ref=coolify) |
| 67 | + |
| 68 | +</details> |
| 69 | + |
| 70 | + |
| 71 | +## 2. Verify Installation (Optional) |
| 72 | +After installing Docker (or Orbstack) and Spin, verify the installation: |
| 73 | + |
| 74 | +1. Open a terminal or command prompt |
| 75 | +2. Run the following commands: |
| 76 | + ```bash |
| 77 | + docker --version |
| 78 | + spin --version |
| 79 | + ``` |
| 80 | + You should see version information for both Docker and Spin. |
| 81 | + |
| 82 | + |
| 83 | +## 3. Fork and Setup Local Repository |
| 84 | +1. Fork the [Coolify](https://github.com/coollabsio/coolify) repository to your GitHub account. |
| 85 | + |
| 86 | +2. Install a code editor on your machine (choose one): |
| 87 | + |
| 88 | + | Editor | Platform | Download Link | |
| 89 | + |--------|----------|---------------| |
| 90 | + | Visual Studio Code (recommended free) | Windows/macOS/Linux | [Download](https://code.visualstudio.com/download?ref=coolify) | |
| 91 | + | Cursor (recommended but paid) | Windows/macOS/Linux | [Download](https://www.cursor.com/?ref=coolify) | |
| 92 | + | Zed (very fast) | Windows/macOS/Linux | [Download](https://zed.dev/download?ref=coolify) | |
| 93 | + |
| 94 | +3. Clone the Coolify Repository from your fork to your local machine |
| 95 | + - Use `git clone` in the command line, or |
| 96 | + - Use GitHub Desktop (recommended): |
| 97 | + - Download and install from [https://desktop.github.com/](https://desktop.github.com/?ref=coolify) |
| 98 | + - Open GitHub Desktop and login with your GitHub account |
| 99 | + - Click on `File` -> `Clone Repository` select `github.com` as the repository location, then select your forked Coolify repository, choose the local path and then click `Clone` |
| 100 | + |
| 101 | +4. Open the cloned Coolify Repository in your chosen code editor. |
| 102 | + |
| 103 | + |
| 104 | +## 4. Set up Environment Variables |
| 105 | +1. In the Code Editor, locate the `.env.development.example` file in the root directory of your local Coolify repository. |
| 106 | +2. Duplicate the `.env.development.example` file and rename the copy to `.env`. |
| 107 | +3. Open the new `.env` file and review its contents. Adjust any environment variables as needed for your development setup. |
| 108 | +4. If you encounter errors during database migrations, update the database connection settings in your `.env` file. Use the IP address or hostname of your PostgreSQL database container. You can find this information by running `docker ps` after executing `spin up`. |
| 109 | +5. Save the changes to your `.env` file. |
| 110 | + |
| 111 | + |
| 112 | +## 5. Start Coolify |
| 113 | +1. Open a terminal in the local Coolify directory. |
| 114 | +2. Run the following command in the terminal (leave that terminal open): |
| 115 | + ```bash |
| 116 | + spin up |
| 117 | + ``` |
| 118 | + |
| 119 | +> [!NOTE] |
| 120 | +> You may see some errors, but don't worry; this is expected. |
| 121 | +
|
| 122 | +3. If you encounter permission errors, especially on macOS, use: |
| 123 | + ```bash |
| 124 | + sudo spin up |
| 125 | + ``` |
| 126 | + |
| 127 | +> [!NOTE] |
| 128 | +> If you change environment variables afterwards or anything seems broken, press Ctrl + C to stop the process and run `spin up` again. |
| 129 | +
|
| 130 | + |
| 131 | +## 6. Start Development |
| 132 | +1. Access your Coolify instance: |
| 133 | + - URL: `http://localhost:8000` |
| 134 | + - Login: `test@example.com` |
| 135 | + - Password: `password` |
| 136 | + |
| 137 | +2. Additional development tools: |
| 138 | + |
| 139 | + | Tool | URL | Note | |
| 140 | + |------|-----|------| |
| 141 | + | Laravel Horizon (scheduler) | `http://localhost:8000/horizon` | Only accessible when logged in as root user | |
| 142 | + | Mailpit (email catcher) | `http://localhost:8025` | | |
| 143 | + | Telescope (debugging tool) | `http://localhost:8000/telescope` | Disabled by default | |
| 144 | + |
| 145 | +> [!NOTE] |
| 146 | +> To enable Telescope, add the following to your `.env` file: |
| 147 | +> ```env |
| 148 | +> TELESCOPE_ENABLED=true |
| 149 | +> ``` |
| 150 | +
|
| 151 | +
|
| 152 | +## Development Notes |
| 153 | +When working on Coolify, keep the following in mind: |
| 154 | +
|
| 155 | +1. **Database Migrations**: After switching branches or making changes to the database structure, always run migrations: |
| 156 | + ```bash |
| 157 | + docker exec -it coolify php artisan migrate |
| 158 | + ``` |
| 159 | +
|
| 160 | +2. **Resetting Development Setup**: To reset your development setup to a clean database with default values: |
| 161 | + ```bash |
| 162 | + docker exec -it coolify php artisan migrate:fresh --seed |
| 163 | + ``` |
| 164 | + |
| 165 | +3. **Troubleshooting**: If you encounter unexpected behavior, ensure your database is up-to-date with the latest migrations and if possible reset the development setup to eliminate any environment-specific issues. |
| 166 | + |
| 167 | +> [!IMPORTANT] |
| 168 | +> Forgetting to migrate the database can cause problems, so make it a habit to run migrations after pulling changes or switching branches. |
| 169 | +
|
| 170 | + |
| 171 | +## Resetting Development Environment |
| 172 | +If you encounter issues or break your database or something else, follow these steps to start from a clean slate (works since `v4.0.0-beta.342`): |
| 173 | + |
| 174 | +1. Stop all running containers `ctrl + c`. |
| 175 | + |
| 176 | +2. Remove all Coolify containers: |
| 177 | + ```bash |
| 178 | + docker rm coolify coolify-db coolify-redis coolify-realtime coolify-testing-host coolify-minio coolify-vite-1 coolify-mail |
| 179 | + ``` |
| 180 | + |
| 181 | +3. Remove Coolify volumes (it is possible that the volumes have no `coolify` prefix on your machine, in that case remove the prefix from the command): |
| 182 | + ```bash |
| 183 | + docker volume rm coolify_dev_backups_data coolify_dev_postgres_data coolify_dev_redis_data coolify_dev_coolify_data coolify_dev_minio_data |
| 184 | + ``` |
| 185 | + |
| 186 | +4. Remove unused images: |
| 187 | + ```bash |
| 188 | + docker image prune -a |
| 189 | + ``` |
| 190 | + |
| 191 | +5. Start Coolify again: |
| 192 | + ```bash |
| 193 | + spin up |
| 194 | + ``` |
| 195 | + |
| 196 | +6. Run database migrations and seeders: |
| 197 | + ```bash |
| 198 | + docker exec -it coolify php artisan migrate:fresh --seed |
| 199 | + ``` |
| 200 | + |
| 201 | +After completing these steps, you'll have a fresh development setup. |
| 202 | + |
| 203 | +> [!IMPORTANT] |
| 204 | +> Always run database migrations and seeders after switching branches or pulling updates to ensure your local database structure matches the current codebase and includes necessary seed data. |
| 205 | +
|
| 206 | + |
| 207 | +## Additional Development Guidelines |
| 208 | +### Adding a New Service |
| 209 | +To add a new service to Coolify, please refer to our documentation: [Adding a New Service](https://coolify.io/docs/get-started/contribute/service) |
| 210 | + |
| 211 | +### Development for Documentation |
| 212 | +To contribute to the Coolify documentation, please refer to this guide: [Contributing to the Coolify Documentation](https://coolify.io/docs/get-started/contribute/documentation) |
0 commit comments