diff --git a/app/Http/Livewire/Project/Database/Postgresql/General.php b/app/Http/Livewire/Project/Database/Postgresql/General.php
index 9045eee69..5a03908e1 100644
--- a/app/Http/Livewire/Project/Database/Postgresql/General.php
+++ b/app/Http/Livewire/Project/Database/Postgresql/General.php
@@ -50,8 +50,9 @@ class General extends Component
$this->getDbUrl();
}
public function getDbUrl() {
+
if ($this->database->is_public) {
- $this->db_url = "postgres://{$this->database->postgres_user}:{$this->database->postgres_password}@{$this->database->destination->server->ip}:{$this->database->public_port}/{$this->database->postgres_db}";
+ $this->db_url = "postgres://{$this->database->postgres_user}:{$this->database->postgres_password}@{$this->database->destination->server->getIp}:{$this->database->public_port}/{$this->database->postgres_db}";
} else {
$this->db_url = "postgres://{$this->database->postgres_user}:{$this->database->postgres_password}@{$this->database->uuid}:5432/{$this->database->postgres_db}";
}
diff --git a/app/Http/Livewire/Project/Service/Index.php b/app/Http/Livewire/Project/Service/Index.php
index 18029fb73..3f48fdf5d 100644
--- a/app/Http/Livewire/Project/Service/Index.php
+++ b/app/Http/Livewire/Project/Service/Index.php
@@ -29,7 +29,10 @@ class Index extends Component
$this->parameters = get_route_parameters();
$this->query = request()->query();
$this->service = Service::whereUuid($this->parameters['service_uuid'])->firstOrFail();
- $this->refreshStack();
+ $this->applications = $this->service->applications->sort();
+ $this->databases = $this->service->databases->sort();
+ ray($this->applications);
+ ray($this->databases);
}
public function saveCompose($raw)
{
diff --git a/app/Http/Livewire/Project/Service/Storage.php b/app/Http/Livewire/Project/Service/Storage.php
new file mode 100644
index 000000000..2e3ef8f58
--- /dev/null
+++ b/app/Http/Livewire/Project/Service/Storage.php
@@ -0,0 +1,35 @@
+ $data['name'],
+ 'mount_path' => $data['mount_path'],
+ 'host_path' => $data['host_path'],
+ 'resource_id' => $this->resource->id,
+ 'resource_type' => $this->resource->getMorphClass(),
+ ]);
+ $this->resource->refresh();
+ $this->emit('success', 'Storage added successfully');
+ $this->emit('clearAddStorage');
+ $this->emit('refreshStorages');
+ } catch (\Throwable $e) {
+ return handleError($e, $this);
+ }
+ }
+}
diff --git a/app/Http/Livewire/Project/Shared/Storages/Add.php b/app/Http/Livewire/Project/Shared/Storages/Add.php
index 1edfe03a4..7278eda7a 100644
--- a/app/Http/Livewire/Project/Shared/Storages/Add.php
+++ b/app/Http/Livewire/Project/Shared/Storages/Add.php
@@ -33,7 +33,7 @@ class Add extends Component
{
$this->validate();
$name = $this->uuid . '-' . $this->name;
- $this->emitUp('submit', [
+ $this->emit('addNewVolume', [
'name' => $name,
'mount_path' => $this->mount_path,
'host_path' => $this->host_path,
diff --git a/app/Http/Livewire/Project/Shared/Storages/All.php b/app/Http/Livewire/Project/Shared/Storages/All.php
index 8ac22d881..457071711 100644
--- a/app/Http/Livewire/Project/Shared/Storages/All.php
+++ b/app/Http/Livewire/Project/Shared/Storages/All.php
@@ -7,30 +7,11 @@ use Livewire\Component;
class All extends Component
{
- public bool $isHeaderVisible = true;
public $resource;
- protected $listeners = ['refreshStorages', 'submit'];
+ protected $listeners = ['refreshStorages'];
public function refreshStorages()
{
$this->resource->refresh();
}
-
- public function submit($data)
- {
- try {
- LocalPersistentVolume::create([
- 'name' => $data['name'],
- 'mount_path' => $data['mount_path'],
- 'host_path' => $data['host_path'],
- 'resource_id' => $this->resource->id,
- 'resource_type' => $this->resource->getMorphClass(),
- ]);
- $this->resource->refresh();
- $this->emit('success', 'Storage added successfully');
- $this->emit('clearAddStorage');
- } catch (\Throwable $e) {
- return handleError($e, $this);
- }
- }
}
diff --git a/app/Models/Application.php b/app/Models/Application.php
index fc437769a..af2db98ee 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -44,6 +44,10 @@ class Application extends BaseModel
{
return $this->morphMany(LocalPersistentVolume::class, 'resource');
}
+ public function fileStorages()
+ {
+ return $this->morphMany(LocalFileVolume::class, 'resource');
+ }
public function type()
{
diff --git a/app/Models/LocalFileVolume.php b/app/Models/LocalFileVolume.php
index b45a868aa..f426e40a0 100644
--- a/app/Models/LocalFileVolume.php
+++ b/app/Models/LocalFileVolume.php
@@ -31,23 +31,18 @@ class LocalFileVolume extends BaseModel
}
$isFile = instant_remote_process(["test -f $path && echo OK || echo NOK"], $server);
$isDir = instant_remote_process(["test -d $path && echo OK || echo NOK"], $server);
- ray($isFile);
if ($isFile == 'OK' && $fileVolume->is_directory) {
throw new \Exception("File $path is a file on the server, but you are trying to mark it as a directory. Please delete the file on the server or mark it as directory.");
} else if ($isDir == 'OK' && !$fileVolume->is_directory) {
throw new \Exception("File $path is a directory on the server, but you are trying to mark it as a file. Please delete the directory on the server or mark it as directory.");
}
- if (($isFile == 'NOK' && !$fileVolume->is_directory) || $isFile == 'OK') {
- $rootDir = Str::of($path)->dirname();
- $commands->push("mkdir -p $rootDir > /dev/null 2>&1 || true");
- $commands->push("touch $path > /dev/null 2>&1 || true");
- if ($content) {
- $content = base64_encode($content);
- $commands->push("echo '$content' | base64 -d > $path");
- }
- } else if ($isDir == 'NOK' && $fileVolume->is_directory) {
+ if (!$fileVolume->is_directory && $isDir == 'NOK') {
+ $content = base64_encode($content);
+ $commands->push("echo '$content' | base64 -d > $path");
+ } else if ($isDir == 'NOK' && $fileVolume->is_directory) {
$commands->push("mkdir -p $path > /dev/null 2>&1 || true");
}
+ ray($commands->toArray());
return instant_remote_process($commands, $server);
}
}
diff --git a/app/Models/Server.php b/app/Models/Server.php
index 0619a589e..f174222c0 100644
--- a/app/Models/Server.php
+++ b/app/Models/Server.php
@@ -5,6 +5,7 @@ namespace App\Models;
use App\Enums\ProxyStatus;
use App\Enums\ProxyTypes;
use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\Casts\Attribute;
use Spatie\SchemalessAttributes\Casts\SchemalessAttributes;
use Spatie\SchemalessAttributes\SchemalessAttributesTrait;
@@ -120,7 +121,20 @@ class Server extends BaseModel
{
return $this->hasMany(Service::class);
}
-
+ public function getIp(): Attribute
+ {
+ return Attribute::make(
+ get: function () {
+ if (isDev()) {
+ return '127.0.0.1';
+ }
+ if ($this->ip === 'host.docker.internal') {
+ return base_ip();
+ }
+ return $this->ip;
+ }
+ );
+ }
public function previews()
{
return $this->destinations()->map(function ($standaloneDocker) {
diff --git a/app/Models/ServiceDatabase.php b/app/Models/ServiceDatabase.php
index 057db8e67..b4a130904 100644
--- a/app/Models/ServiceDatabase.php
+++ b/app/Models/ServiceDatabase.php
@@ -3,7 +3,6 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
-use Symfony\Component\Yaml\Yaml;
class ServiceDatabase extends BaseModel
{
diff --git a/app/Models/StandalonePostgresql.php b/app/Models/StandalonePostgresql.php
index 17b5b8056..ed270862b 100644
--- a/app/Models/StandalonePostgresql.php
+++ b/app/Models/StandalonePostgresql.php
@@ -76,6 +76,11 @@ class StandalonePostgresql extends BaseModel
return $this->belongsTo(Environment::class);
}
+ public function fileStorages()
+ {
+ return $this->morphMany(LocalFileVolume::class, 'resource');
+ }
+
public function destination()
{
return $this->morphTo();
diff --git a/bootstrap/helpers/services.php b/bootstrap/helpers/services.php
index 306ca172f..2590049ad 100644
--- a/bootstrap/helpers/services.php
+++ b/bootstrap/helpers/services.php
@@ -85,28 +85,39 @@ function getFilesystemVolumesFromServer(ServiceApplication|ServiceDatabase $oneS
} else {
$fileLocation = $path;
}
+ ray($path,$fileLocation);
+ // Exists and is a file
$isFile = instant_remote_process(["test -f $fileLocation && echo OK || echo NOK"], $server);
+ // Exists and is a directory
$isDir = instant_remote_process(["test -d $fileLocation && echo OK || echo NOK"], $server);
- if ($isFile === 'NOK' &&!$fileVolume->is_directory && $isInit) {
- $fileVolume->saveStorageOnServer($oneService);
- continue;
- }
- if ($isFile == 'OK' && !$fileVolume->is_directory) {
+
+ if ($isFile == 'OK') {
+ // If its a file & exists
$filesystemContent = instant_remote_process(["cat $fileLocation"], $server);
- if (base64_encode($filesystemContent) != base64_encode($content)) {
- $fileVolume->content = $filesystemContent;
- $fileVolume->save();
- }
- } else {
- if ($isDir == 'OK') {
- $fileVolume->content = null;
- $fileVolume->is_directory = true;
- $fileVolume->save();
- } else {
- $fileVolume->content = null;
- $fileVolume->is_directory = false;
- $fileVolume->save();
- }
+ $fileVolume->content = $filesystemContent;
+ $fileVolume->is_directory = false;
+ $fileVolume->save();
+ } else if ($isDir == 'OK') {
+ // If its a directory & exists
+ $fileVolume->content = null;
+ $fileVolume->is_directory = true;
+ $fileVolume->save();
+ } else if ($isFile == 'NOK' && $isDir == 'NOK' && !$fileVolume->is_directory && $isInit && $content) {
+ // Does not exists (no dir or file), not flagged as directory, is init, has content
+ $fileVolume->content = $content;
+ $fileVolume->is_directory = false;
+ $fileVolume->save();
+ $content = base64_encode($content);
+ $dir = Str::of($fileLocation)->dirname();
+ instant_remote_process([
+ "mkdir -p $dir",
+ "echo '$content' | base64 -d > $fileLocation"
+ ], $server);
+ } else if ($isFile == 'NOK' && $isDir == 'NOK' && $fileVolume->is_directory && $isInit) {
+ $fileVolume->content = null;
+ $fileVolume->is_directory = true;
+ $fileVolume->save();
+ instant_remote_process(["mkdir -p $fileLocation"], $server);
}
}
} catch (\Throwable $e) {
diff --git a/config/sentry.php b/config/sentry.php
index 4c571d7c3..3754637d7 100644
--- a/config/sentry.php
+++ b/config/sentry.php
@@ -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.62',
+ 'release' => '4.0.0-beta.63',
// When left empty or `null` the Laravel environment will be used
'environment' => config('app.env'),
diff --git a/config/version.php b/config/version.php
index a58b7c0ee..51a7a5302 100644
--- a/config/version.php
+++ b/config/version.php
@@ -1,3 +1,3 @@
https://hub.docker.com/_/postgres" />
-