diff --git a/.env.production b/.env.production index 32652711e..5d9eeaaaf 100644 --- a/.env.production +++ b/.env.production @@ -4,3 +4,11 @@ APP_KEY= DB_PASSWORD= REDIS_PASSWORD= + +PUSHER_APP_ID= +PUSHER_APP_KEY= +PUSHER_APP_SECRET= + +VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}" +VITE_PUSHER_HOST="${PUSHER_HOST}" +VITE_PUSHER_PORT="${PUSHER_PORT}" diff --git a/app/Providers/ApplicationDeploymentFinished.php b/app/Events/ApplicationDeploymentFinished.php similarity index 54% rename from app/Providers/ApplicationDeploymentFinished.php rename to app/Events/ApplicationDeploymentFinished.php index 627ae03a1..fb43f72c5 100644 --- a/app/Providers/ApplicationDeploymentFinished.php +++ b/app/Events/ApplicationDeploymentFinished.php @@ -1,6 +1,6 @@ teamId = auth()->user()->currentTeam()->id; } + /** + * Get the channels the event should broadcast on. + * + * @return array + */ public function broadcastOn(): array { return [ - new Channel('custom-channel'), + new PrivateChannel("custom.{$this->teamId}"), ]; } } diff --git a/app/Http/Livewire/Dashboard.php b/app/Http/Livewire/Dashboard.php index b7219864d..05bef207d 100644 --- a/app/Http/Livewire/Dashboard.php +++ b/app/Http/Livewire/Dashboard.php @@ -10,7 +10,6 @@ class Dashboard extends Component { public $projects = []; public $servers = []; - public function mount() { $this->servers = Server::ownedByCurrentTeam()->get(); diff --git a/app/Http/Livewire/Project/Application/Configuration.php b/app/Http/Livewire/Project/Application/Configuration.php index 7cb2939f2..51d964d37 100644 --- a/app/Http/Livewire/Project/Application/Configuration.php +++ b/app/Http/Livewire/Project/Application/Configuration.php @@ -26,7 +26,7 @@ public function mount() return redirect()->route('dashboard'); } $this->application = $application; - $mainServer = $application->destination->server; + $mainServer = $this->application->destination->server; $servers = Server::ownedByCurrentTeam()->get(); $this->servers = $servers->filter(function ($server) use ($mainServer) { return $server->id != $mainServer->id; diff --git a/app/Http/Livewire/Project/Application/DeploymentNavbar.php b/app/Http/Livewire/Project/Application/DeploymentNavbar.php index 830a24fab..2cee34d11 100644 --- a/app/Http/Livewire/Project/Application/DeploymentNavbar.php +++ b/app/Http/Livewire/Project/Application/DeploymentNavbar.php @@ -17,11 +17,7 @@ class DeploymentNavbar extends Component public Application $application; public Server $server; public bool $is_debug_enabled = false; - protected $listeners = ['deploymentFinished','echo:custom-channel,ApplicationDeploymentFinished' => 'notifyNewOrder']; - - public function notifyNewOrder() { - ray('New order received'); - } + protected $listeners = ['deploymentFinished']; public function mount() { $this->application = Application::find($this->application_deployment_queue->application_id); diff --git a/app/Http/Livewire/Project/Application/Heading.php b/app/Http/Livewire/Project/Application/Heading.php index 3d5af34da..9a212867a 100644 --- a/app/Http/Livewire/Project/Application/Heading.php +++ b/app/Http/Livewire/Project/Application/Heading.php @@ -11,11 +11,24 @@ class Heading extends Component { + protected string $deploymentUuid; public Application $application; public array $parameters; + public function getListeners() + { + $teamId = auth()->user()->currentTeam()->id; + return [ + "echo-private:custom.{$teamId},ApplicationDeploymentFinished" => 'updateStatus', + ]; + } - protected string $deploymentUuid; - + public function updateStatus($message) + { + $applicationUuid = data_get($message, 'applicationUuid'); + if ($this->application->uuid === $applicationUuid) { + $this->application->status = data_get($message, 'status'); + } + } public function mount() { $this->parameters = get_route_parameters(); diff --git a/app/Http/Livewire/Server/Form.php b/app/Http/Livewire/Server/Form.php index efca800c2..512a7f68a 100644 --- a/app/Http/Livewire/Server/Form.php +++ b/app/Http/Livewire/Server/Form.php @@ -44,6 +44,7 @@ public function mount() { $this->wildcard_domain = $this->server->settings->wildcard_domain; $this->cleanup_after_percentage = $this->server->settings->cleanup_after_percentage; + $this->validateServer(); } public function serverRefresh($install = true) { diff --git a/app/Jobs/ApplicationDeploymentNewJob.php b/app/Jobs/ApplicationDeploymentNewJob.php index b082e82fa..40301bbe9 100644 --- a/app/Jobs/ApplicationDeploymentNewJob.php +++ b/app/Jobs/ApplicationDeploymentNewJob.php @@ -4,6 +4,7 @@ use App\Enums\ApplicationDeploymentStatus; use App\Enums\ProxyTypes; +use App\Events\ApplicationDeploymentFinished; use App\Models\Application; use App\Models\ApplicationDeploymentQueue; use App\Models\ApplicationPreview; @@ -14,7 +15,6 @@ use App\Models\SwarmDocker; use App\Notifications\Application\DeploymentFailed; use App\Notifications\Application\DeploymentSuccess; -use App\Providers\ApplicationDeploymentFinished; use App\Traits\ExecuteRemoteCommand; use Exception; use Illuminate\Bus\Queueable; @@ -102,7 +102,7 @@ public function handle() }); } $this->next(ApplicationDeploymentStatus::FINISHED->value); - ApplicationDeploymentFinished::dispatch($this->application, $this->deployment); + ApplicationDeploymentFinished::dispatch($this->application->uuid, ApplicationDeploymentStatus::FINISHED->value); } catch (Throwable $exception) { $this->fail($exception); } finally { diff --git a/app/Models/Server.php b/app/Models/Server.php index 1806f5ceb..37a5ffe2a 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -382,17 +382,17 @@ public function isSwarm() public function validateConnection() { $server = Server::find($this->id); - if ($this->skipServer()) { + if ($server->skipServer()) { return false; } - $uptime = instant_remote_process(['uptime'], $this, false); + $uptime = instant_remote_process(['uptime'], $server, false); if (!$uptime) { - $this->settings()->update([ + $server->settings()->update([ 'is_reachable' => false, ]); return false; } else { - $this->settings()->update([ + $server->settings()->update([ 'is_reachable' => true, ]); $server->update([ @@ -400,8 +400,8 @@ public function validateConnection() ]); } - if (data_get($this, 'unreachable_notification_sent') === true) { - $this->team->notify(new Revived($this)); + if (data_get($server, 'unreachable_notification_sent') === true) { + $server->team->notify(new Revived($server)); $server->update(['unreachable_notification_sent' => false]); } diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index b4b9d1c0c..b964f2c44 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -8,31 +8,15 @@ class EventServiceProvider extends ServiceProvider { - /** - * The event to listener mappings for the application. - * - * @var array> - */ protected $listen = [ // Registered::class => [ // SendEmailVerificationNotification::class, // ], - ApplicationDeploymentFinished::class => [ - SendDeploymentNotification::class, - ], ]; - - /** - * Register any events for your application. - */ public function boot(): void { // } - - /** - * Determine if events and listeners should be automatically discovered. - */ public function shouldDiscoverEvents(): bool { return false; diff --git a/app/Providers/SendDeploymentNotification.php b/app/Providers/SendDeploymentNotification.php deleted file mode 100644 index b4f3d6b46..000000000 --- a/app/Providers/SendDeploymentNotification.php +++ /dev/null @@ -1,28 +0,0 @@ - env('BROADCAST_DRIVER', 'log'), + 'default' => env('BROADCAST_DRIVER', 'pusher'), /* |-------------------------------------------------------------------------- @@ -32,9 +32,9 @@ 'pusher' => [ 'driver' => 'pusher', - 'key' => env('PUSHER_APP_KEY'), - 'secret' => env('PUSHER_APP_SECRET'), - 'app_id' => env('PUSHER_APP_ID'), + 'key' => env('PUSHER_APP_KEY', 'coolify'), + 'secret' => env('PUSHER_APP_SECRET', 'coolify'), + 'app_id' => env('PUSHER_APP_ID', 'coolify'), 'options' => [ 'host' => 'coolify-soketi', 'port' => env('PUSHER_PORT', 6001), diff --git a/database/seeders/StandaloneDockerSeeder.php b/database/seeders/StandaloneDockerSeeder.php index 1e9a749dd..9f67de710 100644 --- a/database/seeders/StandaloneDockerSeeder.php +++ b/database/seeders/StandaloneDockerSeeder.php @@ -13,11 +13,11 @@ class StandaloneDockerSeeder extends Seeder */ public function run(): void { - // StandaloneDocker::create([ - // 'id' => 0, - // 'name' => 'Standalone Docker 1', - // 'network' => 'coolify', - // 'server_id' => 0, - // ]); + StandaloneDocker::create([ + 'id' => 0, + 'name' => 'Standalone Docker 1', + 'network' => 'coolify', + 'server_id' => 0, + ]); } } diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 25f3d5a7b..d52c83b7d 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -21,6 +21,10 @@ services: SSL_MODE: "off" AUTORUN_LARAVEL_STORAGE_LINK: "false" AUTORUN_LARAVEL_MIGRATION: "false" + PUSHER_HOST: "${PUSHER_HOST:-127.0.0.1}" + PUSHER_APP_ID: "${PUSHER_APP_ID:-coolify}" + PUSHER_APP_KEY: "${PUSHER_APP_KEY:-coolify}" + PUSHER_APP_SECRET: "${PUSHER_APP_SECRET:-coolify}" volumes: - .:/var/www/html/:cached postgres: @@ -45,15 +49,22 @@ services: - /data/coolify/_volumes/redis/:/data # - coolify-redis-data-dev:/data soketi: + env_file: + - .env ports: - "${FORWARD_SOKETI_PORT:-6001}:6001" - - "${FORWARD_SOKETI_METRICS_SERVER_PORT:-9601}:9601" environment: SOKETI_DEBUG: "true" - SOKETI_METRICS_SERVER_PORT: "${SOKETI_METRICS_SERVER_PORT:-9601}" + SOKETI_DEFAULT_APP_ID: "${PUSHER_APP_ID:-coolify}" + SOKETI_DEFAULT_APP_KEY: "${PUSHER_APP_KEY:-coolify}" + SOKETI_DEFAULT_APP_SECRET: "${PUSHER_APP_SECRET:-coolify}" vite: image: node:20 working_dir: /var/www/html + environment: + VITE_PUSHER_HOST: "${PUSHER_HOST:-127.0.0.1}" + VITE_PUSHER_APP_KEY: "${PUSHER_APP_KEY:-coolify}" + VITE_PUSHER_PORT: "${FORWARD_SOKETI_PORT:-6001}" ports: - "${VITE_PORT:-5173}:${VITE_PORT:-5173}" volumes: @@ -67,14 +78,14 @@ services: - /var/run/docker.sock:/var/run/docker.sock - /data/coolify/:/data/coolify # - coolify-data-dev:/data/coolify - remote-host: - <<: *testing-host-base - container_name: coolify-remote-host - volumes: - - /:/host - - /var/run/docker.sock:/var/run/docker.sock - - /data/coolify/:/data/coolify - # - coolify-data-dev:/data/coolify + # remote-host: + # <<: *testing-host-base + # container_name: coolify-remote-host + # volumes: + # - /:/host + # - /var/run/docker.sock:/var/run/docker.sock + # - /data/coolify/:/data/coolify + # # - coolify-data-dev:/data/coolify mailpit: image: "axllent/mailpit:latest" container_name: coolify-mail diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index ca6b42348..4ba513d5a 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -1,7 +1,7 @@ version: '3.8' services: coolify: - image: "ghcr.io/coollabsio/coolify:${LATEST_IMAGE:-4.0.0-beta.20}" + image: "ghcr.io/coollabsio/coolify:${LATEST_IMAGE:-4.0.0-beta.153}" volumes: - type: bind source: /data/coolify/source/.env @@ -35,6 +35,13 @@ services: - PHP_PM_START_SERVERS=1 - PHP_PM_MIN_SPARE_SERVERS=1 - PHP_PM_MAX_SPARE_SERVERS=10 + - PUSHER_HOST + - PUSHER_APP_ID + - PUSHER_APP_KEY + - PUSHER_APP_SECRET + - VITE_PUSHER_HOST + - VITE_PUSHER_APP_KEY + - VITE_PUSHER_PORT - SELF_HOSTED - WAITLIST - SUBSCRIPTION_PROVIDER @@ -111,6 +118,12 @@ services: interval: 2s retries: 5 timeout: 2s + soketi: + environment: + SOKETI_DEBUG: "${SOKETI_DEBUG:-false}" + SOKETI_DEFAULT_APP_ID: "${PUSHER_APP_ID}" + SOKETI_DEFAULT_APP_KEY: "${PUSHER_APP_KEY}" + SOKETI_DEFAULT_APP_SECRET: "${PUSHER_APP_SECRET}" volumes: coolify-db: name: coolify-db diff --git a/resources/js/app.js b/resources/js/app.js index d7fb2541d..053b277c1 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -9,14 +9,15 @@ window.Pusher = Pusher; window.Echo = new Echo({ broadcaster: 'pusher', - cluster: import.meta.env.VITE_PUSHER_HOST, - key: import.meta.env.VITE_PUSHER_APP_KEY, - wsHost: import.meta.env.VITE_PUSHER_HOST, + cluster: import.meta.env.VITE_PUSHER_HOST ?? '127.0.0.1', + key: import.meta.env.VITE_PUSHER_APP_KEY ?? 'coolify', + wsHost: import.meta.env.VITE_PUSHER_HOST ?? '127.0.0.1', wsPort: import.meta.env.VITE_PUSHER_PORT, wssPort: import.meta.env.VITE_PUSHER_PORT, forceTLS: false, - encrypted: false, - disableStats: true, + encrypted: true, + disableStats: false, + enableLogging: true, enabledTransports: ['ws', 'wss'], }); @@ -30,6 +31,4 @@ app.component("magic-bar", MagicBar); app.mount("#vue"); -window.Echo.channel("custom-channel").listen("ApplicationDeploymentFinished", (e) => { - console.log(e); -}); + diff --git a/resources/views/livewire/project/application/heading.blade.php b/resources/views/livewire/project/application/heading.blade.php index ca76d38e8..3a197e810 100644 --- a/resources/views/livewire/project/application/heading.blade.php +++ b/resources/views/livewire/project/application/heading.blade.php @@ -1,4 +1,4 @@ -