commit
774a245e84
100
app/Console/Commands/ResourcesDelete.php
Normal file
100
app/Console/Commands/ResourcesDelete.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Application;
|
||||
use App\Models\Service;
|
||||
use App\Models\StandalonePostgresql;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use function Laravel\Prompts\confirm;
|
||||
use function Laravel\Prompts\select;
|
||||
|
||||
class ResourcesDelete extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'resources:delete';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Delete a resource from the database';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$resource = select(
|
||||
'What resource do you want to delete?',
|
||||
['Application', 'Database', 'Service'],
|
||||
);
|
||||
if ($resource === 'Application') {
|
||||
$this->deleteApplication();
|
||||
} elseif ($resource === 'Database') {
|
||||
$this->deleteDatabase();
|
||||
} elseif ($resource === 'Service') {
|
||||
$this->deleteService();
|
||||
}
|
||||
}
|
||||
private function deleteApplication()
|
||||
{
|
||||
$applications = Application::all();
|
||||
if ($applications->count() === 0) {
|
||||
$this->error('There are no applications to delete.');
|
||||
return;
|
||||
}
|
||||
$application = select(
|
||||
'What application do you want to delete?',
|
||||
$applications->pluck('name')->toArray(),
|
||||
);
|
||||
$application = $applications->where('name', $application)->first();
|
||||
$confirmed = confirm("Are you sure you want to delete {$application->name}?");
|
||||
if (!$confirmed) {
|
||||
return;
|
||||
}
|
||||
$application->delete();
|
||||
}
|
||||
private function deleteDatabase()
|
||||
{
|
||||
$databases = StandalonePostgresql::all();
|
||||
if ($databases->count() === 0) {
|
||||
$this->error('There are no databases to delete.');
|
||||
return;
|
||||
}
|
||||
$database = select(
|
||||
'What database do you want to delete?',
|
||||
$databases->pluck('name')->toArray(),
|
||||
);
|
||||
$database = $databases->where('name', $database)->first();
|
||||
$confirmed = confirm("Are you sure you want to delete {$database->name}?");
|
||||
if (!$confirmed) {
|
||||
return;
|
||||
}
|
||||
$database->delete();
|
||||
}
|
||||
private function deleteService()
|
||||
{
|
||||
$services = Service::all();
|
||||
if ($services->count() === 0) {
|
||||
$this->error('There are no services to delete.');
|
||||
return;
|
||||
}
|
||||
$service = select(
|
||||
'What service do you want to delete?',
|
||||
$services->pluck('name')->toArray(),
|
||||
);
|
||||
$service = $services->where('name', $service)->first();
|
||||
$confirmed = confirm("Are you sure you want to delete {$service->name}?");
|
||||
if (!$confirmed) {
|
||||
return;
|
||||
}
|
||||
$service->delete();
|
||||
}
|
||||
}
|
@ -8,14 +8,14 @@ use Illuminate\Support\Facades\Hash;
|
||||
|
||||
use function Laravel\Prompts\password;
|
||||
|
||||
class ResetRootPassword extends Command
|
||||
class UsersResetRoot extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'app:reset-root-password';
|
||||
protected $signature = 'users:reset-root';
|
||||
|
||||
/**
|
||||
* The console command description.
|
@ -7,6 +7,7 @@ use Livewire\Component;
|
||||
|
||||
class All extends Component
|
||||
{
|
||||
public bool $isHeaderVisible = true;
|
||||
public $resource;
|
||||
protected $listeners = ['refreshStorages', 'submit'];
|
||||
|
||||
|
@ -11,6 +11,7 @@ class Show extends Component
|
||||
public LocalPersistentVolume $storage;
|
||||
public bool $isReadOnly = false;
|
||||
public ?string $modalId = null;
|
||||
public bool $isFirst = true;
|
||||
|
||||
protected $rules = [
|
||||
'storage.name' => 'required|string',
|
||||
|
@ -18,10 +18,16 @@ class Application extends BaseModel
|
||||
]);
|
||||
});
|
||||
static::deleting(function ($application) {
|
||||
// Stop Container
|
||||
instant_remote_process(
|
||||
["docker rm -f {$application->uuid}"],
|
||||
$application->destination->server,
|
||||
false
|
||||
);
|
||||
$application->settings()->delete();
|
||||
$storages = $application->persistentStorages()->get();
|
||||
foreach ($storages as $storage) {
|
||||
instant_remote_process(["docker volume rm -f $storage->name"], $application->destination->server);
|
||||
instant_remote_process(["docker volume rm -f $storage->name"], $application->destination->server, false);
|
||||
}
|
||||
$application->persistentStorages()->delete();
|
||||
$application->environment_variables()->delete();
|
||||
@ -233,7 +239,7 @@ class Application extends BaseModel
|
||||
}
|
||||
public function isHealthcheckDisabled(): bool
|
||||
{
|
||||
if (data_get($this, 'dockerfile') || data_get($this, 'build_pack') === 'dockerfile' || data_get($this,'health_check_enabled') === false) {
|
||||
if (data_get($this, 'dockerfile') || data_get($this, 'build_pack') === 'dockerfile' || data_get($this, 'health_check_enabled') === false) {
|
||||
ray('dockerfile');
|
||||
return true;
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Illuminate\Support\Str;
|
||||
use Spatie\Url\Url;
|
||||
|
||||
class Service extends BaseModel
|
||||
{
|
||||
@ -20,6 +19,7 @@ class Service extends BaseModel
|
||||
static::deleted(function ($service) {
|
||||
$storagesToDelete = collect([]);
|
||||
foreach ($service->applications()->get() as $application) {
|
||||
instant_remote_process(["docker rm -f {$application->name}-{$service->uuid}"], $service->server, false);
|
||||
$storages = $application->persistentStorages()->get();
|
||||
foreach ($storages as $storage) {
|
||||
$storagesToDelete->push($storage);
|
||||
@ -27,6 +27,7 @@ class Service extends BaseModel
|
||||
$application->persistentStorages()->delete();
|
||||
}
|
||||
foreach ($service->databases()->get() as $database) {
|
||||
instant_remote_process(["docker rm -f {$database->name}-{$service->uuid}"], $service->server, false);
|
||||
$storages = $database->persistentStorages()->get();
|
||||
foreach ($storages as $storage) {
|
||||
$storagesToDelete->push($storage);
|
||||
@ -318,11 +319,7 @@ class Service extends BaseModel
|
||||
);
|
||||
} else if ($type->value() === 'volume') {
|
||||
$slug = Str::slug($source, '-');
|
||||
if ($isNew) {
|
||||
$name = "{$savedService->service->uuid}-{$slug}";
|
||||
} else {
|
||||
$name = "{$savedService->service->uuid}_{$slug}";
|
||||
}
|
||||
$name = "{$savedService->service->uuid}_{$slug}";
|
||||
if (is_string($volume)) {
|
||||
$source = Str::of($volume)->before(':');
|
||||
$target = Str::of($volume)->after(':')->beforeLast(':');
|
||||
|
@ -29,9 +29,20 @@ class StandalonePostgresql extends BaseModel
|
||||
]);
|
||||
});
|
||||
static::deleted(function ($database) {
|
||||
// Stop Container
|
||||
instant_remote_process(
|
||||
["docker rm -f {$database->uuid}"],
|
||||
$database->destination->server,
|
||||
false
|
||||
);
|
||||
// Stop TCP Proxy
|
||||
if ($database->is_public) {
|
||||
instant_remote_process(["docker rm -f {$database->uuid}-proxy"], $database->destination->server, false);
|
||||
}
|
||||
$database->scheduledBackups()->delete();
|
||||
$database->persistentStorages()->delete();
|
||||
$database->environment_variables()->delete();
|
||||
// Remove Volume
|
||||
instant_remote_process(['docker volume rm postgres-data-' . $database->uuid], $database->destination->server, false);
|
||||
});
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ return [
|
||||
|
||||
// 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.59',
|
||||
'release' => '4.0.0-beta.60',
|
||||
// When left empty or `null` the Laravel environment will be used
|
||||
'environment' => config('app.env'),
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
<?php
|
||||
|
||||
return '4.0.0-beta.59';
|
||||
return '4.0.0-beta.60';
|
||||
|
@ -34,14 +34,14 @@ services:
|
||||
POSTGRES_DB: "${DB_DATABASE:-coolify}"
|
||||
POSTGRES_HOST_AUTH_METHOD: "trust"
|
||||
volumes:
|
||||
- /data/coolify/_volumes/database/:/var/lib/postgresql/data
|
||||
- ./_data/coolify/_volumes/database/:/var/lib/postgresql/data
|
||||
redis:
|
||||
ports:
|
||||
- "${FORWARD_REDIS_PORT:-6379}:6379"
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- /data/coolify/_volumes/redis/:/data
|
||||
- ./_data/coolify/_volumes/redis/:/data
|
||||
vite:
|
||||
image: node:19
|
||||
working_dir: /var/www/html
|
||||
@ -56,7 +56,7 @@ services:
|
||||
volumes:
|
||||
- /:/host
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- /data/coolify/:/data/coolify
|
||||
- ./_data/coolify/:/data/coolify
|
||||
mailpit:
|
||||
image: "axllent/mailpit:latest"
|
||||
container_name: coolify-mail
|
||||
@ -76,6 +76,6 @@ services:
|
||||
MINIO_ACCESS_KEY: "${MINIO_ACCESS_KEY:-minioadmin}"
|
||||
MINIO_SECRET_KEY: "${MINIO_SECRET_KEY:-minioadmin}"
|
||||
volumes:
|
||||
- /data/coolify/_volumes/minio/:/data
|
||||
- ./_data/coolify/_volumes/minio/:/data
|
||||
networks:
|
||||
- coolify
|
||||
|
@ -1,13 +1,17 @@
|
||||
<dialog id="composeModal" class="modal" x-data="{ raw: true }">
|
||||
<form method="dialog" class="flex flex-col gap-2 rounded max-w-7xl modal-box" wire:submit.prevent='submit'>
|
||||
<div class="flex items-end gap-2">
|
||||
<h1>Docker Compose</h1>
|
||||
<div x-cloak x-show="raw">
|
||||
<x-forms.button class="w-64" @click.prevent="raw = !raw">Check Deployable Compose</x-forms.button>
|
||||
<x-forms.button class="w-64" @click.prevent="raw = !raw">Show Deployable Compose</x-forms.button>
|
||||
</div>
|
||||
<div x-cloak x-show="raw === false">
|
||||
<x-forms.button class="w-64" @click.prevent="raw = !raw">Show Source
|
||||
Compose</x-forms.button>
|
||||
</div>
|
||||
</div>
|
||||
<div>Volume names are updated upon save. The service UUID will be added as a prefix to all volumes, to prevent name collision. <br>To see the actual volume names, check the Deployable Compose file, or go to Storage menu.</div>
|
||||
|
||||
<div x-cloak x-show="raw">
|
||||
<x-forms.textarea rows="20" id="raw">
|
||||
</x-forms.textarea>
|
||||
|
@ -7,6 +7,8 @@
|
||||
<a :class="activeTab === 'service-stack' && 'text-white'"
|
||||
@click.prevent="activeTab = 'service-stack'; window.location.hash = 'service-stack'"
|
||||
href="#">Service Stack</a>
|
||||
<a :class="activeTab === 'storages' && 'text-white'"
|
||||
@click.prevent="activeTab = 'storages'; window.location.hash = 'storages'" href="#">Storages</a>
|
||||
<a :class="activeTab === 'environment-variables' && 'text-white'"
|
||||
@click.prevent="activeTab = 'environment-variables'; window.location.hash = 'environment-variables'"
|
||||
href="#">Environment
|
||||
@ -34,7 +36,7 @@
|
||||
</div>
|
||||
</form>
|
||||
<div class="grid grid-cols-1 gap-2 pt-4 xl:grid-cols-3">
|
||||
@foreach ($service->applications as $application)
|
||||
@foreach ($applications as $application)
|
||||
<div @class([
|
||||
'border-l border-dashed border-red-500' => Str::of(
|
||||
$application->status)->contains(['exited']),
|
||||
@ -98,6 +100,46 @@
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div x-cloak x-show="activeTab === 'storages'">
|
||||
@foreach ($applications as $application)
|
||||
@if ($loop->first)
|
||||
<livewire:project.shared.storages.all :resource="$application" />
|
||||
@else
|
||||
<livewire:project.shared.storages.all :resource="$application" :isHeaderVisible="false" />
|
||||
@endif
|
||||
@if ($application->fileStorages()->get()->count() > 0)
|
||||
<h5 class="py-4">Mounted Files/Dirs (binds)</h5>
|
||||
<div class="flex flex-col gap-4">
|
||||
@foreach ($application->fileStorages()->get()->sort() as $fileStorage)
|
||||
<livewire:project.service.file-storage :fileStorage="$fileStorage"
|
||||
wire:key="{{ $loop->index }}" />
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
@endforeach
|
||||
@foreach ($databases as $database)
|
||||
@if ($loop->first)
|
||||
<h3 class="pt-4">{{ Str::headline($database->name) }}</h3>
|
||||
@if ($applications->count() > 0)
|
||||
<livewire:project.shared.storages.all :resource="$database" :isHeaderVisible="false" />
|
||||
@else
|
||||
<livewire:project.shared.storages.all :resource="$database" />
|
||||
@endif
|
||||
@if ($database->fileStorages()->get()->count() > 0)
|
||||
<h5 class="py-4">Mounted Files/Dirs (binds)</h5>
|
||||
<div class="flex flex-col gap-4">
|
||||
@foreach ($database->fileStorages()->get()->sort() as $fileStorage)
|
||||
<livewire:project.service.file-storage :fileStorage="$fileStorage"
|
||||
wire:key="{{ $loop->index }}" />
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
@else
|
||||
<livewire:project.shared.storages.all :resource="$database" :isHeaderVisible="false" />
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
</div>
|
||||
<div x-cloak x-show="activeTab === 'environment-variables'">
|
||||
<div x-cloak x-show="activeTab === 'environment-variables'">
|
||||
|
@ -26,7 +26,7 @@
|
||||
<div x-cloak x-show="activeTab === 'storages'">
|
||||
<livewire:project.shared.storages.all :resource="$serviceApplication" />
|
||||
@if ($serviceApplication->fileStorages()->get()->count() > 0)
|
||||
<h3 class="py-4">Mounted Files (binds)</h3>
|
||||
<h5 class="py-4">Mounted Files/Dirs (binds)</h5>
|
||||
<div class="flex flex-col gap-4">
|
||||
@foreach ($serviceApplication->fileStorages()->get()->sort() as $fileStorage)
|
||||
<livewire:project.service.file-storage :fileStorage="$fileStorage" wire:key="{{ $loop->index }}" />
|
||||
@ -42,7 +42,7 @@
|
||||
<div x-cloak x-show="activeTab === 'storages'">
|
||||
<livewire:project.shared.storages.all :resource="$serviceDatabase" />
|
||||
@if ($serviceDatabase->fileStorages()->get()->count() > 0)
|
||||
<h3 class="py-4">Mounted Files (binds)</h3>
|
||||
<h5 class="py-4">Mounted Files/Dirs (binds)</h5>
|
||||
<div class="flex flex-col gap-4">
|
||||
@foreach ($serviceDatabase->fileStorages()->get()->sort() as $fileStorage)
|
||||
<livewire:project.service.file-storage :fileStorage="$fileStorage" wire:key="{{ $loop->index }}" />
|
||||
|
@ -1,28 +1,33 @@
|
||||
<div>
|
||||
<div>
|
||||
<div class="flex items-center gap-2">
|
||||
<h2>Storages</h2>
|
||||
@if ($resource->type() !== 'service')
|
||||
<x-helper
|
||||
helper="For Preview Deployments, storage has a <span class='text-helper'>-pr-#PRNumber</span> in their
|
||||
@if ($isHeaderVisible)
|
||||
<div>
|
||||
<div class="flex items-center gap-2">
|
||||
<h2>Storages</h2>
|
||||
@if ($resource->type() !== 'service')
|
||||
<x-helper
|
||||
helper="For Preview Deployments, storage has a <span class='text-helper'>-pr-#PRNumber</span> in their
|
||||
volume
|
||||
name, example: <span class='text-helper'>-pr-1</span>" />
|
||||
<x-forms.button class="btn" onclick="newStorage.showModal()">+ Add</x-forms.button>
|
||||
<livewire:project.shared.storages.add :uuid="$resource->uuid" />
|
||||
<x-forms.button class="btn" onclick="newStorage.showModal()">+ Add</x-forms.button>
|
||||
<livewire:project.shared.storages.add :uuid="$resource->uuid" />
|
||||
@endif
|
||||
</div>
|
||||
<div class="pb-4">Persistent storage to preserve data between deployments.</div>
|
||||
@if ($resource->type() === 'service')
|
||||
<span class="text-warning">Please modify storage layout in your <a class="underline"
|
||||
href="{{ Str::of(url()->current())->beforeLast('/') }}">Docker Compose</a> file.</span>
|
||||
<h2 class="pt-4">{{ Str::headline($resource->name) }} </h2>
|
||||
@endif
|
||||
</div>
|
||||
<div>Persistent storage to preserve data between deployments.</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2 py-4">
|
||||
@forelse ($resource->persistentStorages as $storage)
|
||||
@endif
|
||||
<div class="flex flex-col gap-4">
|
||||
@foreach ($resource->persistentStorages as $storage)
|
||||
@if ($resource->type() === 'service')
|
||||
<livewire:project.shared.storages.show wire:key="storage-{{ $storage->id }}" :storage="$storage"
|
||||
<livewire:project.shared.storages.show wire:key="storage-{{ $storage->id }}" :storage="$storage" :isFirst="$loop->first"
|
||||
isReadOnly='true' />
|
||||
@else
|
||||
<livewire:project.shared.storages.show wire:key="storage-{{ $storage->id }}" :storage="$storage" />
|
||||
@endif
|
||||
@empty
|
||||
<div class="text-neutral-500">No volume storages found.</div>
|
||||
@endforelse
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
|
@ -6,19 +6,28 @@
|
||||
reversible. <br>Please think again.</p>
|
||||
</x-slot:modalBody>
|
||||
</x-modal>
|
||||
@once ($isReadOnly)
|
||||
<span class="text-warning">Please modify storage layout in your <a
|
||||
class="underline" href="{{ Str::of(url()->current())->beforeLast('/') }}#compose">Docker Compose</a> file.</span>
|
||||
@endonce
|
||||
<form wire:submit.prevent='submit' class="flex flex-col gap-2 pt-4 xl:items-end xl:flex-row">
|
||||
|
||||
<form wire:submit.prevent='submit' class="flex flex-col gap-2 xl:items-end xl:flex-row">
|
||||
@if ($isReadOnly)
|
||||
<x-forms.input id="storage.name" label="Volume Name" required readonly />
|
||||
<x-forms.input id="storage.host_path" label="Source Path" readonly />
|
||||
<x-forms.input id="storage.mount_path" label="Destination Path" required readonly />
|
||||
@if ($isFirst)
|
||||
<x-forms.input id="storage.name" label="Volume Name" required readonly />
|
||||
<x-forms.input id="storage.host_path" label="Source Path (on host)" readonly />
|
||||
<x-forms.input id="storage.mount_path" label="Destination Path (in container)" required readonly />
|
||||
@else
|
||||
<x-forms.input id="storage.name" required readonly />
|
||||
<x-forms.input id="storage.host_path" readonly />
|
||||
<x-forms.input id="storage.mount_path" required readonly />
|
||||
@endif
|
||||
@else
|
||||
<x-forms.input id="storage.name" label="Name" required />
|
||||
<x-forms.input id="storage.host_path" label="Source Path" />
|
||||
<x-forms.input id="storage.mount_path" label="Destination Path" required />
|
||||
@if ($isFirst)
|
||||
<x-forms.input id="storage.name" label="Volume Name" required />
|
||||
<x-forms.input id="storage.host_path" label="Source Path (on host)" />
|
||||
<x-forms.input id="storage.mount_path" label="Destination Path (in container)" required />
|
||||
@else
|
||||
<x-forms.input id="storage.name" required />
|
||||
<x-forms.input id="storage.host_path" />
|
||||
<x-forms.input id="storage.mount_path" required />
|
||||
@endif
|
||||
<div class="flex gap-2">
|
||||
<x-forms.button type="submit">
|
||||
Update
|
||||
|
@ -17,17 +17,16 @@
|
||||
@forelse ($projects as $project)
|
||||
<div class="gap-2 border border-transparent cursor-pointer box group" x-data
|
||||
x-on:click="goto('{{ $project->uuid }}')">
|
||||
<div class="flex flex-col mx-6">
|
||||
<div class="flex flex-col flex-1 mx-6">
|
||||
<a class=" group-hover:text-white hover:no-underline"
|
||||
href="{{ route('project.show', ['project_uuid' => data_get($project, 'uuid')]) }}">{{ $project->name }}</a>
|
||||
<div class="text-xs group-hover:text-white hover:no-underline"
|
||||
href="{{ route('project.show', ['project_uuid' => data_get($project, 'uuid')]) }}">
|
||||
{{ $project->description }}</div>
|
||||
</div>
|
||||
<div class="flex-1"></div>
|
||||
<a class="mx-4 rounded hover:text-white"
|
||||
<a class="mx-4 rounded group-hover:text-white"
|
||||
href="{{ route('project.edit', ['project_uuid' => data_get($project, 'uuid')]) }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon hover:text-warning" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path
|
||||
|
@ -4,7 +4,7 @@
|
||||
"version": "3.12.36"
|
||||
},
|
||||
"v4": {
|
||||
"version": "4.0.0-beta.59"
|
||||
"version": "4.0.0-beta.60"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,9 @@ import vue from "@vitejs/plugin-vue";
|
||||
|
||||
export default defineConfig({
|
||||
server: {
|
||||
watch: {
|
||||
ignored: ['**/_data/**'],
|
||||
},
|
||||
host: "0.0.0.0",
|
||||
hmr: process.env.GITPOD_WORKSPACE_URL
|
||||
? {
|
||||
|
Loading…
x
Reference in New Issue
Block a user