parameters = get_route_parameters(); if (isDev()) { $this->existingPostgresqlUrl = 'postgres://coolify:password@coolify-db:5432'; } $projectUuid = data_get($this->parameters, 'project_uuid'); $this->environments = Project::whereUuid($projectUuid)->first()->environments; $this->selectedEnvironment = data_get($this->parameters, 'environment_uuid'); } public function render() { return view('livewire.project.new.select'); } public function updatedSelectedEnvironment() { return redirect()->route('project.resource.create', [ 'project_uuid' => $this->parameters['project_uuid'], 'environment_uuid' => $this->selectedEnvironment, ]); } public function loadServices() { $services = get_service_templates(true); $services = collect($services)->map(function ($service, $key) { $default_logo = 'images/default.webp'; $logo = data_get($service, 'logo', $default_logo); $local_logo_path = public_path($logo); return [ 'name' => str($key)->headline(), 'logo' => asset($logo), 'logo_github_url' => file_exists($local_logo_path) ? 'https://raw.githubusercontent.com/coollabsio/coolify/refs/heads/main/public/'.$logo : asset($default_logo), ] + (array) $service; })->all(); $gitBasedApplications = [ [ 'id' => 'public', 'name' => 'Public Repository', 'description' => 'You can deploy any kind of public repositories from the supported git providers.', 'logo' => asset('svgs/git.svg'), ], [ 'id' => 'private-gh-app', 'name' => 'Private Repository (with GitHub App)', 'description' => 'You can deploy public & private repositories through your GitHub Apps.', 'logo' => asset('svgs/github.svg'), ], [ 'id' => 'private-deploy-key', 'name' => 'Private Repository (with Deploy Key)', 'description' => 'You can deploy private repositories with a deploy key.', 'logo' => asset('svgs/git.svg'), ], ]; $dockerBasedApplications = [ [ 'id' => 'dockerfile', 'name' => 'Dockerfile', 'description' => 'You can deploy a simple Dockerfile, without Git.', 'logo' => asset('svgs/docker.svg'), ], [ 'id' => 'docker-compose-empty', 'name' => 'Docker Compose Empty', 'description' => 'You can deploy complex application easily with Docker Compose, without Git.', 'logo' => asset('svgs/docker.svg'), ], [ 'id' => 'docker-image', 'name' => 'Docker Image', 'description' => 'You can deploy an existing Docker Image from any Registry, without Git.', 'logo' => asset('svgs/docker.svg'), ], ]; $databases = [ [ 'id' => 'postgresql', 'name' => 'PostgreSQL', 'description' => 'PostgreSQL is an object-relational database known for its robustness, advanced features, and strong standards compliance.', 'logo' => ' ', ], [ 'id' => 'mysql', 'name' => 'MySQL', 'description' => 'MySQL is an open-source relational database management system. ', 'logo' => '', ], [ 'id' => 'mariadb', 'name' => 'MariaDB', 'description' => 'MariaDB is a community-developed, commercially supported fork of the MySQL relational database management system, intended to remain free and open-source.', 'logo' => '', ], [ 'id' => 'redis', 'name' => 'Redis', 'description' => 'Redis is a source-available, in-memory storage, used as a distributed, in-memory key–value database, cache and message broker, with optional durability.', 'logo' => '', ], [ 'id' => 'keydb', 'name' => 'KeyDB', 'description' => 'KeyDB is a database that offers high performance, low latency, and scalability for various data structures and workloads.', 'logo' => '
', ], [ 'id' => 'dragonfly', 'name' => 'Dragonfly', 'description' => 'Dragonfly DB is a drop-in Redis replacement that delivers 25x more throughput and 12x faster snapshotting than Redis.', 'logo' => '', ], [ 'id' => 'mongodb', 'name' => 'MongoDB', 'description' => 'MongoDB is a source-available, cross-platform, document-oriented database program.', 'logo' => '', ], [ 'id' => 'clickhouse', 'name' => 'ClickHouse', 'description' => 'ClickHouse is a column-oriented database that supports real-time analytics, business intelligence, observability, ML and GenAI, and more.', 'logo' => '', ], ]; return [ 'services' => $services, 'gitBasedApplications' => $gitBasedApplications, 'dockerBasedApplications' => $dockerBasedApplications, 'databases' => $databases, ]; } public function instantSave() { if ($this->includeSwarm) { $this->servers = $this->allServers; } else { if ($this->allServers instanceof Collection) { $this->servers = $this->allServers->where('settings.is_swarm_worker', false)->where('settings.is_swarm_manager', false)->where('settings.is_build_server', false); } else { $this->servers = $this->allServers; } } } public function setType(string $type) { $type = str($type)->lower()->slug()->value(); if ($this->loading) { return; } $this->loading = true; $this->type = $type; switch ($type) { case 'postgresql': case 'mysql': case 'mariadb': case 'redis': case 'keydb': case 'dragonfly': case 'clickhouse': case 'mongodb': $this->isDatabase = true; $this->includeSwarm = false; if ($this->allServers instanceof Collection) { $this->servers = $this->allServers->where('settings.is_swarm_worker', false)->where('settings.is_swarm_manager', false)->where('settings.is_build_server', false); } else { $this->servers = $this->allServers; } break; } if (str($type)->startsWith('one-click-service') || str($type)->startsWith('docker-compose-empty')) { $this->isDatabase = true; $this->includeSwarm = false; if ($this->allServers instanceof Collection) { $this->servers = $this->allServers->where('settings.is_swarm_worker', false)->where('settings.is_swarm_manager', false)->where('settings.is_build_server', false); } else { $this->servers = $this->allServers; } } if ($type === 'existing-postgresql') { $this->current_step = $type; return; } if (count($this->servers) === 1) { $server = $this->servers->first(); if ($server instanceof Server) { $this->setServer($server); } } if (! is_null($this->server)) { $foundServer = $this->servers->where('id', $this->server->id)->first(); if ($foundServer) { return $this->setServer($foundServer); } } $this->current_step = 'servers'; } public function setServer(Server $server) { $this->server_id = $server->id; $this->server = $server; $this->standaloneDockers = $server->standaloneDockers; $this->swarmDockers = $server->swarmDockers; $count = count($this->standaloneDockers) + count($this->swarmDockers); if ($count === 1) { $docker = $this->standaloneDockers->first() ?? $this->swarmDockers->first(); if ($docker) { $this->setDestination($docker->uuid); return $this->whatToDoNext(); } } $this->current_step = 'destinations'; } public function setDestination(string $destination_uuid) { $this->destination_uuid = $destination_uuid; return $this->whatToDoNext(); } public function setPostgresqlType(string $type) { $this->postgresql_type = $type; return redirect()->route('project.resource.create', [ 'project_uuid' => $this->parameters['project_uuid'], 'environment_uuid' => $this->parameters['environment_uuid'], 'type' => $this->type, 'destination' => $this->destination_uuid, 'server_id' => $this->server_id, 'database_image' => $this->postgresql_type, ]); } public function whatToDoNext() { if ($this->type === 'postgresql') { $this->current_step = 'select-postgresql-type'; } else { return redirect()->route('project.resource.create', [ 'project_uuid' => $this->parameters['project_uuid'], 'environment_uuid' => $this->parameters['environment_uuid'], 'type' => $this->type, 'destination' => $this->destination_uuid, 'server_id' => $this->server_id, ]); } } public function loadServers() { $this->servers = Server::isUsable()->get()->sortBy('name'); $this->allServers = $this->servers; if ($this->allServers && $this->allServers->isNotEmpty()) { $this->onlyBuildServerAvailable = $this->allServers->every(function ($server) { return $server->isBuildServer(); }); } } }