feat: image tag for services
This commit is contained in:
@@ -15,6 +15,7 @@ class Application extends Component
|
|||||||
'application.human_name' => 'nullable',
|
'application.human_name' => 'nullable',
|
||||||
'application.description' => 'nullable',
|
'application.description' => 'nullable',
|
||||||
'application.fqdn' => 'nullable',
|
'application.fqdn' => 'nullable',
|
||||||
|
'application.image_tag' => 'required',
|
||||||
'application.ignore_from_status' => 'required|boolean',
|
'application.ignore_from_status' => 'required|boolean',
|
||||||
];
|
];
|
||||||
public function render()
|
public function render()
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Http\Livewire\Project\Service;
|
namespace App\Http\Livewire\Project\Service;
|
||||||
|
|
||||||
use App\Models\ServiceApplication;
|
|
||||||
use App\Models\ServiceDatabase;
|
use App\Models\ServiceDatabase;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
@@ -12,6 +11,7 @@ class Database extends Component
|
|||||||
protected $rules = [
|
protected $rules = [
|
||||||
'database.human_name' => 'nullable',
|
'database.human_name' => 'nullable',
|
||||||
'database.description' => 'nullable',
|
'database.description' => 'nullable',
|
||||||
|
'database.image_tag' => 'required',
|
||||||
'database.ignore_from_status' => 'required|boolean',
|
'database.ignore_from_status' => 'required|boolean',
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ class Service extends BaseModel
|
|||||||
$image = data_get($service, 'image');
|
$image = data_get($service, 'image');
|
||||||
if ($image) {
|
if ($image) {
|
||||||
$imageName = Str::of($image)->before(':');
|
$imageName = Str::of($image)->before(':');
|
||||||
|
$imageTag = Str::of($image)->after(':') ?? 'latest';
|
||||||
if (collect(DATABASE_DOCKER_IMAGES)->contains($imageName)) {
|
if (collect(DATABASE_DOCKER_IMAGES)->contains($imageName)) {
|
||||||
$isDatabase = true;
|
$isDatabase = true;
|
||||||
data_set($service, 'is_database', true);
|
data_set($service, 'is_database', true);
|
||||||
@@ -159,12 +160,14 @@ class Service extends BaseModel
|
|||||||
if ($isDatabase) {
|
if ($isDatabase) {
|
||||||
$savedService = ServiceDatabase::create([
|
$savedService = ServiceDatabase::create([
|
||||||
'name' => $serviceName,
|
'name' => $serviceName,
|
||||||
|
'image_tag' => $imageTag,
|
||||||
'service_id' => $this->id
|
'service_id' => $this->id
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
$savedService = ServiceApplication::create([
|
$savedService = ServiceApplication::create([
|
||||||
'name' => $serviceName,
|
'name' => $serviceName,
|
||||||
'fqdn' => $this->generateFqdn($serviceVariables, $serviceName),
|
'fqdn' => $this->generateFqdn($serviceVariables, $serviceName),
|
||||||
|
'image_tag' => $imageTag,
|
||||||
'service_id' => $this->id
|
'service_id' => $this->id
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -182,6 +185,8 @@ class Service extends BaseModel
|
|||||||
$savedService->save();
|
$savedService->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set image tag
|
||||||
$fqdns = data_get($savedService, 'fqdn');
|
$fqdns = data_get($savedService, 'fqdn');
|
||||||
if ($fqdns) {
|
if ($fqdns) {
|
||||||
$fqdns = collect(Str::of($fqdns)->explode(','));
|
$fqdns = collect(Str::of($fqdns)->explode(','));
|
||||||
@@ -495,6 +500,8 @@ class Service extends BaseModel
|
|||||||
$labels = $labels->merge(fqdnLabelsForTraefik($fqdns, $container_name, true));
|
$labels = $labels->merge(fqdnLabelsForTraefik($fqdns, $container_name, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
data_set($service, 'labels', $labels->toArray());
|
data_set($service, 'labels', $labels->toArray());
|
||||||
data_forget($service, 'is_database');
|
data_forget($service, 'is_database');
|
||||||
data_set($service, 'restart', RESTART_MODE);
|
data_set($service, 'restart', RESTART_MODE);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ return new class extends Migration
|
|||||||
{
|
{
|
||||||
Schema::table('service_applications', function (Blueprint $table) {
|
Schema::table('service_applications', function (Blueprint $table) {
|
||||||
$table->boolean('ignore_from_status')->default(false);
|
$table->boolean('ignore_from_status')->default(false);
|
||||||
|
$table->string('image_tag')->nullable();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ return new class extends Migration
|
|||||||
{
|
{
|
||||||
Schema::table('service_applications', function (Blueprint $table) {
|
Schema::table('service_applications', function (Blueprint $table) {
|
||||||
$table->dropColumn('ignore_from_status');
|
$table->dropColumn('ignore_from_status');
|
||||||
|
$table->dropColumn('image_tag');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ return new class extends Migration
|
|||||||
{
|
{
|
||||||
Schema::table('service_databases', function (Blueprint $table) {
|
Schema::table('service_databases', function (Blueprint $table) {
|
||||||
$table->boolean('ignore_from_status')->default(false);
|
$table->boolean('ignore_from_status')->default(false);
|
||||||
|
$table->string('image_tag')->nullable();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,6 +24,7 @@ return new class extends Migration
|
|||||||
{
|
{
|
||||||
Schema::table('service_databases', function (Blueprint $table) {
|
Schema::table('service_databases', function (Blueprint $table) {
|
||||||
$table->dropColumn('ignore_from_status');
|
$table->dropColumn('ignore_from_status');
|
||||||
|
$table->dropColumn('image_tag');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,7 +16,11 @@
|
|||||||
placeholder="Human readable name"></x-forms.input>
|
placeholder="Human readable name"></x-forms.input>
|
||||||
<x-forms.input label="Description" id="application.description"></x-forms.input>
|
<x-forms.input label="Description" id="application.description"></x-forms.input>
|
||||||
</div>
|
</div>
|
||||||
<x-forms.input placeholder="https://app.coolify.io" label="Domains" id="application.fqdn"></x-forms.input>
|
<div class="flex gap-2">
|
||||||
|
<x-forms.input placeholder="https://app.coolify.io" label="Domains"
|
||||||
|
id="application.fqdn"></x-forms.input>
|
||||||
|
<x-forms.input required helper="You can change the image tag you would like to deploy.<br><br><span class='text-warning'>WARNING. You could corrupt your data. Only do it if you know what you are doing.</span>" label="Image Tag" id="application.image_tag"></x-forms.input>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h3 class="pt-2">Advanced</h3>
|
<h3 class="pt-2">Advanced</h3>
|
||||||
<div class="w-64">
|
<div class="w-64">
|
||||||
|
|||||||
@@ -9,10 +9,16 @@
|
|||||||
<x-forms.button type="submit">Save</x-forms.button>
|
<x-forms.button type="submit">Save</x-forms.button>
|
||||||
<a target="_blank" href="{{ $database->documentation() }}">Documentation <x-external-link /></a>
|
<a target="_blank" href="{{ $database->documentation() }}">Documentation <x-external-link /></a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex flex-col gap-2">
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<x-forms.input label="Name" id="database.human_name" placeholder="Name"></x-forms.input>
|
<x-forms.input label="Name" id="database.human_name" placeholder="Name"></x-forms.input>
|
||||||
<x-forms.input label="Description" id="database.description"></x-forms.input>
|
<x-forms.input label="Description" id="database.description"></x-forms.input>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<x-forms.input required helper="You can change the image tag you would like to deploy.<br><br><span class='text-warning'>WARNING. You could corrupt your data. Only do it if you know what you are doing.</span>" label="Image Tag"
|
||||||
|
id="database.image_tag"></x-forms.input>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<h3 class="pt-2">Advanced</h3>
|
<h3 class="pt-2">Advanced</h3>
|
||||||
<div class="w-64">
|
<div class="w-64">
|
||||||
<x-forms.checkbox instantSave label="Ignore from service status"
|
<x-forms.checkbox instantSave label="Ignore from service status"
|
||||||
|
|||||||
Reference in New Issue
Block a user