An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
wip: dockerimage
Andras Bacsai9c22e0171668
diff --git a/app/Http/Livewire/Project/New/DockerImage.php b/app/Http/Livewire/Project/New/DockerImage.phpnew file mode 100644index 0000000000..5e1107e4de--- /dev/null+++ b/app/Http/Livewire/Project/New/DockerImage.php@@ -0,0 +1,73 @@+<?php++namespace App\Http\Livewire\Project\New;++use App\Models\Application;+use App\Models\Project;+use App\Models\StandaloneDocker;+use App\Models\SwarmDocker;+use Livewire\Component;+use Visus\Cuid2\Cuid2;+use Illuminate\Support\Str;++class DockerImage extends Component+{+ public string $dockerImage = '';+ public array $parameters;+ public array $query;+ public function mount()+ {+ $this->parameters = get_route_parameters();+ $this->query = request()->query();+ }+ public function submit()+ {+ $this->validate([+ 'dockerImage' => 'required'+ ]);+ $image = Str::of($this->dockerImage)->before(':');+ $tag = Str::of($this->dockerImage)->after(':') ?: 'latest';+ $destination_uuid = $this->query['destination'];+ $destination = StandaloneDocker::where('uuid', $destination_uuid)->first();+ if (!$destination) {+ $destination = SwarmDocker::where('uuid', $destination_uuid)->first();+ }+ if (!$destination) {+ throw new \Exception('Destination not found. What?!');+ }+ $destination_class = $destination->getMorphClass();++ $project = Project::where('uuid', $this->parameters['project_uuid'])->first();+ $environment = $project->load(['environments'])->environments->where('name', $this->parameters['environment_name'])->first();+ $application = Application::create([+ 'name' => 'docker-image-' . new Cuid2(7),+ 'repository_project_id' => 0,+ 'git_repository' => "coollabsio/coolify",+ 'git_branch' => 'main',+ 'build_pack' => 'dockerimage',+ 'ports_exposes' => 80,+ 'docker_registry_image_name' => $image,+ 'docker_registry_image_tag' => $tag,+ 'environment_id' => $environment->id,+ 'destination_id' => $destination->id,+ 'destination_type' => $destination_class,+ 'health_check_enabled' => false,+ ]);++ $fqdn = generateFqdn($destination->server, $application->uuid);+ $application->update([+ 'name' => 'docker-image-' . $application->uuid,+ 'fqdn' => $fqdn+ ]);++ redirect()->route('project.application.configuration', [+ 'application_uuid' => $application->uuid,+ 'environment_name' => $environment->name,+ 'project_uuid' => $project->uuid,+ ]);+ }+ public function render()+ {+ return view('livewire.project.new.docker-image');+ }+}diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.phpindex fb525a8dd1..3654bd50b5 100644--- a/resources/views/livewire/project/application/general.blade.php+++ b/resources/views/livewire/project/application/general.blade.php@@ -24,6 +24,7 @@<x-forms.select id="application.build_pack" label="Build Pack" required><option value="nixpacks">Nixpacks</option><option value="dockerfile">Dockerfile</option>+ <option value="dockerimage">Docker Image</option></x-forms.select>@if ($application->settings->is_static)<x-forms.select id="application.static_image" label="Static Image" required>diff --git a/resources/views/livewire/project/new/docker-image.blade.php b/resources/views/livewire/project/new/docker-image.blade.phpnew file mode 100644index 0000000000..3927247c7b--- /dev/null+++ b/resources/views/livewire/project/new/docker-image.blade.php@@ -0,0 +1,11 @@+<div>+ <h1>Create a new Application</h1>+ <div class="pb-4">You can deploy an existing Docker Image from any Registry.</div>+ <form wire:submit.prevent="submit">+ <div class="flex gap-2 pb-1">+ <h2>Docker Image</h2>+ <x-forms.button type="submit">Save</x-forms.button>+ </div>+ <x-forms.input rows="20" id="dockerImage" placeholder="nginx"></x-forms.textarea>+ </form>+</div>diff --git a/resources/views/livewire/project/new/select.blade.php b/resources/views/livewire/project/new/select.blade.phpindex 376f143dc7..4e96cdf765 100644--- a/resources/views/livewire/project/new/select.blade.php+++ b/resources/views/livewire/project/new/select.blade.php@@ -62,6 +62,16 @@</div></div></div>+ <div class="box group" wire:click="setType('docker-image')">+ <div class="flex flex-col mx-6">+ <div class="font-bold text-white group-hover:text-white">+ Based on an existing Docker Image+ </div>+ <div class="text-xs group-hover:text-white">+ You can deploy an existing Docker Image form any Registry.+ </div>+ </div>+ </div></div><h2 class="py-4">Databases</h2><div class="grid justify-start grid-cols-1 gap-2 text-left xl:grid-cols-3">diff --git a/resources/views/project/new.blade.php b/resources/views/project/new.blade.phpindex 8d69f95e0b..5b6ee1029f 100644--- a/resources/views/project/new.blade.php+++ b/resources/views/project/new.blade.php@@ -9,6 +9,8 @@<livewire:project.new.simple-dockerfile :type="$type" />@elseif ($type === 'docker-compose-empty')<livewire:project.new.docker-compose :type="$type" />+ @elseif ($type === 'docker-image')+ <livewire:project.new.docker-image :type="$type" />@else<livewire:project.new.select />@endif