diff --git a/.env.development.example b/.env.development.example index 920c32d92..f9bcd361a 100644 --- a/.env.development.example +++ b/.env.development.example @@ -1,16 +1,31 @@ -APP_NAME=Coolify-localhost -APP_ID=development +# Coolify Configuration APP_ENV=local +APP_NAME="Coolify Development" +APP_ID=development APP_KEY= -APP_DEBUG=true APP_URL=http://localhost APP_PORT=8000 +APP_DEBUG=true MUX_ENABLED=false +# Enable Laravel Telescope for debugging +TELESCOPE_ENABLED=false + +# Selenium Driver URL for Dusk DUSK_DRIVER_URL=http://selenium:4444 -## For Andras only -# To purge cache +# PostgreSQL Database Configuration +DB_DATABASE=coolify +DB_USERNAME=coolify +DB_PASSWORD=password +DB_HOST=host.docker.internal +DB_PORT=5432 + +#Set custom ray port +RAY_PORT= + +# Special Keys for Andras +# For cache purging BUNNY_API_KEY= -# To upload assets +# For asset uploads BUNNY_STORAGE_API_KEY= diff --git a/.env.production b/.env.production index f15a8b0e9..8e5dd4602 100644 --- a/.env.production +++ b/.env.production @@ -1,10 +1,16 @@ +# Coolify Configuration APP_ID= -APP_NAME=Coolify APP_KEY= +# PostgreSQL Database Configuration +DB_DATABASE=coolify +DB_USERNAME= DB_PASSWORD= + +# Redis Configuration REDIS_PASSWORD= +# Pusher Configuration PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..9618bfae5 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,189 @@ +# Contributing + +> "First, thanks for considering contributing to my project. It really means a lot!" - [@andrasbacsai](https://github.com/andrasbacsai) + +You can ask for guidance anytime on our [Discord server](https://coollabs.io/discord) in the `#contribute` channel. + + +## Code Contribution + +## 1. Setup your development environment + +Follow the steps below for your operating system: + +### Windows + +1. Install `docker-ce`, Docker Desktop (or similar): + - Docker CE (recommended): + - Install Windows Subsystem for Linux v2 (WSL2) by following this guide: [Install WSL](https://learn.microsoft.com/en-us/windows/wsl/install) + - After installing WSL2, install Docker CE for your Linux distribution by following this guide: [Install Docker Engine](https://docs.docker.com/engine/install/) + - Make sure to choose the appropriate Linux distribution (e.g., Ubuntu) when following the Docker installation guide + - Install Docker Desktop (easier): + - Download and install [Docker Desktop for Windows](https://docs.docker.com/desktop/install/windows-install/) + - Ensure WSL2 backend is enabled in Docker Desktop settings + +2. Install Spin: + - 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) + +### MacOS + +1. Install Orbstack, Docker Desktop (or similar): + - Orbstack (recommended, as it is a faster and lighter alternative to Docker Desktop): + - Download and install [Orbstack](https://docs.orbstack.dev/quick-start#installation) + - Docker Desktop: + - Download and install [Docker Desktop for Mac](https://docs.docker.com/desktop/install/mac-install/) + +2. Install Spin: + - 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) + +### Linux + +1. Install Docker Engine, Docker Desktop (or similar): + - Docker Engine (recommended, as there is no VM overhead): + - Follow the official [Docker Engine installation guide](https://docs.docker.com/engine/install/) for your Linux distribution + - Docker Desktop: + - If you want a GUI, you can use [Docker Desktop for Linux](https://docs.docker.com/desktop/install/linux-install/) + +2. Install Spin: + - 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) + + +## 2. Verify installation (optional) + +After installing Docker (or Orbstack) and Spin, verify the installation: + +1. Open a terminal or command prompt +2. Run the following commands: + ```bash + docker --version + spin --version + ``` + You should see version information for both Docker and Spin. + + +## 3. Fork the Coolify repository and setup your local repository + +1. Fork the [Coolify](https://github.com/coollabsio/coolify) repository to your GitHub account. + +2. Install a code editor on your machine (below are some popular choices, choose one): + + - Visual Studio Code (recommended free): + - Windows/macOS/Linux: Download and install from [https://code.visualstudio.com/download](https://code.visualstudio.com/download) + + - Cursor (recommended but paid for getting the full benefits): + - Windows/macOS/Linux: Download and install from [https://www.cursor.com/](https://www.cursor.com/) + + - Zed (very fast code editor): + - macOS/Linux: Download and install from [https://zed.dev/download](https://zed.dev/download) + - Windows: Not available yet + +3. Clone the Coolify Repository from your fork to your local machine + - Use `git clone` in the command line + - Use GitHub Desktop (recommended): + - Download and install from [https://desktop.github.com/](https://desktop.github.com/) + - Open GitHub Desktop and login with your GitHub account + - 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` + +4. Open the cloned Coolify Repository in your chosen code editor. + + +## 4. Set up Environment Variables + +1. In the Code Editor, locate the `.env.development.example` file in the root directory of your local Coolify repository. + +2. Duplicate the `.env.development.example` file and rename the copy to `.env`. + +3. Open the new `.env` file and review its contents. Adjust any environment variables as needed for your development setup. + +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`. + +5. Save the changes to your `.env` file. + + +## 5. Start Coolify + +1. Open a terminal in the local Coolify directory. + +2. Run the following command in the terminal (leave that terminal open): + ``` + spin up + ``` + Note: You may see some errors, but don't worry; this is expected. + +3. If you encounter permission errors, especially on macOS, use: + ``` + sudo spin up + ``` + +Note: If you change environment variables afterwards or anything seems broken, press Ctrl + C to stop the process and run `spin up` again. + + +## 6. Start Development + +1. Access your Coolify instance: + - URL: `http://localhost:8000` + - Login: `test@example.com` + - Password: `password` + +2. Additional development tools: + - Laravel Horizon (scheduler): `http://localhost:8000/horizon` + Note: Only accessible when logged in as root user + - Mailpit (email catcher): `http://localhost:8025` + - Telescope (debugging tool): `http://localhost:8000/telescope` + Note: Disabled by default (so the database is not overloaded), enable by adding the following environment variable to your `.env` file: + ```env + TELESCOPE_ENABLED=true + ``` + + +## 7. Development Notes + +When working on Coolify, keep the following in mind: + +1. **Database Migrations**: After switching branches or making changes to the database structure, always run migrations: + ```bash + docker exec -it coolify php artisan migrate + ``` + +2. **Resetting Development Setup**: To reset your development setup to a clean database with default values: + ```bash + docker exec -it coolify php artisan migrate:fresh --seed + ``` + +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. + +Remember, forgetting to migrate the database can cause problems, so make it a habit to run migrations after pulling changes or switching branches. + + +## 8. Contributing a New Service + +To add a new service to Coolify, please refer to our documentation: +[Adding a New Service](https://coolify.io/docs/knowledge-base/add-a-service) + + +## 9. Create a Pull Request + +1. After making changes or adding a new service: + - Commit your changes to your forked repository. + - Push the changes to your GitHub account. + +2. Creating the Pull Request (PR): + - Navigate to the main Coolify repository on GitHub. + - Click the "Pull requests" tab. + - Click the green "New pull request" button. + - Choose your fork and branch as the compare branch. + - Click "Create pull request". + +3. Filling out the PR details: + - Give your PR a descriptive title. + - In the description, explain the changes you've made. + - Reference any related issues by using keywords like "Fixes #123" or "Closes #456". + +4. Important note: + Always set the base branch for your PR to the `next` branch of the Coolify repository, not the `main` branch. + +5. Submit your PR: + - Review your changes one last time. + - Click "Create pull request" to submit. + +After submission, maintainers will review your PR and may request changes or provide feedback. diff --git a/CONTRIBUTION.md b/CONTRIBUTION.md deleted file mode 100644 index 02a21573c..000000000 --- a/CONTRIBUTION.md +++ /dev/null @@ -1,34 +0,0 @@ -# Contributing - -> "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](https://coollabs.io/discord) in the `#contribution` channel. - -## Code Contribution - -### 1) Setup your development environment - -- You need to have Docker Engine (or equivalent) [installed](https://docs.docker.com/engine/install/) on your system. -- For better DX, install [Spin](https://serversideup.net/open-source/spin/). - -### 2) Set your environment variables - -- Copy [.env.development.example](./.env.development.example) to .env. - -## 3) Start & setup Coolify - -- Run `spin up` - You can notice that errors will be thrown. Don't worry. - - If you see weird permission errors, especially on Mac, run `sudo spin up` instead. - -### 4) Start development -You can login your Coolify instance at `localhost:8000` with `test@example.com` and `password`. - -Your horizon (Laravel scheduler): `localhost:8000/horizon` - Only reachable if you logged in with root user. - -Mails are caught by Mailpit: `localhost:8025` - -## New Service Contribution -Check out the docs [here](https://coolify.io/docs/knowledge-base/add-a-service). - diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index b8156cab5..aaceeed17 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -13,19 +13,18 @@ services: - /data/coolify/backups:/var/www/html/storage/app/backups - /data/coolify/webhooks-during-maintenance:/var/www/html/storage/app/webhooks-during-maintenance environment: - - PHP_MEMORY_LIMIT - - APP_ID - APP_ENV=production - - APP_DEBUG - - APP_NAME + - APP_NAME=Coolify + - APP_ID - APP_KEY - APP_URL - - DB_CONNECTION - - DB_HOST - - DB_PORT + - APP_DEBUG - DB_DATABASE - DB_USERNAME - DB_PASSWORD + - DB_HOST + - DB_PORT + - DB_CONNECTION - QUEUE_CONNECTION - REDIS_HOST - REDIS_PASSWORD @@ -34,6 +33,7 @@ services: - HORIZON_BALANCE_MAX_SHIFT - HORIZON_BALANCE_COOLDOWN - SSL_MODE=off + - PHP_MEMORY_LIMIT - PHP_PM_CONTROL=dynamic - PHP_PM_START_SERVERS=1 - PHP_PM_MIN_SPARE_SERVERS=1 @@ -47,7 +47,7 @@ services: - PUSHER_APP_KEY - PUSHER_APP_SECRET - AUTOUPDATE - - SELF_HOSTED + - SELF_HOSTED=true - SSH_MUX_PERSIST_TIME - FEEDBACK_DISCORD_WEBHOOK - WAITLIST @@ -83,18 +83,20 @@ services: condition: service_healthy redis: condition: service_healthy + soketi: + condition: service_healthy postgres: volumes: - coolify-db:/var/lib/postgresql/data environment: - POSTGRES_USER: "${DB_USERNAME:-coolify}" + POSTGRES_USER: "${DB_USERNAME}" POSTGRES_PASSWORD: "${DB_PASSWORD}" POSTGRES_DB: "${DB_DATABASE:-coolify}" healthcheck: test: [ "CMD-SHELL", - "pg_isready -U ${DB_USERNAME:-coolify}", + "pg_isready -U ${DB_USERNAME}", "-d", "${DB_DATABASE:-coolify}" ] diff --git a/docker-compose.windows.yml b/docker-compose.windows.yml index af5ecc0f7..a1ee1aeea 100644 --- a/docker-compose.windows.yml +++ b/docker-compose.windows.yml @@ -71,14 +71,14 @@ services: volumes: - coolify-db:/var/lib/postgresql/data environment: - POSTGRES_USER: "${DB_USERNAME:-coolify}" + POSTGRES_USER: "${DB_USERNAME}" POSTGRES_PASSWORD: "${DB_PASSWORD}" POSTGRES_DB: "${DB_DATABASE:-coolify}" healthcheck: test: [ "CMD-SHELL", - "pg_isready -U ${DB_USERNAME:-coolify}", + "pg_isready -U ${DB_USERNAME}", "-d", "${DB_DATABASE:-coolify}" ] diff --git a/docker-compose.yml b/docker-compose.yml index 8eed44f8c..930c0a6b9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,6 +10,7 @@ services: depends_on: - postgres - redis + - soketi postgres: image: postgres:15-alpine container_name: coolify-db @@ -32,4 +33,4 @@ networks: coolify: name: coolify driver: bridge - external: true + external: false diff --git a/scripts/install.sh b/scripts/install.sh index 69263642b..e2a0793b1 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -287,13 +287,21 @@ curl -fsSL $CDN/upgrade.sh -o /data/coolify/source/upgrade.sh # Copy .env.example if .env does not exist if [ ! -f /data/coolify/source/.env ]; then cp /data/coolify/source/.env.production /data/coolify/source/.env - sed -i "s|APP_ID=.*|APP_ID=$(openssl rand -hex 16)|g" /data/coolify/source/.env - sed -i "s|APP_KEY=.*|APP_KEY=base64:$(openssl rand -base64 32)|g" /data/coolify/source/.env - sed -i "s|DB_PASSWORD=.*|DB_PASSWORD=$(openssl rand -base64 32)|g" /data/coolify/source/.env - sed -i "s|REDIS_PASSWORD=.*|REDIS_PASSWORD=$(openssl rand -base64 32)|g" /data/coolify/source/.env - sed -i "s|PUSHER_APP_ID=.*|PUSHER_APP_ID=$(openssl rand -hex 32)|g" /data/coolify/source/.env - sed -i "s|PUSHER_APP_KEY=.*|PUSHER_APP_KEY=$(openssl rand -hex 32)|g" /data/coolify/source/.env - sed -i "s|PUSHER_APP_SECRET=.*|PUSHER_APP_SECRET=$(openssl rand -hex 32)|g" /data/coolify/source/.env + # Generate a secure APP_ID and APP_KEY + sed -i "s|^APP_ID=.*|APP_ID=$(openssl rand -hex 16)|" "$ENV_FILE" + sed -i "s|^APP_KEY=.*|APP_KEY=base64:$(openssl rand -base64 32)|" "$ENV_FILE" + + # Generate a secure Postgres DB username and password + sed -i "s|^DB_USERNAME=.*|DB_USERNAME=$(openssl rand -hex 16)|" "$ENV_FILE" + sed -i "s|^DB_PASSWORD=.*|DB_PASSWORD=$(openssl rand -base64 32)|" "$ENV_FILE" + + # Generate a secure Redis password + sed -i "s|^REDIS_PASSWORD=.*|REDIS_PASSWORD=$(openssl rand -base64 32)|" "$ENV_FILE" + + # Generate secure Pusher credentials + sed -i "s|^PUSHER_APP_ID=.*|PUSHER_APP_ID=$(openssl rand -hex 32)|" "$ENV_FILE" + sed -i "s|^PUSHER_APP_KEY=.*|PUSHER_APP_KEY=$(openssl rand -hex 32)|" "$ENV_FILE" + sed -i "s|^PUSHER_APP_SECRET=.*|PUSHER_APP_SECRET=$(openssl rand -hex 32)|" "$ENV_FILE" fi # Merge .env and .env.production. New values will be added to .env