From 21fc8efb865f3d464d5d12dfc355f450fdfa4136 Mon Sep 17 00:00:00 2001 From: Alejandro Akbal <37181533+AlejandroAkbal@users.noreply.github.com> Date: Tue, 4 Jun 2024 13:13:37 +0100 Subject: [PATCH 01/42] feat: add Mixpost template --- public/svgs/mixpost.svg | 5 ++++ templates/compose/mixpost.yaml | 54 ++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 public/svgs/mixpost.svg create mode 100644 templates/compose/mixpost.yaml diff --git a/public/svgs/mixpost.svg b/public/svgs/mixpost.svg new file mode 100644 index 0000000000..bd915e77a5 --- /dev/null +++ b/public/svgs/mixpost.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/templates/compose/mixpost.yaml b/templates/compose/mixpost.yaml new file mode 100644 index 0000000000..7dffd55c64 --- /dev/null +++ b/templates/compose/mixpost.yaml @@ -0,0 +1,54 @@ +# documentation: https://docs.mixpost.app/lite +# slogan: Mixpost is a robust and versatile social media management software, designed to streamline social media operations and enhance content marketing strategies. +# tags: social media, marketing, content, management, automation, self-hosted +# logo: svgs/mixpost.svg +# port: 80 + +services: + mixpost: + image: 'inovector/mixpost:latest' + environment: + - SERVICE_FQDN_MIXPOST + - APP_NAME=Mixpost + - 'APP_KEY=${SERVICE_BASE64_MIXPOST}' + - APP_DEBUG=false + - 'APP_URL=${SERVICE_FQDN_MIXPOST}' + - 'DB_DATABASE=${MYSQL_DATABASE:-mixpost_db}' + - 'DB_USERNAME=${SERVICE_USERNAME_MYSQL}' + - 'DB_PASSWORD=${SERVICE_PASSWORD_MYSQL}' + volumes: + - 'mixpost-storage:/var/www/html/storage/app' + - 'mixpost-logs:/var/www/html/storage/logs' + depends_on: + - mysql + - redis + mysql: + image: 'mysql/mysql-server:8.0' + environment: + - 'MYSQL_DATABASE=${MYSQL_DATABASE:-mixpost_db}' + - 'MYSQL_USER=${SERVICE_USERNAME_MYSQL}' + - 'MYSQL_PASSWORD=${SERVICE_PASSWORD_MYSQL}' + - 'MYSQL_ROOT_PASSWORD=${SERVICE_PASSWORD_MYSQLROOT}' + volumes: + - 'mixpost-mysql:/var/lib/mysql' + healthcheck: + test: + - CMD + - mysqladmin + - ping + - '-h' + - 127.0.0.1 + - '-uroot' + - '-p${SERVICE_PASSWORD_MYSQLROOT}' + interval: 5s + timeout: 20s + retries: 10 + redis: + image: 'redis:alpine' + healthcheck: + test: + - CMD + - redis-cli + - '--raw' + - incr + - ping From 1138ec0dea197f980aa4266b9894b6202f84e9ba Mon Sep 17 00:00:00 2001 From: Luan Estradioto Date: Sun, 21 Jul 2024 13:30:28 -0300 Subject: [PATCH 02/42] add storage:link to dev environment --- app/Console/Commands/Dev.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Console/Commands/Dev.php b/app/Console/Commands/Dev.php index 964b8e46e9..20a2667c32 100644 --- a/app/Console/Commands/Dev.php +++ b/app/Console/Commands/Dev.php @@ -48,6 +48,13 @@ public function init() echo "Generating APP_KEY.\n"; Artisan::call('key:generate'); } + + // Generate STORAGE link if not exists + if (! file_exists(public_path('storage'))) { + echo "Generating STORAGE link.\n"; + Artisan::call('storage:link'); + } + // Seed database if it's empty $settings = InstanceSettings::find(0); if (! $settings) { From 7e154ba3c38926e607e6d28f09fa09d4d72b8a79 Mon Sep 17 00:00:00 2001 From: Franck Kerbiriou Date: Thu, 22 Aug 2024 22:52:20 +0200 Subject: [PATCH 03/42] Add Mailpit template --- public/svgs/mailpit.svg | 5 +++++ templates/compose/mailpit.yaml | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 public/svgs/mailpit.svg create mode 100644 templates/compose/mailpit.yaml diff --git a/public/svgs/mailpit.svg b/public/svgs/mailpit.svg new file mode 100644 index 0000000000..e569e71ccd --- /dev/null +++ b/public/svgs/mailpit.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/templates/compose/mailpit.yaml b/templates/compose/mailpit.yaml new file mode 100644 index 0000000000..46072fb217 --- /dev/null +++ b/templates/compose/mailpit.yaml @@ -0,0 +1,20 @@ +# documentation: https://mailpit.axllent.org/docs/ +# slogan: Email & SMTP testing tool with API for developers +# tags: mailpit,email,testing,smtp +# logo: svgs/mailpit.png +# port: 8025 + +services: + mailpit: + image: axllent/mailpit + container_name: mailpit + volumes: + - "mailpit-data:/data" + ports: + - "1025:1025" + environment: + - SERVICE_FQDN_MAILPIT_8025 + - MP_MAX_MESSAGES: 5000 + - MP_DATABASE: /data/mailpit.db + - MP_SMTP_AUTH_ACCEPT_ANY: 1 + - MP_SMTP_AUTH_ALLOW_INSECURE: 1 From baa236f9343730fddad42f805c26a0059c216b29 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Wed, 11 Sep 2024 16:46:14 +0200 Subject: [PATCH 04/42] Feat: Add debug bar --- composer.json | 3 +- composer.lock | 154 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 155 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 7ca65babea..09e7f08e88 100644 --- a/composer.json +++ b/composer.json @@ -48,6 +48,7 @@ "zircote/swagger-php": "^4.10" }, "require-dev": { + "barryvdh/laravel-debugbar": "^3.13", "fakerphp/faker": "^v1.21.0", "laravel/dusk": "^v8.0", "laravel/pint": "^1.16", @@ -110,4 +111,4 @@ }, "minimum-stability": "stable", "prefer-stable": true -} \ No newline at end of file +} diff --git a/composer.lock b/composer.lock index 4deaa42de8..c3f521de04 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "96f8146407d0e6e897ff097c5eccd3a4", + "content-hash": "42c28ab141b70fcabf75b51afa96c670", "packages": [ { "name": "amphp/amp", @@ -11895,6 +11895,90 @@ } ], "packages-dev": [ + { + "name": "barryvdh/laravel-debugbar", + "version": "v3.13.5", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-debugbar.git", + "reference": "92d86be45ee54edff735e46856f64f14b6a8bb07" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/92d86be45ee54edff735e46856f64f14b6a8bb07", + "reference": "92d86be45ee54edff735e46856f64f14b6a8bb07", + "shasum": "" + }, + "require": { + "illuminate/routing": "^9|^10|^11", + "illuminate/session": "^9|^10|^11", + "illuminate/support": "^9|^10|^11", + "maximebf/debugbar": "~1.22.0", + "php": "^8.0", + "symfony/finder": "^6|^7" + }, + "require-dev": { + "mockery/mockery": "^1.3.3", + "orchestra/testbench-dusk": "^5|^6|^7|^8|^9", + "phpunit/phpunit": "^9.6|^10.5", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.13-dev" + }, + "laravel": { + "providers": [ + "Barryvdh\\Debugbar\\ServiceProvider" + ], + "aliases": { + "Debugbar": "Barryvdh\\Debugbar\\Facades\\Debugbar" + } + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Barryvdh\\Debugbar\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "PHP Debugbar integration for Laravel", + "keywords": [ + "debug", + "debugbar", + "laravel", + "profiler", + "webprofiler" + ], + "support": { + "issues": "https://github.com/barryvdh/laravel-debugbar/issues", + "source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.13.5" + }, + "funding": [ + { + "url": "https://fruitcake.nl", + "type": "custom" + }, + { + "url": "https://github.com/barryvdh", + "type": "github" + } + ], + "time": "2024-04-12T11:20:37+00:00" + }, { "name": "brianium/paratest", "version": "v7.4.3", @@ -12373,6 +12457,74 @@ }, "time": "2024-08-06T15:11:54+00:00" }, + { + "name": "maximebf/debugbar", + "version": "v1.22.5", + "source": { + "type": "git", + "url": "https://github.com/maximebf/php-debugbar.git", + "reference": "1b5cabe0ce013134cf595bfa427bbf2f6abcd989" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/1b5cabe0ce013134cf595bfa427bbf2f6abcd989", + "reference": "1b5cabe0ce013134cf595bfa427bbf2f6abcd989", + "shasum": "" + }, + "require": { + "php": "^7.2|^8", + "psr/log": "^1|^2|^3", + "symfony/var-dumper": "^4|^5|^6|^7" + }, + "require-dev": { + "dbrekelmans/bdi": "^1", + "phpunit/phpunit": "^8|^9", + "symfony/panther": "^1|^2.1", + "twig/twig": "^1.38|^2.7|^3.0" + }, + "suggest": { + "kriswallsmith/assetic": "The best way to manage assets", + "monolog/monolog": "Log using Monolog", + "predis/predis": "Redis storage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.22-dev" + } + }, + "autoload": { + "psr-4": { + "DebugBar\\": "src/DebugBar/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maxime Bouroumeau-Fuseau", + "email": "maxime.bouroumeau@gmail.com", + "homepage": "http://maximebf.com" + }, + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "Debug bar in the browser for php application", + "homepage": "https://github.com/maximebf/php-debugbar", + "keywords": [ + "debug", + "debugbar" + ], + "support": { + "issues": "https://github.com/maximebf/php-debugbar/issues", + "source": "https://github.com/maximebf/php-debugbar/tree/v1.22.5" + }, + "time": "2024-09-09T08:05:55+00:00" + }, { "name": "mockery/mockery", "version": "1.6.12", From 26f18e25aad56cb73fe401e7b3de30ae9c4e92fe Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Fri, 27 Sep 2024 16:54:24 +0200 Subject: [PATCH 05/42] Create .gitignore --- storage/debugbar/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 storage/debugbar/.gitignore diff --git a/storage/debugbar/.gitignore b/storage/debugbar/.gitignore new file mode 100644 index 0000000000..d6b7ef32c8 --- /dev/null +++ b/storage/debugbar/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore From b99474ac731ba5f937b4052cf4a6a318ee1110c0 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Fri, 27 Sep 2024 17:38:34 +0200 Subject: [PATCH 06/42] Fix: Remove memlock as it caused problems for some users --- app/Actions/Database/StartDragonfly.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/Actions/Database/StartDragonfly.php b/app/Actions/Database/StartDragonfly.php index 352c6a59f9..3ee46a2e10 100644 --- a/app/Actions/Database/StartDragonfly.php +++ b/app/Actions/Database/StartDragonfly.php @@ -46,9 +46,6 @@ public function handle(StandaloneDragonfly $database) 'networks' => [ $this->database->destination->network, ], - 'ulimits' => [ - 'memlock' => '-1', - ], 'labels' => [ 'coolify.managed' => 'true', ], From 9ec3233c0c039fe352b029baf09de1bd7e4e9707 Mon Sep 17 00:00:00 2001 From: liberocks Date: Sat, 28 Sep 2024 11:11:43 +0700 Subject: [PATCH 07/42] feat: allow specify use_build_server when creating/updating an application --- .../Controllers/Api/ApplicationsController.php | 17 +++++++++++++++-- bootstrap/helpers/api.php | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Api/ApplicationsController.php b/app/Http/Controllers/Api/ApplicationsController.php index 48e126f27c..4941b49909 100644 --- a/app/Http/Controllers/Api/ApplicationsController.php +++ b/app/Http/Controllers/Api/ApplicationsController.php @@ -177,6 +177,7 @@ public function applications(Request $request) 'docker_compose_custom_build_command' => ['type' => 'string', 'description' => 'The Docker Compose custom build command.'], 'docker_compose_domains' => ['type' => 'array', 'description' => 'The Docker Compose domains.'], 'watch_paths' => ['type' => 'string', 'description' => 'The watch paths.'], + 'use_build_server' => ['type' => 'boolean', 'nullable' => true, 'description' => 'Use build server.'], ], )), ]), @@ -279,6 +280,7 @@ public function create_public_application(Request $request) 'docker_compose_custom_build_command' => ['type' => 'string', 'description' => 'The Docker Compose custom build command.'], 'docker_compose_domains' => ['type' => 'array', 'description' => 'The Docker Compose domains.'], 'watch_paths' => ['type' => 'string', 'description' => 'The watch paths.'], + 'use_build_server' => ['type' => 'boolean', 'nullable' => true, 'description' => 'Use build server.'], ], )), ]), @@ -381,6 +383,7 @@ public function create_private_gh_app_application(Request $request) 'docker_compose_custom_build_command' => ['type' => 'string', 'description' => 'The Docker Compose custom build command.'], 'docker_compose_domains' => ['type' => 'array', 'description' => 'The Docker Compose domains.'], 'watch_paths' => ['type' => 'string', 'description' => 'The watch paths.'], + 'use_build_server' => ['type' => 'boolean', 'nullable' => true, 'description' => 'Use build server.'], ], )), ]), @@ -468,6 +471,7 @@ public function create_private_deploy_key_application(Request $request) 'manual_webhook_secret_gitea' => ['type' => 'string', 'description' => 'Manual webhook secret for Gitea.'], 'redirect' => ['type' => 'string', 'nullable' => true, 'description' => 'How to set redirect with Traefik / Caddy. www<->non-www.', 'enum' => ['www', 'non-www', 'both']], 'instant_deploy' => ['type' => 'boolean', 'description' => 'The flag to indicate if the application should be deployed instantly.'], + 'use_build_server' => ['type' => 'boolean', 'nullable' => true, 'description' => 'Use build server.'], ], )), ]), @@ -552,6 +556,7 @@ public function create_dockerfile_application(Request $request) 'manual_webhook_secret_gitea' => ['type' => 'string', 'description' => 'Manual webhook secret for Gitea.'], 'redirect' => ['type' => 'string', 'nullable' => true, 'description' => 'How to set redirect with Traefik / Caddy. www<->non-www.', 'enum' => ['www', 'non-www', 'both']], 'instant_deploy' => ['type' => 'boolean', 'description' => 'The flag to indicate if the application should be deployed instantly.'], + 'use_build_server' => ['type' => 'boolean', 'nullable' => true, 'description' => 'Use build server.'], ], )), ]), @@ -602,6 +607,7 @@ public function create_dockerimage_application(Request $request) 'name' => ['type' => 'string', 'description' => 'The application name.'], 'description' => ['type' => 'string', 'description' => 'The application description.'], 'instant_deploy' => ['type' => 'boolean', 'description' => 'The flag to indicate if the application should be deployed instantly.'], + 'use_build_server' => ['type' => 'boolean', 'nullable' => true, 'description' => 'Use build server.'], ], )), ]), @@ -627,7 +633,7 @@ public function create_dockercompose_application(Request $request) private function create_application(Request $request, $type) { - $allowedFields = ['project_uuid', 'environment_name', 'server_uuid', 'destination_uuid', 'type', 'name', 'description', 'is_static', 'domains', 'git_repository', 'git_branch', 'git_commit_sha', 'private_key_uuid', 'docker_registry_image_name', 'docker_registry_image_tag', 'build_pack', 'install_command', 'build_command', 'start_command', 'ports_exposes', 'ports_mappings', 'base_directory', 'publish_directory', 'health_check_enabled', 'health_check_path', 'health_check_port', 'health_check_host', 'health_check_method', 'health_check_return_code', 'health_check_scheme', 'health_check_response_text', 'health_check_interval', 'health_check_timeout', 'health_check_retries', 'health_check_start_period', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'custom_labels', 'custom_docker_run_options', 'post_deployment_command', 'post_deployment_command_container', 'pre_deployment_command', 'pre_deployment_command_container', 'manual_webhook_secret_github', 'manual_webhook_secret_gitlab', 'manual_webhook_secret_bitbucket', 'manual_webhook_secret_gitea', 'redirect', 'github_app_uuid', 'instant_deploy', 'dockerfile', 'docker_compose_location', 'docker_compose_raw', 'docker_compose_custom_start_command', 'docker_compose_custom_build_command', 'docker_compose_domains', 'watch_paths']; + $allowedFields = ['project_uuid', 'environment_name', 'server_uuid', 'destination_uuid', 'type', 'name', 'description', 'is_static', 'domains', 'git_repository', 'git_branch', 'git_commit_sha', 'private_key_uuid', 'docker_registry_image_name', 'docker_registry_image_tag', 'build_pack', 'install_command', 'build_command', 'start_command', 'ports_exposes', 'ports_mappings', 'base_directory', 'publish_directory', 'health_check_enabled', 'health_check_path', 'health_check_port', 'health_check_host', 'health_check_method', 'health_check_return_code', 'health_check_scheme', 'health_check_response_text', 'health_check_interval', 'health_check_timeout', 'health_check_retries', 'health_check_start_period', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'custom_labels', 'custom_docker_run_options', 'post_deployment_command', 'post_deployment_command_container', 'pre_deployment_command', 'pre_deployment_command_container', 'manual_webhook_secret_github', 'manual_webhook_secret_gitlab', 'manual_webhook_secret_bitbucket', 'manual_webhook_secret_gitea', 'redirect', 'github_app_uuid', 'instant_deploy', 'dockerfile', 'docker_compose_location', 'docker_compose_raw', 'docker_compose_custom_start_command', 'docker_compose_custom_build_command', 'docker_compose_domains', 'watch_paths', 'use_build_server']; $teamId = getTeamIdFromToken(); if (is_null($teamId)) { return invalidTokenResponse(); @@ -665,6 +671,7 @@ private function create_application(Request $request, $type) $fqdn = $request->domains; $instantDeploy = $request->instant_deploy; $githubAppUuid = $request->github_app_uuid; + $useBuildServer = $request->use_build_server; $project = Project::whereTeamId($teamId)->whereUuid($request->project_uuid)->first(); if (! $project) { @@ -737,6 +744,8 @@ private function create_application(Request $request, $type) $application->destination_id = $destination->id; $application->destination_type = $destination->getMorphClass(); $application->environment_id = $environment->id; + $application->settings->is_build_server_enabled = $useBuildServer; + $application->save(); $application->refresh(); if (! $application->settings->is_container_label_readonly_enabled) { @@ -1404,6 +1413,7 @@ public function delete_by_uuid(Request $request) 'docker_compose_custom_build_command' => ['type' => 'string', 'description' => 'The Docker Compose custom build command.'], 'docker_compose_domains' => ['type' => 'array', 'description' => 'The Docker Compose domains.'], 'watch_paths' => ['type' => 'string', 'description' => 'The watch paths.'], + 'use_build_server' => ['type' => 'boolean', 'nullable' => true, 'description' => 'Use build server.'], ], )), ]), @@ -1460,7 +1470,7 @@ public function update_by_uuid(Request $request) ], 404); } $server = $application->destination->server; - $allowedFields = ['name', 'description', 'is_static', 'domains', 'git_repository', 'git_branch', 'git_commit_sha', 'docker_registry_image_name', 'docker_registry_image_tag', 'build_pack', 'static_image', 'install_command', 'build_command', 'start_command', 'ports_exposes', 'ports_mappings', 'base_directory', 'publish_directory', 'health_check_enabled', 'health_check_path', 'health_check_port', 'health_check_host', 'health_check_method', 'health_check_return_code', 'health_check_scheme', 'health_check_response_text', 'health_check_interval', 'health_check_timeout', 'health_check_retries', 'health_check_start_period', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'custom_labels', 'custom_docker_run_options', 'post_deployment_command', 'post_deployment_command_container', 'pre_deployment_command', 'pre_deployment_command_container', 'watch_paths', 'manual_webhook_secret_github', 'manual_webhook_secret_gitlab', 'manual_webhook_secret_bitbucket', 'manual_webhook_secret_gitea', 'docker_compose_location', 'docker_compose_raw', 'docker_compose_custom_start_command', 'docker_compose_custom_build_command', 'docker_compose_domains', 'redirect', 'instant_deploy']; + $allowedFields = ['name', 'description', 'is_static', 'domains', 'git_repository', 'git_branch', 'git_commit_sha', 'docker_registry_image_name', 'docker_registry_image_tag', 'build_pack', 'static_image', 'install_command', 'build_command', 'start_command', 'ports_exposes', 'ports_mappings', 'base_directory', 'publish_directory', 'health_check_enabled', 'health_check_path', 'health_check_port', 'health_check_host', 'health_check_method', 'health_check_return_code', 'health_check_scheme', 'health_check_response_text', 'health_check_interval', 'health_check_timeout', 'health_check_retries', 'health_check_start_period', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'custom_labels', 'custom_docker_run_options', 'post_deployment_command', 'post_deployment_command_container', 'pre_deployment_command', 'pre_deployment_command_container', 'watch_paths', 'manual_webhook_secret_github', 'manual_webhook_secret_gitlab', 'manual_webhook_secret_bitbucket', 'manual_webhook_secret_gitea', 'docker_compose_location', 'docker_compose_raw', 'docker_compose_custom_start_command', 'docker_compose_custom_build_command', 'docker_compose_domains', 'redirect', 'instant_deploy', 'use_build_server']; $validator = customApiValidator($request->all(), [ sharedDataApplications(), @@ -1538,6 +1548,9 @@ public function update_by_uuid(Request $request) } $instantDeploy = $request->instant_deploy; + $use_build_server = $request->use_build_server; + $application->settings->is_build_server_enabled = $use_build_server; + removeUnnecessaryFieldsFromRequest($request); $data = $request->all(); diff --git a/bootstrap/helpers/api.php b/bootstrap/helpers/api.php index 8e14ef9eee..006b095cfb 100644 --- a/bootstrap/helpers/api.php +++ b/bootstrap/helpers/api.php @@ -175,4 +175,5 @@ function removeUnnecessaryFieldsFromRequest(Request $request) $request->offsetUnset('instant_deploy'); $request->offsetUnset('github_app_uuid'); $request->offsetUnset('private_key_uuid'); + $request->offsetUnset('use_build_server'); } From 221921990650f1921ff799251918f97c26abcc7e Mon Sep 17 00:00:00 2001 From: liberocks Date: Sat, 28 Sep 2024 11:25:00 +0700 Subject: [PATCH 08/42] fix: edit is_build_server_enabled upon creating application on other application type --- app/Http/Controllers/Api/ApplicationsController.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Api/ApplicationsController.php b/app/Http/Controllers/Api/ApplicationsController.php index 4941b49909..69709bfa38 100644 --- a/app/Http/Controllers/Api/ApplicationsController.php +++ b/app/Http/Controllers/Api/ApplicationsController.php @@ -745,7 +745,6 @@ private function create_application(Request $request, $type) $application->destination_type = $destination->getMorphClass(); $application->environment_id = $environment->id; $application->settings->is_build_server_enabled = $useBuildServer; - $application->save(); $application->refresh(); if (! $application->settings->is_container_label_readonly_enabled) { @@ -842,6 +841,7 @@ private function create_application(Request $request, $type) $application->environment_id = $environment->id; $application->source_type = $githubApp->getMorphClass(); $application->source_id = $githubApp->id; + $application->settings->is_build_server_enabled = $useBuildServer; $application->save(); $application->refresh(); if (! $application->settings->is_container_label_readonly_enabled) { @@ -934,6 +934,7 @@ private function create_application(Request $request, $type) $application->destination_id = $destination->id; $application->destination_type = $destination->getMorphClass(); $application->environment_id = $environment->id; + $application->settings->is_build_server_enabled = $useBuildServer; $application->save(); $application->refresh(); if (! $application->settings->is_container_label_readonly_enabled) { @@ -1013,7 +1014,7 @@ private function create_application(Request $request, $type) $application->destination_id = $destination->id; $application->destination_type = $destination->getMorphClass(); $application->environment_id = $environment->id; - + $application->settings->is_build_server_enabled = $useBuildServer; $application->git_repository = 'coollabsio/coolify'; $application->git_branch = 'main'; $application->save(); @@ -1071,7 +1072,7 @@ private function create_application(Request $request, $type) $application->destination_id = $destination->id; $application->destination_type = $destination->getMorphClass(); $application->environment_id = $environment->id; - + $application->settings->is_build_server_enabled = $useBuildServer; $application->git_repository = 'coollabsio/coolify'; $application->git_branch = 'main'; $application->save(); From f5785b1f171cb45f12af180a98829bc17d5d4b14 Mon Sep 17 00:00:00 2001 From: liberocks Date: Sat, 28 Sep 2024 11:28:48 +0700 Subject: [PATCH 09/42] fix: save settings after assigning value --- app/Http/Controllers/Api/ApplicationsController.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/Http/Controllers/Api/ApplicationsController.php b/app/Http/Controllers/Api/ApplicationsController.php index 69709bfa38..782b3f2707 100644 --- a/app/Http/Controllers/Api/ApplicationsController.php +++ b/app/Http/Controllers/Api/ApplicationsController.php @@ -745,6 +745,7 @@ private function create_application(Request $request, $type) $application->destination_type = $destination->getMorphClass(); $application->environment_id = $environment->id; $application->settings->is_build_server_enabled = $useBuildServer; + $application->settings->save(); $application->save(); $application->refresh(); if (! $application->settings->is_container_label_readonly_enabled) { @@ -842,6 +843,7 @@ private function create_application(Request $request, $type) $application->source_type = $githubApp->getMorphClass(); $application->source_id = $githubApp->id; $application->settings->is_build_server_enabled = $useBuildServer; + $application->settings->save(); $application->save(); $application->refresh(); if (! $application->settings->is_container_label_readonly_enabled) { @@ -935,6 +937,7 @@ private function create_application(Request $request, $type) $application->destination_type = $destination->getMorphClass(); $application->environment_id = $environment->id; $application->settings->is_build_server_enabled = $useBuildServer; + $application->settings->save(); $application->save(); $application->refresh(); if (! $application->settings->is_container_label_readonly_enabled) { @@ -1015,6 +1018,8 @@ private function create_application(Request $request, $type) $application->destination_type = $destination->getMorphClass(); $application->environment_id = $environment->id; $application->settings->is_build_server_enabled = $useBuildServer; + $application->settings->save(); + $application->git_repository = 'coollabsio/coolify'; $application->git_branch = 'main'; $application->save(); @@ -1073,6 +1078,8 @@ private function create_application(Request $request, $type) $application->destination_type = $destination->getMorphClass(); $application->environment_id = $environment->id; $application->settings->is_build_server_enabled = $useBuildServer; + $application->settings->save(); + $application->git_repository = 'coollabsio/coolify'; $application->git_branch = 'main'; $application->save(); @@ -1551,6 +1558,7 @@ public function update_by_uuid(Request $request) $use_build_server = $request->use_build_server; $application->settings->is_build_server_enabled = $use_build_server; + $application->settings->save(); removeUnnecessaryFieldsFromRequest($request); From 56ec0a300413a1900afe54347a1ed6ae6bda0219 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 29 Sep 2024 13:27:45 +0200 Subject: [PATCH 10/42] chore: Update version numbers to 4.0.0-beta.348 --- config/sentry.php | 2 +- config/version.php | 2 +- versions.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/sentry.php b/config/sentry.php index 1e83eae9e5..5efd8968de 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.347', + 'release' => '4.0.0-beta.348', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index 6e7f911aef..09d7ab3e72 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Sun, 29 Sep 2024 15:36:41 +0200 Subject: [PATCH 11/42] fix(templates): filebrowser FQDN env variable --- templates/compose/filebrowser.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/compose/filebrowser.yaml b/templates/compose/filebrowser.yaml index eb5ba9eb6b..e7b32dfc00 100644 --- a/templates/compose/filebrowser.yaml +++ b/templates/compose/filebrowser.yaml @@ -7,7 +7,7 @@ services: filebrowser: image: filebrowser/filebrowser:latest environment: - - SERVICE_FQDN_FILEBROWSER + - SERVICE_FQDN_FILEBROWSER_80 volumes: - type: bind source: ./srv From 795af8de52f3031264646004e02aa7d1b6962959 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 29 Sep 2024 20:05:02 +0200 Subject: [PATCH 12/42] Make sure key is not created with wrong private_key --- database/seeders/ProductionSeeder.php | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/database/seeders/ProductionSeeder.php b/database/seeders/ProductionSeeder.php index d0f0f10f40..2c56824c67 100644 --- a/database/seeders/ProductionSeeder.php +++ b/database/seeders/ProductionSeeder.php @@ -106,7 +106,8 @@ public function run(): void $ssh_keys_directory = Storage::disk('ssh-keys')->files(); $coolify_key = collect($ssh_keys_directory)->firstWhere(fn ($item) => str($item)->contains($coolify_key_name)); - $found = PrivateKey::find(0); + $server = Server::find(0); + $found = $server->privateKey; if ($found) { echo 'Private Key found in database.\n'; if ($coolify_key) { @@ -125,17 +126,7 @@ public function run(): void ]); $server->update(['user' => $user]); echo "SSH key found for the Coolify host machine (localhost).\n"; - } else { - PrivateKey::create( - [ - 'id' => 0, - 'team_id' => 0, - 'name' => 'localhost\'s key', - 'description' => 'The private key for the Coolify host machine (localhost).', - 'private_key' => 'Paste here you private key!!', - ] - ); echo "No SSH key found for the Coolify host machine (localhost).\n"; echo "Please read the following documentation (point 3) to fix it: https://coolify.io/docs/knowledge-base/server/openssh/\n"; echo "Your localhost connection won't work until then."; From cccd05f32290f06574a6c3a9dac438a43446f24e Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 29 Sep 2024 20:12:30 +0200 Subject: [PATCH 13/42] chore: Refactor code to improve SSH key handling and storage --- bootstrap/helpers/shared.php | 6 ++---- database/seeders/PopulateSshKeysDirectorySeeder.php | 1 - database/seeders/ProductionSeeder.php | 8 +------- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 350f168370..975edf9ca5 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -1236,8 +1236,6 @@ function parseLineForSudo(string $command, Server $server): string function get_public_ips() { try { - echo "Refreshing public ips!\n"; - $settings = \App\Models\InstanceSettings::get(); [$first, $second] = Process::concurrently(function (Pool $pool) { $pool->path(__DIR__)->command('curl -4s https://ifconfig.io'); $pool->path(__DIR__)->command('curl -6s https://ifconfig.io'); @@ -1251,7 +1249,7 @@ function get_public_ips() return; } - $settings->update(['public_ipv4' => $ipv4]); + InstanceSettings::get()->update(['public_ipv4' => $ipv4]); } } catch (\Exception $e) { echo "Error: {$e->getMessage()}\n"; @@ -1266,7 +1264,7 @@ function get_public_ips() return; } - $settings->update(['public_ipv6' => $ipv6]); + InstanceSettings::get()->update(['public_ipv6' => $ipv6]); } } catch (\Throwable $e) { echo "Error: {$e->getMessage()}\n"; diff --git a/database/seeders/PopulateSshKeysDirectorySeeder.php b/database/seeders/PopulateSshKeysDirectorySeeder.php index dc27d21b00..e2543ee02e 100644 --- a/database/seeders/PopulateSshKeysDirectorySeeder.php +++ b/database/seeders/PopulateSshKeysDirectorySeeder.php @@ -19,7 +19,6 @@ public function run() PrivateKey::chunk(100, function ($keys) { foreach ($keys as $key) { - echo 'Storing key: '.$key->name."\n"; $key->storeInFileSystem(); } }); diff --git a/database/seeders/ProductionSeeder.php b/database/seeders/ProductionSeeder.php index 2c56824c67..206f04d6b6 100644 --- a/database/seeders/ProductionSeeder.php +++ b/database/seeders/ProductionSeeder.php @@ -101,19 +101,13 @@ public function run(): void } if (! isCloud() && config('coolify.is_windows_docker_desktop') == false) { - echo "Checking localhost key.\n"; $coolify_key_name = '@host.docker.internal'; $ssh_keys_directory = Storage::disk('ssh-keys')->files(); $coolify_key = collect($ssh_keys_directory)->firstWhere(fn ($item) => str($item)->contains($coolify_key_name)); $server = Server::find(0); $found = $server->privateKey; - if ($found) { - echo 'Private Key found in database.\n'; - if ($coolify_key) { - echo "SSH key found for the Coolify host machine (localhost).\n"; - } - } else { + if (! $found) { if ($coolify_key) { $user = str($coolify_key)->before('@')->after('id.'); $coolify_key = Storage::disk('ssh-keys')->get($coolify_key); From 6fe31c26a33c7648e2d20f1bbf13ada57431477b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 30 Sep 2024 11:14:40 +0200 Subject: [PATCH 14/42] refactor: remove unnecessary code --- app/Models/EnvironmentVariable.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/Models/EnvironmentVariable.php b/app/Models/EnvironmentVariable.php index 138775abad..9f8e4b342f 100644 --- a/app/Models/EnvironmentVariable.php +++ b/app/Models/EnvironmentVariable.php @@ -126,11 +126,6 @@ public function realValue(): Attribute $env = $this->get_real_environment_variables($this->value, $resource); return data_get($env, 'value', $env); - if (is_string($env)) { - return $env; - } - - return $env->value; } ); } From a66011701512c720fe7865d582575bd7685c7274 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 30 Sep 2024 11:14:53 +0200 Subject: [PATCH 15/42] use latest helper in dev --- app/Models/InstanceSettings.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/Models/InstanceSettings.php b/app/Models/InstanceSettings.php index 27a181ee43..6a9876c9bd 100644 --- a/app/Models/InstanceSettings.php +++ b/app/Models/InstanceSettings.php @@ -85,4 +85,17 @@ public function getTitleDisplayName(): string return "[{$instanceName}]"; } + + public function helperVersion(): Attribute + { + return Attribute::make( + get: function () { + if (isDev()) { + return 'latest'; + } + + return $this->helper_version; + } + ); + } } From 8385b7dfe89aa4301122c142541793f693801898 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 30 Sep 2024 11:15:23 +0200 Subject: [PATCH 16/42] fix: handle edge case when build variables and env variables are in different format --- bootstrap/helpers/shared.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 975edf9ca5..9ff05085a9 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -3826,6 +3826,21 @@ function convertComposeEnvironmentToArray($environment) { $convertedServiceVariables = collect([]); if (isAssociativeArray($environment)) { + if ($environment instanceof Collection) { + $changedEnvironment = collect([]); + $environment->each(function ($value, $key) use ($changedEnvironment) { + $parts = explode('=', $value, 2); + if (count($parts) === 2) { + $key = $parts[0]; + $realValue = $parts[1] ?? ''; + $changedEnvironment->put($key, $realValue); + } else { + $changedEnvironment->put($key, $value); + } + }); + + return $changedEnvironment; + } $convertedServiceVariables = $environment; } else { foreach ($environment as $value) { From b6b4d936580b85904f66051f26ae952a2d50cdf3 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 30 Sep 2024 11:58:28 +0200 Subject: [PATCH 17/42] fix: compose based terminal --- .../Shared/ExecuteContainerCommand.php | 35 ++++++++++++------- .../execute-container-command.blade.php | 6 ++-- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/app/Livewire/Project/Shared/ExecuteContainerCommand.php b/app/Livewire/Project/Shared/ExecuteContainerCommand.php index d954436215..90419caed1 100644 --- a/app/Livewire/Project/Shared/ExecuteContainerCommand.php +++ b/app/Livewire/Project/Shared/ExecuteContainerCommand.php @@ -11,6 +11,8 @@ class ExecuteContainerCommand extends Component { + public $selected_container = 'default'; + public $container; public Collection $containers; @@ -83,11 +85,14 @@ public function loadContainers() $containers = getCurrentApplicationContainerStatus($server, $this->resource->id, includePullrequests: true); } foreach ($containers as $container) { - $payload = [ - 'server' => $server, - 'container' => $container, - ]; - $this->containers = $this->containers->push($payload); + // if container state is running + if (data_get($container, 'State') === 'running') { + $payload = [ + 'server' => $server, + 'container' => $container, + ]; + $this->containers = $this->containers->push($payload); + } } } elseif (data_get($this->parameters, 'database_uuid')) { if ($this->resource->isRunning()) { @@ -100,7 +105,6 @@ public function loadContainers() } } elseif (data_get($this->parameters, 'service_uuid')) { $this->resource->applications()->get()->each(function ($application) { - ray($application); if ($application->isRunning()) { $this->containers->push([ 'server' => $this->resource->server, @@ -131,9 +135,14 @@ public function loadContainers() #[On('connectToContainer')] public function connectToContainer() { + if ($this->selected_container === 'default') { + $this->dispatch('error', 'Please select a container.'); + + return; + } try { - $container_name = data_get($this->container, 'container.Names'); - if (is_null($container_name)) { + $container = collect($this->containers)->firstWhere('container.Names', $this->selected_container); + if (is_null($container)) { throw new \RuntimeException('Container not found.'); } $server = data_get($this->container, 'server'); @@ -141,11 +150,11 @@ public function connectToContainer() if ($server->isForceDisabled()) { throw new \RuntimeException('Server is disabled.'); } - - $this->dispatch('send-terminal-command', - true, - $container_name, - $server->uuid, + $this->dispatch( + 'send-terminal-command', + isset($container), + data_get($container, 'container.Names'), + data_get($container, 'server.uuid') ); } catch (\Throwable $e) { diff --git a/resources/views/livewire/project/shared/execute-container-command.blade.php b/resources/views/livewire/project/shared/execute-container-command.blade.php index c98e9ae19b..927e795ecf 100644 --- a/resources/views/livewire/project/shared/execute-container-command.blade.php +++ b/resources/views/livewire/project/shared/execute-container-command.blade.php @@ -20,9 +20,11 @@ @if (count($containers) > 0)
- - + @foreach ($containers as $container) + @if ($loop->first) + + @endif