diff --git a/app/Actions/Database/StartRedis.php b/app/Actions/Database/StartRedis.php index 44d1c5ae5..dc17636a7 100644 --- a/app/Actions/Database/StartRedis.php +++ b/app/Actions/Database/StartRedis.php @@ -3,6 +3,7 @@ namespace App\Actions\Database; use App\Models\StandaloneRedis; +use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; use Symfony\Component\Yaml\Yaml; use Lorisleiva\Actions\Concerns\AsAction; @@ -106,7 +107,7 @@ class StartRedis 'target' => '/usr/local/etc/redis/redis.conf', 'read_only' => true, ]; - $docker_compose['services'][$container_name]['command'] = $startCommand . ' /usr/local/etc/redis/redis.conf'; + $docker_compose['services'][$container_name]['command'] = "redis-server /usr/local/etc/redis/redis.conf --requirepass {$this->database->redis_password} --appendonly yes"; } $docker_compose = Yaml::dump($docker_compose, 10); $docker_compose_base64 = base64_encode($docker_compose); @@ -165,8 +166,9 @@ class StartRedis return; } $filename = 'redis.conf'; - $content = $this->database->redis_conf; - $content_base64 = base64_encode($content); - $this->commands[] = "echo '{$content_base64}' | base64 -d > $this->configuration_dir/{$filename}"; + Storage::disk('local')->put("tmp/redis.conf_{$this->database->uuid}", $this->database->redis_conf); + $path = Storage::path("tmp/redis.conf_{$this->database->uuid}"); + instant_scp($path, "{$this->configuration_dir}/{$filename}", $this->database->destination->server); + Storage::disk('local')->delete("tmp/redis.conf_{$this->database->uuid}"); } } diff --git a/app/Actions/Service/StartService.php b/app/Actions/Service/StartService.php index a90b368ab..cbee5918b 100644 --- a/app/Actions/Service/StartService.php +++ b/app/Actions/Service/StartService.php @@ -12,7 +12,6 @@ class StartService public function handle(Service $service) { ray('Starting service: ' . $service->name); - $network = $service->destination->network; $service->saveComposeConfigs(); $commands[] = "cd " . $service->workdir(); $commands[] = "echo 'Saved configuration files to {$service->workdir()}.'"; @@ -24,10 +23,13 @@ class StartService $commands[] = "echo 'Starting containers.'"; $commands[] = "docker compose up -d --remove-orphans --force-recreate --build"; $commands[] = "docker network connect $service->uuid coolify-proxy >/dev/null 2>&1 || true"; - $compose = data_get($service, 'docker_compose', []); - $serviceNames = data_get(Yaml::parse($compose), 'services', []); - foreach ($serviceNames as $serviceName => $serviceConfig) { - $commands[] = "docker network connect --alias {$serviceName}-{$service->uuid} $network {$serviceName}-{$service->uuid} || true"; + if (data_get($service, 'connect_to_docker_network')) { + $compose = data_get($service, 'docker_compose', []); + $network = $service->destination->network; + $serviceNames = data_get(Yaml::parse($compose), 'services', []); + foreach ($serviceNames as $serviceName => $serviceConfig) { + $commands[] = "docker network connect --alias {$serviceName}-{$service->uuid} $network {$serviceName}-{$service->uuid} || true"; + } } $activity = remote_process($commands, $service->server, type_uuid: $service->uuid, callEventOnFinish: 'ServiceStatusChanged'); return $activity; diff --git a/app/Livewire/Project/Service/StackForm.php b/app/Livewire/Project/Service/StackForm.php index c21f4d8f6..894428182 100644 --- a/app/Livewire/Project/Service/StackForm.php +++ b/app/Livewire/Project/Service/StackForm.php @@ -14,6 +14,7 @@ class StackForm extends Component 'service.docker_compose' => 'required', 'service.name' => 'required', 'service.description' => 'nullable', + 'service.connect_to_docker_network' => 'nullable', ]; public $validationAttributes = []; public function mount() @@ -44,6 +45,9 @@ class StackForm extends Component $this->service->docker_compose_raw = $raw; $this->submit(); } + public function instantSave() { + $this->service->save(); + } public function submit() { diff --git a/app/Livewire/Project/Shared/ExecuteContainerCommand.php b/app/Livewire/Project/Shared/ExecuteContainerCommand.php index 1ffcd810b..83df5a15c 100644 --- a/app/Livewire/Project/Shared/ExecuteContainerCommand.php +++ b/app/Livewire/Project/Shared/ExecuteContainerCommand.php @@ -79,21 +79,21 @@ class ExecuteContainerCommand extends Component $this->resource = $resource; $this->server = $this->resource->destination->server; $this->container = $this->resource->uuid; - if (str(data_get($this,'resource.status'))->startsWith('running')) { + // if (!str(data_get($this,'resource.status'))->startsWith('exited')) { $this->containers->push($this->container); - } + // } } else if (data_get($this->parameters, 'service_uuid')) { $this->type = 'service'; $this->resource = Service::where('uuid', $this->parameters['service_uuid'])->firstOrFail(); $this->resource->applications()->get()->each(function ($application) { - if (str(data_get($application, 'status'))->contains('running')) { + // if (str(data_get($application, 'status'))->contains('running')) { $this->containers->push(data_get($application, 'name') . '-' . data_get($this->resource, 'uuid')); - } + // } }); $this->resource->databases()->get()->each(function ($database) { - if (str(data_get($database, 'status'))->contains('running')) { + // if (str(data_get($database, 'status'))->contains('running')) { $this->containers->push(data_get($database, 'name') . '-' . data_get($this->resource, 'uuid')); - } + // } }); $this->server = $this->resource->server; diff --git a/app/Livewire/Project/Shared/Logs.php b/app/Livewire/Project/Shared/Logs.php index a8f41c92e..19edbdd7b 100644 --- a/app/Livewire/Project/Shared/Logs.php +++ b/app/Livewire/Project/Shared/Logs.php @@ -70,21 +70,21 @@ class Logs extends Component $this->status = $this->resource->status; $this->server = $this->resource->destination->server; $this->container = $this->resource->uuid; - if (str(data_get($this, 'resource.status'))->startsWith('running')) { + // if (str(data_get($this, 'resource.status'))->startsWith('running')) { $this->containers->push($this->container); - } + // } } else if (data_get($this->parameters, 'service_uuid')) { $this->type = 'service'; $this->resource = Service::where('uuid', $this->parameters['service_uuid'])->firstOrFail(); $this->resource->applications()->get()->each(function ($application) { - if (str(data_get($application, 'status'))->contains('running')) { + // if (str(data_get($application, 'status'))->contains('running')) { $this->containers->push(data_get($application, 'name') . '-' . data_get($this->resource, 'uuid')); - } + // } }); $this->resource->databases()->get()->each(function ($database) { - if (str(data_get($database, 'status'))->contains('running')) { + // if (str(data_get($database, 'status'))->contains('running')) { $this->containers->push(data_get($database, 'name') . '-' . data_get($this->resource, 'uuid')); - } + // } }); $this->server = $this->resource->server; diff --git a/app/View/Components/Forms/Checkbox.php b/app/View/Components/Forms/Checkbox.php index 4fd05c2dd..0bbbc1e04 100644 --- a/app/View/Components/Forms/Checkbox.php +++ b/app/View/Components/Forms/Checkbox.php @@ -19,7 +19,7 @@ class Checkbox extends Component public string|null $helper = null, public string|bool $instantSave = false, public bool $disabled = false, - public string $defaultClass = "toggle toggle-xs toggle-warning rounded disabled:bg-coolgray-200 disabled:opacity-50 placeholder:text-neutral-700" + public string $defaultClass = "toggle toggle-xs toggle-warning rounded disabled:bg-coolgray-200 disabled:opacity-50 placeholder:text-neutral-700", ) { // } diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 2a0e14111..3cff9ba24 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -1036,6 +1036,9 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal if (!data_get($service, 'restart')) { data_set($service, 'restart', RESTART_MODE); } + if (data_get($service, 'restart') === 'no') { + $savedService->update(['exclude_from_status' => true]); + } data_set($service, 'container_name', $containerName); data_forget($service, 'volumes.*.content'); data_forget($service, 'volumes.*.isDirectory'); diff --git a/config/sentry.php b/config/sentry.php index ccae430a3..f6b3ee9be 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.198', + 'release' => '4.0.0-beta.199', // 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 e5829a919..0eb21d0dd 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ boolean('connect_to_docker_network')->default(false); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('services', function (Blueprint $table) { + $table->dropColumn('connect_to_docker_network'); + }); + } +}; diff --git a/resources/views/components/forms/checkbox.blade.php b/resources/views/components/forms/checkbox.blade.php index 1265dc132..12ed8edb3 100644 --- a/resources/views/components/forms/checkbox.blade.php +++ b/resources/views/components/forms/checkbox.blade.php @@ -1,6 +1,6 @@