|
| 1 | +# Contributing |
| 2 | + |
| 3 | +> "First, thanks for considering contributing to my project. It really means a lot!" - [@andrasbacsai](https://github.com/andrasbacsai) |
| 4 | +
|
| 5 | +You can ask for guidance anytime on our [Discord server](https://coollabs.io/discord) in the `#contribute` channel. |
| 6 | + |
| 7 | + |
| 8 | +## Code Contribution |
| 9 | + |
| 10 | +## 1. Setup your development environment |
| 11 | + |
| 12 | +Follow the steps below for your operating system: |
| 13 | + |
| 14 | +### Windows |
| 15 | + |
| 16 | +1. Install `docker-ce`, Docker Desktop (or similar): |
| 17 | + - Docker CE (recommended): |
| 18 | + - Install Windows Subsystem for Linux v2 (WSL2) by following this guide: [Install WSL](https://learn.microsoft.com/en-us/windows/wsl/install) |
| 19 | + - After installing WSL2, install Docker CE for your Linux distribution by following this guide: [Install Docker Engine](https://docs.docker.com/engine/install/) |
| 20 | + - Make sure to choose the appropriate Linux distribution (e.g., Ubuntu) when following the Docker installation guide |
| 21 | + - Install Docker Desktop (easier): |
| 22 | + - Download and install [Docker Desktop for Windows](https://docs.docker.com/desktop/install/windows-install/) |
| 23 | + - Ensure WSL2 backend is enabled in Docker Desktop settings |
| 24 | + |
| 25 | +2. Install Spin: |
| 26 | + - 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) |
| 27 | + |
| 28 | +### MacOS |
| 29 | + |
| 30 | +1. Install Orbstack, Docker Desktop (or similar): |
| 31 | + - Orbstack (recommended, as it is a faster and lighter alternative to Docker Desktop): |
| 32 | + - Download and install [Orbstack](https://docs.orbstack.dev/quick-start#installation) |
| 33 | + - Docker Desktop: |
| 34 | + - Download and install [Docker Desktop for Mac](https://docs.docker.com/desktop/install/mac-install/) |
| 35 | + |
| 36 | +2. Install Spin: |
| 37 | + - 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) |
| 38 | + |
| 39 | +### Linux |
| 40 | + |
| 41 | +1. Install Docker Engine, Docker Desktop (or similar): |
| 42 | + - Docker Engine (recommended, as there is no VM overhead): |
| 43 | + - Follow the official [Docker Engine installation guide](https://docs.docker.com/engine/install/) for your Linux distribution |
| 44 | + - Docker Desktop: |
| 45 | + - If you want a GUI, you can use [Docker Desktop for Linux](https://docs.docker.com/desktop/install/linux-install/) |
| 46 | + |
| 47 | +2. Install Spin: |
| 48 | + - 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) |
| 49 | + |
| 50 | + |
| 51 | +## 2. Verify installation (optional) |
| 52 | + |
| 53 | +After installing Docker (or Orbstack) and Spin, verify the installation: |
| 54 | + |
| 55 | +1. Open a terminal or command prompt |
| 56 | +2. Run the following commands: |
| 57 | + ```bash |
| 58 | + docker --version |
| 59 | + spin --version |
| 60 | + ``` |
| 61 | + You should see version information for both Docker and Spin. |
| 62 | + |
| 63 | + |
| 64 | +## 3. Fork the Coolify repository and setup your local repository |
| 65 | + |
| 66 | +1. Fork the [Coolify](https://github.com/coollabsio/coolify) repository to your GitHub account. |
| 67 | + |
| 68 | +2. Install a code editor on your machine (below are some popular choices, choose one): |
| 69 | + |
| 70 | + - Visual Studio Code (recommended free): |
| 71 | + - Windows/macOS/Linux: Download and install from [https://code.visualstudio.com/download](https://code.visualstudio.com/download) |
| 72 | + |
| 73 | + - Cursor (recommended but paid for getting the full benefits): |
| 74 | + - Windows/macOS/Linux: Download and install from [https://www.cursor.com/](https://www.cursor.com/) |
| 75 | + |
| 76 | + - Zed (very fast code editor): |
| 77 | + - macOS/Linux: Download and install from [https://zed.dev/download](https://zed.dev/download) |
| 78 | + - Windows: Not available yet |
| 79 | + |
| 80 | +3. Clone the Coolify Repository from your fork to your local machine |
| 81 | + - Use `git clone` in the command line |
| 82 | + - Use GitHub Desktop (recommended): |
| 83 | + - Download and install from [https://desktop.github.com/](https://desktop.github.com/) |
| 84 | + - Open GitHub Desktop and login with your GitHub account |
| 85 | + - 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` |
| 86 | + |
| 87 | +4. Open the cloned Coolify Repository in your chosen code editor. |
| 88 | + |
| 89 | + |
| 90 | +## 4. Set up Environment Variables |
| 91 | + |
| 92 | +1. In the Code Editor, locate the `.env.development.example` file in the root directory of your local Coolify repository. |
| 93 | + |
| 94 | +2. Duplicate the `.env.development.example` file and rename the copy to `.env`. |
| 95 | + |
| 96 | +3. Open the new `.env` file and review its contents. Adjust any environment variables as needed for your development setup. |
| 97 | + |
| 98 | +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`. |
| 99 | + |
| 100 | +5. Save the changes to your `.env` file. |
| 101 | + |
| 102 | + |
| 103 | +## 5. Start Coolify |
| 104 | + |
| 105 | +1. Open a terminal in the local Coolify directory. |
| 106 | + |
| 107 | +2. Run the following command in the terminal (leave that terminal open): |
| 108 | + ``` |
| 109 | + spin up |
| 110 | + ``` |
| 111 | + Note: You may see some errors, but don't worry; this is expected. |
| 112 | + |
| 113 | +3. If you encounter permission errors, especially on macOS, use: |
| 114 | + ``` |
| 115 | + sudo spin up |
| 116 | + ``` |
| 117 | + |
| 118 | +Note: If you change environment variables afterwards or anything seems broken, press Ctrl + C to stop the process and run `spin up` again. |
| 119 | + |
| 120 | + |
| 121 | +## 6. Start Development |
| 122 | + |
| 123 | +1. Access your Coolify instance: |
| 124 | + - URL: `http://localhost:8000` |
| 125 | + |
| 126 | + - Password: `password` |
| 127 | + |
| 128 | +2. Additional development tools: |
| 129 | + - Laravel Horizon (scheduler): `http://localhost:8000/horizon` |
| 130 | + Note: Only accessible when logged in as root user |
| 131 | + - Mailpit (email catcher): `http://localhost:8025` |
| 132 | + - Telescope (debugging tool): `http://localhost:8000/telescope` |
| 133 | + Note: Disabled by default (so the database is not overloaded), enable by adding the following environment variable to your `.env` file: |
| 134 | + ```env |
| 135 | + TELESCOPE_ENABLED=true |
| 136 | + ``` |
| 137 | +
|
| 138 | +
|
| 139 | +## 7. Development Notes |
| 140 | +
|
| 141 | +When working on Coolify, keep the following in mind: |
| 142 | +
|
| 143 | +1. **Database Migrations**: After switching branches or making changes to the database structure, always run migrations: |
| 144 | + ```bash |
| 145 | + docker exec -it coolify php artisan migrate |
| 146 | + ``` |
| 147 | + |
| 148 | +2. **Resetting Development Setup**: To reset your development setup to a clean database with default values: |
| 149 | + ```bash |
| 150 | + docker exec -it coolify php artisan migrate:fresh --seed |
| 151 | + ``` |
| 152 | + |
| 153 | +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 envrionement specific issues. |
| 154 | + |
| 155 | +Remember, forgetting to migrate the database can cause problems, so make it a habit to run migrations after pulling changes or switching branches. |
| 156 | + |
| 157 | + |
| 158 | +## 8. Contributing a New Service |
| 159 | + |
| 160 | +To add a new service to Coolify, please refer to our documentation: |
| 161 | +[Adding a New Service](https://coolify.io/docs/knowledge-base/add-a-service) |
| 162 | + |
| 163 | + |
| 164 | +## 9. Create a Pull Request |
| 165 | + |
| 166 | +1. After making changes or adding a new service: |
| 167 | + - Commit your changes to your forked repository. |
| 168 | + - Push the changes to your GitHub account. |
| 169 | + |
| 170 | +2. Creating the Pull Request (PR): |
| 171 | + - Navigate to the main Coolify repository on GitHub. |
| 172 | + - Click the "Pull requests" tab. |
| 173 | + - Click the green "New pull request" button. |
| 174 | + - Choose your fork and branch as the compare branch. |
| 175 | + - Click "Create pull request". |
| 176 | + |
| 177 | +3. Filling out the PR details: |
| 178 | + - Give your PR a descriptive title. |
| 179 | + - In the description, explain the changes you've made. |
| 180 | + - Reference any related issues by using keywords like "Fixes #123" or "Closes #456". |
| 181 | + |
| 182 | +4. Important note: |
| 183 | + Always set the base branch for your PR to the `next` branch of the Coolify repository, not the `main` branch. |
| 184 | + |
| 185 | +5. Submit your PR: |
| 186 | + - Review your changes one last time. |
| 187 | + - Click "Create pull request" to submit. |
| 188 | + |
| 189 | +After submission, maintainers will review your PR and may request changes or provide feedback. |
0 commit comments