mirror of
https://github.com/ershisan99/coolify.git
synced 2025-12-23 04:59:28 +00:00
Compare commits
141 Commits
v4.0.0-bet
...
v4.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd0ad04384 | ||
|
|
910a1f43a9 | ||
|
|
e2f959ce4c | ||
|
|
68fe886fb0 | ||
|
|
4631c73809 | ||
|
|
77558b37da | ||
|
|
e060409a76 | ||
|
|
af01bc3e77 | ||
|
|
1e158badfc | ||
|
|
c620bb58ed | ||
|
|
8a91395472 | ||
|
|
c5f3398b73 | ||
|
|
3878527de8 | ||
|
|
4abcb2d5b9 | ||
|
|
a635e51486 | ||
|
|
b6ce2e9122 | ||
|
|
8c60dd5523 | ||
|
|
94e2d951c4 | ||
|
|
381e24bea5 | ||
|
|
2b1e35980f | ||
|
|
a42c8da344 | ||
|
|
7a0e415ecf | ||
|
|
d721f4809a | ||
|
|
22431eee9a | ||
|
|
c058c0a766 | ||
|
|
1724c0d3ff | ||
|
|
0b8f48230f | ||
|
|
e8d84b7067 | ||
|
|
5236bbc757 | ||
|
|
094e1d1bba | ||
|
|
68b25523d6 | ||
|
|
bdc478d5f5 | ||
|
|
002472d7c6 | ||
|
|
0d65bf62b9 | ||
|
|
01c7e76071 | ||
|
|
884ae0efb0 | ||
|
|
8e7040bf7c | ||
|
|
059e6a88eb | ||
|
|
9947158f7e | ||
|
|
61aa9e8766 | ||
|
|
75813a289c | ||
|
|
af11d8cf3d | ||
|
|
48990db699 | ||
|
|
da71353bfa | ||
|
|
0f5559bc61 | ||
|
|
1afb509c33 | ||
|
|
bccca6e874 | ||
|
|
083dc15053 | ||
|
|
1b6d376472 | ||
|
|
891deee05a | ||
|
|
5ffbba908b | ||
|
|
f762959c9f | ||
|
|
90a5a23fd9 | ||
|
|
94e87141ff | ||
|
|
fceaf3e94b | ||
|
|
3be554cb55 | ||
|
|
27b18fbedf | ||
|
|
5e7c6906b3 | ||
|
|
d05ffe32a3 | ||
|
|
f1298d1db4 | ||
|
|
408738e08d | ||
|
|
8d04fbdb74 | ||
|
|
dccb31d17e | ||
|
|
f61210287e | ||
|
|
18ad7220f0 | ||
|
|
79e0df1d43 | ||
|
|
a2f53085e5 | ||
|
|
c5782252ea | ||
|
|
bf3d88facd | ||
|
|
e45b0bf715 | ||
|
|
9db6c12eea | ||
|
|
3a391b69e8 | ||
|
|
cc1fb83c79 | ||
|
|
efa5dd28f1 | ||
|
|
f1eddae379 | ||
|
|
34febe670d | ||
|
|
3137131a1a | ||
|
|
1b6546d26c | ||
|
|
b9f820cef4 | ||
|
|
d8639f58d7 | ||
|
|
cf9be9355f | ||
|
|
e36bb11ba8 | ||
|
|
190beb3d3f | ||
|
|
890a6925d1 | ||
|
|
d03b8420f8 | ||
|
|
cbd3c880c3 | ||
|
|
6b24001876 | ||
|
|
6bb45430c9 | ||
|
|
bc6b4ed850 | ||
|
|
8a63ef5da9 | ||
|
|
e324866a27 | ||
|
|
0e5f733657 | ||
|
|
c5932ed337 | ||
|
|
ef428f844f | ||
|
|
eb8b752a6e | ||
|
|
ce0b38035c | ||
|
|
562a8f1fac | ||
|
|
68f1621757 | ||
|
|
e3087573bb | ||
|
|
7869f223a3 | ||
|
|
0e99f27108 | ||
|
|
f445a8c312 | ||
|
|
845fc191d4 | ||
|
|
95d0d72e0d | ||
|
|
76f695036c | ||
|
|
225bf06736 | ||
|
|
3a287ae974 | ||
|
|
e5c61b9f9f | ||
|
|
32bc876dfc | ||
|
|
c9b3d2a43d | ||
|
|
f343210e7c | ||
|
|
4a42bff0dc | ||
|
|
36931b5b18 | ||
|
|
3b080abada | ||
|
|
7feba4bbaa | ||
|
|
eef8c756df | ||
|
|
9ed30cb0dc | ||
|
|
6bc43bd999 | ||
|
|
e7683ee9a5 | ||
|
|
ee71aeaa36 | ||
|
|
404c664500 | ||
|
|
aa80392b46 | ||
|
|
c9509ef658 | ||
|
|
31e08a24c9 | ||
|
|
14b32e30cd | ||
|
|
5aaad66fe5 | ||
|
|
b6745c691b | ||
|
|
5ee29c6072 | ||
|
|
b69584fe26 | ||
|
|
4c3907c296 | ||
|
|
bf44b4b949 | ||
|
|
bee7a2357b | ||
|
|
557e1407d0 | ||
|
|
3c99f24b5a | ||
|
|
512197021b | ||
|
|
e233ec05b5 | ||
|
|
d0e3a20a65 | ||
|
|
e2e6813632 | ||
|
|
9bbe9567c7 | ||
|
|
7913a639b5 | ||
|
|
adecf328fc |
@@ -31,7 +31,7 @@ Special thanks to our biggest sponsors, [CCCareers](https://cccareers.org/) and
|
|||||||
<a href="https://github.com/whitesidest"><img src="https://avatars.githubusercontent.com/u/12365916?s=52&v=4" width="60px" alt="Tyler Whitesides" /></a>
|
<a href="https://github.com/whitesidest"><img src="https://avatars.githubusercontent.com/u/12365916?s=52&v=4" width="60px" alt="Tyler Whitesides" /></a>
|
||||||
<a href="https://github.com/aniftyco"><img src="https://github.com/aniftyco.png" width="60px" alt="NiftyCo" /></a>
|
<a href="https://github.com/aniftyco"><img src="https://github.com/aniftyco.png" width="60px" alt="NiftyCo" /></a>
|
||||||
<a href="https://github.com/iujlaki"><img src="https://github.com/iujlaki.png" width="60px" alt="Imre Ujlaki" /></a>
|
<a href="https://github.com/iujlaki"><img src="https://github.com/iujlaki.png" width="60px" alt="Imre Ujlaki" /></a>
|
||||||
<a href="https://github.com/Illyism"><img src="https://github.com/Illyism.png" width="60px" alt="Ilias Ism" /></a>
|
<a href="https://il.ly"><img src="https://github.com/Illyism.png" width="60px" alt="Ilias Ism" /></a>
|
||||||
<a href="https://github.com/urtho"><img src="https://github.com/urtho.png" width="60px" alt="Paweł Pierścionek" /></a>
|
<a href="https://github.com/urtho"><img src="https://github.com/urtho.png" width="60px" alt="Paweł Pierścionek" /></a>
|
||||||
<a href="https://github.com/monocursive"><img src="https://github.com/monocursive.png" width="60px" alt="Michael Mazurczak" /></a>
|
<a href="https://github.com/monocursive"><img src="https://github.com/monocursive.png" width="60px" alt="Michael Mazurczak" /></a>
|
||||||
|
|
||||||
@@ -93,6 +93,10 @@ Contact us [here](https://coolify.io/docs/contact).
|
|||||||
|
|
||||||
<a href="https://trendshift.io/repositories/634" target="_blank"><img src="https://trendshift.io/api/badge/repositories/634" alt="coollabsio%2Fcoolify | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
<a href="https://trendshift.io/repositories/634" target="_blank"><img src="https://trendshift.io/api/badge/repositories/634" alt="coollabsio%2Fcoolify | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
||||||
|
|
||||||
|
# Repo Activity
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
# Star History
|
# Star History
|
||||||
|
|
||||||
[](https://star-history.com/#coollabsio/coolify&Date)
|
[](https://star-history.com/#coollabsio/coolify&Date)
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ class StartMariadb
|
|||||||
'mem_swappiness' => $this->database->limits_memory_swappiness,
|
'mem_swappiness' => $this->database->limits_memory_swappiness,
|
||||||
'mem_reservation' => $this->database->limits_memory_reservation,
|
'mem_reservation' => $this->database->limits_memory_reservation,
|
||||||
'cpus' => (float) $this->database->limits_cpus,
|
'cpus' => (float) $this->database->limits_cpus,
|
||||||
'cpuset' => $this->database->limits_cpuset,
|
|
||||||
'cpu_shares' => $this->database->limits_cpu_shares,
|
'cpu_shares' => $this->database->limits_cpu_shares,
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@@ -69,6 +68,9 @@ class StartMariadb
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
if (!is_null($this->database->limits_cpuset)) {
|
||||||
|
data_set($docker_compose, "services.{$container_name}.cpuset", $this->database->limits_cpuset);
|
||||||
|
}
|
||||||
if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) {
|
if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) {
|
||||||
$docker_compose['services'][$container_name]['logging'] = [
|
$docker_compose['services'][$container_name]['logging'] = [
|
||||||
'driver' => 'fluentd',
|
'driver' => 'fluentd',
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ class StartMongodb
|
|||||||
'mem_swappiness' => $this->database->limits_memory_swappiness,
|
'mem_swappiness' => $this->database->limits_memory_swappiness,
|
||||||
'mem_reservation' => $this->database->limits_memory_reservation,
|
'mem_reservation' => $this->database->limits_memory_reservation,
|
||||||
'cpus' => (float) $this->database->limits_cpus,
|
'cpus' => (float) $this->database->limits_cpus,
|
||||||
'cpuset' => $this->database->limits_cpuset,
|
|
||||||
'cpu_shares' => $this->database->limits_cpu_shares,
|
'cpu_shares' => $this->database->limits_cpu_shares,
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@@ -76,6 +75,9 @@ class StartMongodb
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
if (!is_null($this->database->limits_cpuset)) {
|
||||||
|
data_set($docker_compose, "services.{$container_name}.cpuset", $this->database->limits_cpuset);
|
||||||
|
}
|
||||||
if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) {
|
if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) {
|
||||||
$docker_compose['services'][$container_name]['logging'] = [
|
$docker_compose['services'][$container_name]['logging'] = [
|
||||||
'driver' => 'fluentd',
|
'driver' => 'fluentd',
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ class StartMysql
|
|||||||
'mem_swappiness' => $this->database->limits_memory_swappiness,
|
'mem_swappiness' => $this->database->limits_memory_swappiness,
|
||||||
'mem_reservation' => $this->database->limits_memory_reservation,
|
'mem_reservation' => $this->database->limits_memory_reservation,
|
||||||
'cpus' => (float) $this->database->limits_cpus,
|
'cpus' => (float) $this->database->limits_cpus,
|
||||||
'cpuset' => $this->database->limits_cpuset,
|
|
||||||
'cpu_shares' => $this->database->limits_cpu_shares,
|
'cpu_shares' => $this->database->limits_cpu_shares,
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@@ -69,6 +68,9 @@ class StartMysql
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
if (!is_null($this->database->limits_cpuset)) {
|
||||||
|
data_set($docker_compose, "services.{$container_name}.cpuset", $this->database->limits_cpuset);
|
||||||
|
}
|
||||||
if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) {
|
if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) {
|
||||||
$docker_compose['services'][$container_name]['logging'] = [
|
$docker_compose['services'][$container_name]['logging'] = [
|
||||||
'driver' => 'fluentd',
|
'driver' => 'fluentd',
|
||||||
|
|||||||
@@ -50,12 +50,8 @@ class StartPostgresql
|
|||||||
],
|
],
|
||||||
'healthcheck' => [
|
'healthcheck' => [
|
||||||
'test' => [
|
'test' => [
|
||||||
'CMD-SHELL',
|
"CMD-SHELL",
|
||||||
'pg_isready',
|
"psql -U {$this->database->postgres_user} -d {$this->database->postgres_db} -c 'SELECT 1' || exit 1"
|
||||||
'-d',
|
|
||||||
$this->database->postgres_db,
|
|
||||||
'-U',
|
|
||||||
$this->database->postgres_user,
|
|
||||||
],
|
],
|
||||||
'interval' => '5s',
|
'interval' => '5s',
|
||||||
'timeout' => '5s',
|
'timeout' => '5s',
|
||||||
@@ -67,7 +63,6 @@ class StartPostgresql
|
|||||||
'mem_swappiness' => $this->database->limits_memory_swappiness,
|
'mem_swappiness' => $this->database->limits_memory_swappiness,
|
||||||
'mem_reservation' => $this->database->limits_memory_reservation,
|
'mem_reservation' => $this->database->limits_memory_reservation,
|
||||||
'cpus' => (float) $this->database->limits_cpus,
|
'cpus' => (float) $this->database->limits_cpus,
|
||||||
'cpuset' => $this->database->limits_cpuset,
|
|
||||||
'cpu_shares' => $this->database->limits_cpu_shares,
|
'cpu_shares' => $this->database->limits_cpu_shares,
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@@ -79,6 +74,9 @@ class StartPostgresql
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
if (!is_null($this->database->limits_cpuset)) {
|
||||||
|
data_set($docker_compose, "services.{$container_name}.cpuset", $this->database->limits_cpuset);
|
||||||
|
}
|
||||||
if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) {
|
if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) {
|
||||||
ray('Log Drain Enabled');
|
ray('Log Drain Enabled');
|
||||||
$docker_compose['services'][$container_name]['logging'] = [
|
$docker_compose['services'][$container_name]['logging'] = [
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ class StartRedis
|
|||||||
'mem_swappiness' => $this->database->limits_memory_swappiness,
|
'mem_swappiness' => $this->database->limits_memory_swappiness,
|
||||||
'mem_reservation' => $this->database->limits_memory_reservation,
|
'mem_reservation' => $this->database->limits_memory_reservation,
|
||||||
'cpus' => (float) $this->database->limits_cpus,
|
'cpus' => (float) $this->database->limits_cpus,
|
||||||
'cpuset' => $this->database->limits_cpuset,
|
|
||||||
'cpu_shares' => $this->database->limits_cpu_shares,
|
'cpu_shares' => $this->database->limits_cpu_shares,
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@@ -78,6 +77,9 @@ class StartRedis
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
if (!is_null($this->database->limits_cpuset)) {
|
||||||
|
data_set($docker_compose, "services.{$container_name}.cpuset", $this->database->limits_cpuset);
|
||||||
|
}
|
||||||
if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) {
|
if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) {
|
||||||
$docker_compose['services'][$container_name]['logging'] = [
|
$docker_compose['services'][$container_name]['logging'] = [
|
||||||
'driver' => 'fluentd',
|
'driver' => 'fluentd',
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Actions\Proxy;
|
namespace App\Actions\Proxy;
|
||||||
|
|
||||||
|
use App\Events\ProxyStatusChanged;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
@@ -13,7 +14,6 @@ class StartProxy
|
|||||||
public function handle(Server $server, bool $async = true): string|Activity
|
public function handle(Server $server, bool $async = true): string|Activity
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$proxyType = $server->proxyType();
|
$proxyType = $server->proxyType();
|
||||||
$commands = collect([]);
|
$commands = collect([]);
|
||||||
$proxy_path = get_proxy_path();
|
$proxy_path = get_proxy_path();
|
||||||
|
|||||||
23
app/Actions/Server/CleanupDocker.php
Normal file
23
app/Actions/Server/CleanupDocker.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Actions\Server;
|
||||||
|
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
use App\Models\Server;
|
||||||
|
|
||||||
|
class CleanupDocker
|
||||||
|
{
|
||||||
|
use AsAction;
|
||||||
|
public function handle(Server $server, bool $force = true)
|
||||||
|
{
|
||||||
|
if ($force) {
|
||||||
|
instant_remote_process(['docker image prune -af'], $server, false);
|
||||||
|
instant_remote_process(['docker container prune -f --filter "label=coolify.managed=true"'], $server, false);
|
||||||
|
instant_remote_process(['docker builder prune -af'], $server, false);
|
||||||
|
} else {
|
||||||
|
instant_remote_process(['docker image prune -f'], $server, false);
|
||||||
|
instant_remote_process(['docker container prune -f --filter "label=coolify.managed=true"'], $server, false);
|
||||||
|
instant_remote_process(['docker builder prune -f'], $server, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@ class UpdateCoolify
|
|||||||
if (!$this->server) {
|
if (!$this->server) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
CleanupDocker::run($this->server, false);
|
||||||
$this->latestVersion = get_latest_version_of_coolify();
|
$this->latestVersion = get_latest_version_of_coolify();
|
||||||
$this->currentVersion = config('version');
|
$this->currentVersion = config('version');
|
||||||
ray('latest version:' . $this->latestVersion . " current version: " . $this->currentVersion . ' force: ' . $force);
|
ray('latest version:' . $this->latestVersion . " current version: " . $this->currentVersion . ' force: ' . $force);
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ class DeleteService
|
|||||||
use AsAction;
|
use AsAction;
|
||||||
public function handle(Service $service)
|
public function handle(Service $service)
|
||||||
{
|
{
|
||||||
StopService::run($service);
|
|
||||||
$server = data_get($service, 'server');
|
$server = data_get($service, 'server');
|
||||||
|
if ($server->isFunctional()) {
|
||||||
|
StopService::run($service);
|
||||||
|
}
|
||||||
$storagesToDelete = collect([]);
|
$storagesToDelete = collect([]);
|
||||||
|
|
||||||
$service->environment_variables()->delete();
|
$service->environment_variables()->delete();
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ class Init extends Command
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Http::get("https://get.coollabs.io/coolify/v4/alive?appId=$id&version=$version");
|
Http::get("https://undead.coolify.io/v4/alive?appId=$id&version=$version");
|
||||||
echo "I am alive!\n";
|
echo "I am alive!\n";
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
echo "Error in alive: {$e->getMessage()}\n";
|
echo "Error in alive: {$e->getMessage()}\n";
|
||||||
@@ -142,83 +142,83 @@ class Init extends Command
|
|||||||
try {
|
try {
|
||||||
$applications = Application::withTrashed()->whereNotNull('deleted_at')->get();
|
$applications = Application::withTrashed()->whereNotNull('deleted_at')->get();
|
||||||
foreach ($applications as $application) {
|
foreach ($applications as $application) {
|
||||||
echo "Deleting stucked application: {$application->name}\n";
|
echo "Deleting stuck application: {$application->name}\n";
|
||||||
$application->forceDelete();
|
$application->forceDelete();
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
echo "Error in cleaning stucked application: {$e->getMessage()}\n";
|
echo "Error in cleaning stuck application: {$e->getMessage()}\n";
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$postgresqls = StandalonePostgresql::withTrashed()->whereNotNull('deleted_at')->get();
|
$postgresqls = StandalonePostgresql::withTrashed()->whereNotNull('deleted_at')->get();
|
||||||
foreach ($postgresqls as $postgresql) {
|
foreach ($postgresqls as $postgresql) {
|
||||||
echo "Deleting stucked postgresql: {$postgresql->name}\n";
|
echo "Deleting stuck postgresql: {$postgresql->name}\n";
|
||||||
$postgresql->forceDelete();
|
$postgresql->forceDelete();
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
echo "Error in cleaning stucked postgresql: {$e->getMessage()}\n";
|
echo "Error in cleaning stuck postgresql: {$e->getMessage()}\n";
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$redis = StandaloneRedis::withTrashed()->whereNotNull('deleted_at')->get();
|
$redis = StandaloneRedis::withTrashed()->whereNotNull('deleted_at')->get();
|
||||||
foreach ($redis as $redis) {
|
foreach ($redis as $redis) {
|
||||||
echo "Deleting stucked redis: {$redis->name}\n";
|
echo "Deleting stuck redis: {$redis->name}\n";
|
||||||
$redis->forceDelete();
|
$redis->forceDelete();
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
echo "Error in cleaning stucked redis: {$e->getMessage()}\n";
|
echo "Error in cleaning stuck redis: {$e->getMessage()}\n";
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$mongodbs = StandaloneMongodb::withTrashed()->whereNotNull('deleted_at')->get();
|
$mongodbs = StandaloneMongodb::withTrashed()->whereNotNull('deleted_at')->get();
|
||||||
foreach ($mongodbs as $mongodb) {
|
foreach ($mongodbs as $mongodb) {
|
||||||
echo "Deleting stucked mongodb: {$mongodb->name}\n";
|
echo "Deleting stuck mongodb: {$mongodb->name}\n";
|
||||||
$mongodb->forceDelete();
|
$mongodb->forceDelete();
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
echo "Error in cleaning stucked mongodb: {$e->getMessage()}\n";
|
echo "Error in cleaning stuck mongodb: {$e->getMessage()}\n";
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$mysqls = StandaloneMysql::withTrashed()->whereNotNull('deleted_at')->get();
|
$mysqls = StandaloneMysql::withTrashed()->whereNotNull('deleted_at')->get();
|
||||||
foreach ($mysqls as $mysql) {
|
foreach ($mysqls as $mysql) {
|
||||||
echo "Deleting stucked mysql: {$mysql->name}\n";
|
echo "Deleting stuck mysql: {$mysql->name}\n";
|
||||||
$mysql->forceDelete();
|
$mysql->forceDelete();
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
echo "Error in cleaning stucked mysql: {$e->getMessage()}\n";
|
echo "Error in cleaning stuck mysql: {$e->getMessage()}\n";
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$mariadbs = StandaloneMariadb::withTrashed()->whereNotNull('deleted_at')->get();
|
$mariadbs = StandaloneMariadb::withTrashed()->whereNotNull('deleted_at')->get();
|
||||||
foreach ($mariadbs as $mariadb) {
|
foreach ($mariadbs as $mariadb) {
|
||||||
echo "Deleting stucked mariadb: {$mariadb->name}\n";
|
echo "Deleting stuck mariadb: {$mariadb->name}\n";
|
||||||
$mariadb->forceDelete();
|
$mariadb->forceDelete();
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
echo "Error in cleaning stucked mariadb: {$e->getMessage()}\n";
|
echo "Error in cleaning stuck mariadb: {$e->getMessage()}\n";
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$services = Service::withTrashed()->whereNotNull('deleted_at')->get();
|
$services = Service::withTrashed()->whereNotNull('deleted_at')->get();
|
||||||
foreach ($services as $service) {
|
foreach ($services as $service) {
|
||||||
echo "Deleting stucked service: {$service->name}\n";
|
echo "Deleting stuck service: {$service->name}\n";
|
||||||
$service->forceDelete();
|
$service->forceDelete();
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
echo "Error in cleaning stucked service: {$e->getMessage()}\n";
|
echo "Error in cleaning stuck service: {$e->getMessage()}\n";
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$serviceApps = ServiceApplication::withTrashed()->whereNotNull('deleted_at')->get();
|
$serviceApps = ServiceApplication::withTrashed()->whereNotNull('deleted_at')->get();
|
||||||
foreach ($serviceApps as $serviceApp) {
|
foreach ($serviceApps as $serviceApp) {
|
||||||
echo "Deleting stucked serviceapp: {$serviceApp->name}\n";
|
echo "Deleting stuck serviceapp: {$serviceApp->name}\n";
|
||||||
$serviceApp->forceDelete();
|
$serviceApp->forceDelete();
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
echo "Error in cleaning stucked serviceapp: {$e->getMessage()}\n";
|
echo "Error in cleaning stuck serviceapp: {$e->getMessage()}\n";
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$serviceDbs = ServiceDatabase::withTrashed()->whereNotNull('deleted_at')->get();
|
$serviceDbs = ServiceDatabase::withTrashed()->whereNotNull('deleted_at')->get();
|
||||||
foreach ($serviceDbs as $serviceDb) {
|
foreach ($serviceDbs as $serviceDb) {
|
||||||
echo "Deleting stucked serviceapp: {$serviceDb->name}\n";
|
echo "Deleting stuck serviceapp: {$serviceDb->name}\n";
|
||||||
$serviceDb->forceDelete();
|
$serviceDb->forceDelete();
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
echo "Error in cleaning stucked serviceapp: {$e->getMessage()}\n";
|
echo "Error in cleaning stuck serviceapp: {$e->getMessage()}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup any resources that are not attached to any environment or destination or server
|
// Cleanup any resources that are not attached to any environment or destination or server
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Jobs\DeleteResourceJob;
|
||||||
use App\Models\Application;
|
use App\Models\Application;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\Service;
|
use App\Models\Service;
|
||||||
@@ -91,7 +92,7 @@ class ServicesDelete extends Command
|
|||||||
if (!$confirmed) {
|
if (!$confirmed) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$toDelete->delete();
|
DeleteResourceJob::dispatch($toDelete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,7 +116,7 @@ class ServicesDelete extends Command
|
|||||||
if (!$confirmed) {
|
if (!$confirmed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$toDelete->delete();
|
DeleteResourceJob::dispatch($toDelete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,7 +140,7 @@ class ServicesDelete extends Command
|
|||||||
if (!$confirmed) {
|
if (!$confirmed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$toDelete->delete();
|
DeleteResourceJob::dispatch($toDelete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,14 @@ namespace App\Console;
|
|||||||
use App\Jobs\CheckLogDrainContainerJob;
|
use App\Jobs\CheckLogDrainContainerJob;
|
||||||
use App\Jobs\CleanupInstanceStuffsJob;
|
use App\Jobs\CleanupInstanceStuffsJob;
|
||||||
use App\Jobs\DatabaseBackupJob;
|
use App\Jobs\DatabaseBackupJob;
|
||||||
|
use App\Jobs\ScheduledTaskJob;
|
||||||
use App\Jobs\InstanceAutoUpdateJob;
|
use App\Jobs\InstanceAutoUpdateJob;
|
||||||
use App\Jobs\ContainerStatusJob;
|
use App\Jobs\ContainerStatusJob;
|
||||||
use App\Jobs\PullHelperImageJob;
|
use App\Jobs\PullHelperImageJob;
|
||||||
use App\Jobs\ServerStatusJob;
|
use App\Jobs\ServerStatusJob;
|
||||||
use App\Models\InstanceSettings;
|
use App\Models\InstanceSettings;
|
||||||
use App\Models\ScheduledDatabaseBackup;
|
use App\Models\ScheduledDatabaseBackup;
|
||||||
|
use App\Models\ScheduledTask;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\Team;
|
use App\Models\Team;
|
||||||
use Illuminate\Console\Scheduling\Schedule;
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
@@ -30,6 +32,7 @@ class Kernel extends ConsoleKernel
|
|||||||
$this->check_resources($schedule);
|
$this->check_resources($schedule);
|
||||||
$this->check_scheduled_backups($schedule);
|
$this->check_scheduled_backups($schedule);
|
||||||
$this->pull_helper_image($schedule);
|
$this->pull_helper_image($schedule);
|
||||||
|
$this->check_scheduled_tasks($schedule);
|
||||||
} else {
|
} else {
|
||||||
// Instance Jobs
|
// Instance Jobs
|
||||||
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
||||||
@@ -41,6 +44,7 @@ class Kernel extends ConsoleKernel
|
|||||||
$this->check_scheduled_backups($schedule);
|
$this->check_scheduled_backups($schedule);
|
||||||
$this->check_resources($schedule);
|
$this->check_resources($schedule);
|
||||||
$this->pull_helper_image($schedule);
|
$this->pull_helper_image($schedule);
|
||||||
|
$this->check_scheduled_tasks($schedule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private function pull_helper_image($schedule)
|
private function pull_helper_image($schedule)
|
||||||
@@ -56,10 +60,10 @@ class Kernel extends ConsoleKernel
|
|||||||
$servers = Server::all()->whereNotNull('team.subscription')->where('team.subscription.stripe_trial_already_ended', false)->where('ip', '!=', '1.2.3.4');
|
$servers = Server::all()->whereNotNull('team.subscription')->where('team.subscription.stripe_trial_already_ended', false)->where('ip', '!=', '1.2.3.4');
|
||||||
$own = Team::find(0)->servers;
|
$own = Team::find(0)->servers;
|
||||||
$servers = $servers->merge($own);
|
$servers = $servers->merge($own);
|
||||||
$containerServers = $servers->where('settings.is_swarm_worker', false);
|
$containerServers = $servers->where('settings.is_swarm_worker', false)->where('settings.is_build_server', false);
|
||||||
} else {
|
} else {
|
||||||
$servers = Server::all()->where('ip', '!=', '1.2.3.4');
|
$servers = Server::all()->where('ip', '!=', '1.2.3.4');
|
||||||
$containerServers = $servers->where('settings.is_swarm_worker', false);
|
$containerServers = $servers->where('settings.is_swarm_worker', false)->where('settings.is_build_server', false);
|
||||||
}
|
}
|
||||||
foreach ($containerServers as $server) {
|
foreach ($containerServers as $server) {
|
||||||
$schedule->job(new ContainerStatusJob($server))->everyMinute()->onOneServer();
|
$schedule->job(new ContainerStatusJob($server))->everyMinute()->onOneServer();
|
||||||
@@ -68,7 +72,7 @@ class Kernel extends ConsoleKernel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($servers as $server) {
|
foreach ($servers as $server) {
|
||||||
$schedule->job(new ServerStatusJob($server))->everyTenMinutes()->onOneServer();
|
$schedule->job(new ServerStatusJob($server))->everyMinute()->onOneServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private function instance_auto_update($schedule)
|
private function instance_auto_update($schedule)
|
||||||
@@ -107,6 +111,32 @@ class Kernel extends ConsoleKernel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function check_scheduled_tasks($schedule)
|
||||||
|
{
|
||||||
|
$scheduled_tasks = ScheduledTask::all();
|
||||||
|
if ($scheduled_tasks->isEmpty()) {
|
||||||
|
ray('no scheduled tasks');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foreach ($scheduled_tasks as $scheduled_task) {
|
||||||
|
$service = $scheduled_task->service()->get();
|
||||||
|
$application = $scheduled_task->application()->get();
|
||||||
|
|
||||||
|
if (!$application && !$service) {
|
||||||
|
ray('application/service attached to scheduled task does not exist');
|
||||||
|
$scheduled_task->delete();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset(VALID_CRON_STRINGS[$scheduled_task->frequency])) {
|
||||||
|
$scheduled_task->frequency = VALID_CRON_STRINGS[$scheduled_task->frequency];
|
||||||
|
}
|
||||||
|
$schedule->job(new ScheduledTaskJob(
|
||||||
|
task: $scheduled_task
|
||||||
|
))->cron($scheduled_task->frequency)->onOneServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function commands(): void
|
protected function commands(): void
|
||||||
{
|
{
|
||||||
$this->load(__DIR__ . '/Commands');
|
$this->load(__DIR__ . '/Commands');
|
||||||
|
|||||||
34
app/Events/ProxyStatusChanged.php
Normal file
34
app/Events/ProxyStatusChanged.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Broadcasting\PresenceChannel;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class ProxyStatusChanged implements ShouldBroadcast
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
public $teamId;
|
||||||
|
public function __construct($teamId = null)
|
||||||
|
{
|
||||||
|
if (is_null($teamId)) {
|
||||||
|
$teamId = auth()->user()->currentTeam()->id ?? null;
|
||||||
|
}
|
||||||
|
if (is_null($teamId)) {
|
||||||
|
throw new \Exception("Team id is null");
|
||||||
|
}
|
||||||
|
$this->teamId = $teamId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function broadcastOn(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
new PrivateChannel("team.{$this->teamId}"),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,23 +2,68 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\InstanceSettings;
|
use App\Events\TestEvent;
|
||||||
use App\Models\S3Storage;
|
|
||||||
use App\Models\StandalonePostgresql;
|
|
||||||
use App\Models\TeamInvitation;
|
use App\Models\TeamInvitation;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||||
|
use Illuminate\Foundation\Auth\EmailVerificationRequest;
|
||||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Routing\Controller as BaseController;
|
use Illuminate\Routing\Controller as BaseController;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Crypt;
|
use Illuminate\Support\Facades\Crypt;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use Laravel\Fortify\Fortify;
|
||||||
|
use Laravel\Fortify\Contracts\FailedPasswordResetLinkRequestResponse;
|
||||||
|
use Laravel\Fortify\Contracts\SuccessfulPasswordResetLinkRequestResponse;
|
||||||
|
use Illuminate\Support\Facades\Password;
|
||||||
|
|
||||||
class Controller extends BaseController
|
class Controller extends BaseController
|
||||||
{
|
{
|
||||||
use AuthorizesRequests, ValidatesRequests;
|
use AuthorizesRequests, ValidatesRequests;
|
||||||
|
|
||||||
|
public function realtime_test() {
|
||||||
|
if (auth()->user()?->currentTeam()->id !== 0) {
|
||||||
|
return redirect(RouteServiceProvider::HOME);
|
||||||
|
}
|
||||||
|
TestEvent::dispatch();
|
||||||
|
return 'Look at your other tab.';
|
||||||
|
}
|
||||||
|
public function verify() {
|
||||||
|
return view('auth.verify-email');
|
||||||
|
}
|
||||||
|
public function email_verify(EmailVerificationRequest $request) {
|
||||||
|
$request->fulfill();
|
||||||
|
$name = request()->user()?->name;
|
||||||
|
send_internal_notification("User {$name} verified their email address.");
|
||||||
|
return redirect(RouteServiceProvider::HOME);
|
||||||
|
}
|
||||||
|
public function forgot_password(Request $request) {
|
||||||
|
if (is_transactional_emails_active()) {
|
||||||
|
$arrayOfRequest = $request->only(Fortify::email());
|
||||||
|
$request->merge([
|
||||||
|
'email' => Str::lower($arrayOfRequest['email']),
|
||||||
|
]);
|
||||||
|
$type = set_transanctional_email_settings();
|
||||||
|
if (!$type) {
|
||||||
|
return response()->json(['message' => 'Transactional emails are not active'], 400);
|
||||||
|
}
|
||||||
|
$request->validate([Fortify::email() => 'required|email']);
|
||||||
|
$status = Password::broker(config('fortify.passwords'))->sendResetLink(
|
||||||
|
$request->only(Fortify::email())
|
||||||
|
);
|
||||||
|
if ($status == Password::RESET_LINK_SENT) {
|
||||||
|
return app(SuccessfulPasswordResetLinkRequestResponse::class, ['status' => $status]);
|
||||||
|
}
|
||||||
|
if ($status == Password::RESET_THROTTLED) {
|
||||||
|
return response('Already requested a password reset in the past minutes.', 400);
|
||||||
|
}
|
||||||
|
return app(FailedPasswordResetLinkRequestResponse::class, ['status' => $status]);
|
||||||
|
}
|
||||||
|
return response()->json(['message' => 'Transactional emails are not active'], 400);
|
||||||
|
}
|
||||||
public function link()
|
public function link()
|
||||||
{
|
{
|
||||||
$token = request()->get('token');
|
$token = request()->get('token');
|
||||||
@@ -51,90 +96,7 @@ class Controller extends BaseController
|
|||||||
return redirect()->route('login')->with('error', 'Invalid credentials.');
|
return redirect()->route('login')->with('error', 'Invalid credentials.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function license()
|
public function accept_invitation()
|
||||||
{
|
|
||||||
if (!isCloud()) {
|
|
||||||
abort(404);
|
|
||||||
}
|
|
||||||
return view('settings.license', [
|
|
||||||
'settings' => InstanceSettings::get(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function force_passoword_reset()
|
|
||||||
{
|
|
||||||
return view('auth.force-password-reset');
|
|
||||||
}
|
|
||||||
public function boarding()
|
|
||||||
{
|
|
||||||
if (currentTeam()->boarding || isDev()) {
|
|
||||||
return view('boarding');
|
|
||||||
} else {
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function settings()
|
|
||||||
{
|
|
||||||
if (isInstanceAdmin()) {
|
|
||||||
$settings = InstanceSettings::get();
|
|
||||||
$database = StandalonePostgresql::whereName('coolify-db')->first();
|
|
||||||
if ($database) {
|
|
||||||
if ($database->status !== 'running') {
|
|
||||||
$database->status = 'running';
|
|
||||||
$database->save();
|
|
||||||
}
|
|
||||||
$s3s = S3Storage::whereTeamId(0)->get();
|
|
||||||
}
|
|
||||||
return view('settings.configuration', [
|
|
||||||
'settings' => $settings,
|
|
||||||
'database' => $database,
|
|
||||||
's3s' => $s3s ?? [],
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function team()
|
|
||||||
{
|
|
||||||
$invitations = [];
|
|
||||||
if (auth()->user()->isAdminFromSession()) {
|
|
||||||
$invitations = TeamInvitation::whereTeamId(currentTeam()->id)->get();
|
|
||||||
}
|
|
||||||
return view('team.index', [
|
|
||||||
'invitations' => $invitations,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function storages()
|
|
||||||
{
|
|
||||||
$s3 = S3Storage::ownedByCurrentTeam()->get();
|
|
||||||
return view('team.storages.all', [
|
|
||||||
's3' => $s3,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function storages_show()
|
|
||||||
{
|
|
||||||
$storage = S3Storage::ownedByCurrentTeam()->whereUuid(request()->storage_uuid)->firstOrFail();
|
|
||||||
return view('team.storages.show', [
|
|
||||||
'storage' => $storage,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function members()
|
|
||||||
{
|
|
||||||
$invitations = [];
|
|
||||||
if (auth()->user()->isAdminFromSession()) {
|
|
||||||
$invitations = TeamInvitation::whereTeamId(currentTeam()->id)->get();
|
|
||||||
}
|
|
||||||
return view('team.members', [
|
|
||||||
'invitations' => $invitations,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function acceptInvitation()
|
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$resetPassword = request()->query('reset-password');
|
$resetPassword = request()->query('reset-password');
|
||||||
@@ -169,7 +131,7 @@ class Controller extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function revokeInvitation()
|
public function revoke_invitation()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$invitation = TeamInvitation::whereUuid(request()->route('uuid'))->firstOrFail();
|
$invitation = TeamInvitation::whereUuid(request()->route('uuid'))->firstOrFail();
|
||||||
|
|||||||
@@ -1,84 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
|
|
||||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|
||||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
|
||||||
|
|
||||||
class DatabaseController extends Controller
|
|
||||||
{
|
|
||||||
use AuthorizesRequests, ValidatesRequests;
|
|
||||||
|
|
||||||
public function configuration()
|
|
||||||
{
|
|
||||||
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
|
||||||
if (!$project) {
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
|
|
||||||
if (!$environment) {
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
$database = $environment->databases()->where('uuid', request()->route('database_uuid'))->first();
|
|
||||||
if (!$database) {
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
return view('project.database.configuration', ['database' => $database]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function executions()
|
|
||||||
{
|
|
||||||
$backup_uuid = request()->route('backup_uuid');
|
|
||||||
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
|
||||||
if (!$project) {
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
|
|
||||||
if (!$environment) {
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
$database = $environment->databases()->where('uuid', request()->route('database_uuid'))->first();
|
|
||||||
if (!$database) {
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
$backup = $database->scheduledBackups->where('uuid', $backup_uuid)->first();
|
|
||||||
if (!$backup) {
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
$executions = collect($backup->executions)->sortByDesc('created_at');
|
|
||||||
return view('project.database.backups.executions', [
|
|
||||||
'database' => $database,
|
|
||||||
'backup' => $backup,
|
|
||||||
'executions' => $executions,
|
|
||||||
's3s' => currentTeam()->s3s,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function backups()
|
|
||||||
{
|
|
||||||
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
|
||||||
if (!$project) {
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
|
|
||||||
if (!$environment) {
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
$database = $environment->databases()->where('uuid', request()->route('database_uuid'))->first();
|
|
||||||
if (!$database) {
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
// No backups for redis
|
|
||||||
if ($database->getMorphClass() === 'App\Models\StandaloneRedis') {
|
|
||||||
return redirect()->route('project.database.configuration', [
|
|
||||||
'project_uuid' => $project->uuid,
|
|
||||||
'environment_name' => $environment->name,
|
|
||||||
'database_uuid' => $database->uuid,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
return view('project.database.backups.all', [
|
|
||||||
'database' => $database,
|
|
||||||
's3s' => currentTeam()->s3s,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -30,6 +30,7 @@ use Spatie\Url\Url;
|
|||||||
use Symfony\Component\Yaml\Yaml;
|
use Symfony\Component\Yaml\Yaml;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
use Visus\Cuid2\Cuid2;
|
use Visus\Cuid2\Cuid2;
|
||||||
|
use Yosymfony\Toml\Toml;
|
||||||
|
|
||||||
class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
||||||
{
|
{
|
||||||
@@ -55,7 +56,13 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
|
|
||||||
private GithubApp|GitlabApp|string $source = 'other';
|
private GithubApp|GitlabApp|string $source = 'other';
|
||||||
private StandaloneDocker|SwarmDocker $destination;
|
private StandaloneDocker|SwarmDocker $destination;
|
||||||
|
// Deploy to Server
|
||||||
private Server $server;
|
private Server $server;
|
||||||
|
// Build Server
|
||||||
|
private Server $build_server;
|
||||||
|
private bool $use_build_server = false;
|
||||||
|
// Save original server between phases
|
||||||
|
private Server $original_server;
|
||||||
private Server $mainServer;
|
private Server $mainServer;
|
||||||
private ?ApplicationPreview $preview = null;
|
private ?ApplicationPreview $preview = null;
|
||||||
private ?string $git_type = null;
|
private ?string $git_type = null;
|
||||||
@@ -71,8 +78,11 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
private bool $is_debug_enabled;
|
private bool $is_debug_enabled;
|
||||||
private $build_args;
|
private $build_args;
|
||||||
private $env_args;
|
private $env_args;
|
||||||
|
private $env_nixpacks_args;
|
||||||
private $docker_compose;
|
private $docker_compose;
|
||||||
private $docker_compose_base64;
|
private $docker_compose_base64;
|
||||||
|
private ?string $nixpacks_plan = null;
|
||||||
|
private ?string $nixpacks_type = null;
|
||||||
private string $dockerfile_location = '/Dockerfile';
|
private string $dockerfile_location = '/Dockerfile';
|
||||||
private string $docker_compose_location = '/docker-compose.yml';
|
private string $docker_compose_location = '/docker-compose.yml';
|
||||||
private ?string $docker_compose_custom_start_command = null;
|
private ?string $docker_compose_custom_start_command = null;
|
||||||
@@ -192,6 +202,25 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
// Check custom port
|
// Check custom port
|
||||||
['repository' => $this->customRepository, 'port' => $this->customPort] = $this->application->customRepository();
|
['repository' => $this->customRepository, 'port' => $this->customPort] = $this->application->customRepository();
|
||||||
|
|
||||||
|
if (data_get($this->application, 'settings.is_build_server_enabled')) {
|
||||||
|
$teamId = data_get($this->application, 'environment.project.team.id');
|
||||||
|
$buildServers = Server::buildServers($teamId)->get();
|
||||||
|
if ($buildServers->count() === 0) {
|
||||||
|
$this->application_deployment_queue->addLogEntry("Build server feature activated, but no suitable build server found. Using the deployment server.");
|
||||||
|
$this->build_server = $this->server;
|
||||||
|
$this->original_server = $this->server;
|
||||||
|
} else {
|
||||||
|
$this->application_deployment_queue->addLogEntry("Build server feature activated and found a suitable build server. Using it to build your application - if needed.");
|
||||||
|
$this->build_server = $buildServers->random();
|
||||||
|
$this->original_server = $this->server;
|
||||||
|
$this->use_build_server = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Set build server & original_server to the same as deployment server
|
||||||
|
$this->build_server = $this->server;
|
||||||
|
$this->original_server = $this->server;
|
||||||
|
}
|
||||||
|
ray($this->build_server);
|
||||||
try {
|
try {
|
||||||
if ($this->restart_only && $this->application->build_pack !== 'dockerimage') {
|
if ($this->restart_only && $this->application->build_pack !== 'dockerimage') {
|
||||||
$this->just_restart();
|
$this->just_restart();
|
||||||
@@ -199,7 +228,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
dispatch(new ContainerStatusJob($this->server));
|
dispatch(new ContainerStatusJob($this->server));
|
||||||
}
|
}
|
||||||
$this->next(ApplicationDeploymentStatus::FINISHED->value);
|
$this->next(ApplicationDeploymentStatus::FINISHED->value);
|
||||||
$this->application->isConfigurationChanged(true);
|
$this->application->isConfigurationChanged(false);
|
||||||
return;
|
return;
|
||||||
} else if ($this->application->dockerfile) {
|
} else if ($this->application->dockerfile) {
|
||||||
$this->deploy_simple_dockerfile();
|
$this->deploy_simple_dockerfile();
|
||||||
@@ -221,7 +250,8 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
if ($this->server->isProxyShouldRun()) {
|
if ($this->server->isProxyShouldRun()) {
|
||||||
dispatch(new ContainerStatusJob($this->server));
|
dispatch(new ContainerStatusJob($this->server));
|
||||||
}
|
}
|
||||||
if ($this->application->docker_registry_image_name && $this->application->build_pack !== 'dockerimage' && !$this->application->destination->server->isSwarm()) {
|
// Otherwise built image needs to be pushed before from the build server.
|
||||||
|
if (!$this->use_build_server) {
|
||||||
$this->push_to_docker_registry();
|
$this->push_to_docker_registry();
|
||||||
}
|
}
|
||||||
$this->next(ApplicationDeploymentStatus::FINISHED->value);
|
$this->next(ApplicationDeploymentStatus::FINISHED->value);
|
||||||
@@ -230,23 +260,10 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
$this->fail($e);
|
$this->fail($e);
|
||||||
throw $e;
|
throw $e;
|
||||||
} finally {
|
} finally {
|
||||||
if (isset($this->docker_compose_base64)) {
|
if ($this->use_build_server) {
|
||||||
$readme = generate_readme_file($this->application->name, $this->application_deployment_queue->updated_at);
|
$this->server = $this->build_server;
|
||||||
$composeFileName = "$this->configuration_dir/docker-compose.yml";
|
} else {
|
||||||
if ($this->pull_request_id !== 0) {
|
$this->write_deployment_configurations();
|
||||||
$composeFileName = "$this->configuration_dir/docker-compose-pr-{$this->pull_request_id}.yml";
|
|
||||||
}
|
|
||||||
$this->execute_remote_command(
|
|
||||||
[
|
|
||||||
"mkdir -p $this->configuration_dir"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"echo '{$this->docker_compose_base64}' | base64 -d > $composeFileName",
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"echo '{$readme}' > $this->configuration_dir/README.md",
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
@@ -265,23 +282,56 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
ApplicationStatusChanged::dispatch(data_get($this->application, 'environment.project.team.id'));
|
ApplicationStatusChanged::dispatch(data_get($this->application, 'environment.project.team.id'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private function push_to_docker_registry()
|
private function write_deployment_configurations()
|
||||||
{
|
{
|
||||||
try {
|
if (isset($this->docker_compose_base64)) {
|
||||||
instant_remote_process(["docker images --format '{{json .}}' {$this->production_image_name}"], $this->server);
|
if ($this->use_build_server) {
|
||||||
|
$this->server = $this->original_server;
|
||||||
|
}
|
||||||
|
$readme = generate_readme_file($this->application->name, $this->application_deployment_queue->updated_at);
|
||||||
|
$composeFileName = "$this->configuration_dir/docker-compose.yml";
|
||||||
|
if ($this->pull_request_id !== 0) {
|
||||||
|
$composeFileName = "$this->configuration_dir/docker-compose-pr-{$this->pull_request_id}.yml";
|
||||||
|
}
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
"echo '\n----------------------------------------'",
|
"mkdir -p $this->configuration_dir"
|
||||||
],
|
],
|
||||||
["echo -n 'Pushing image to docker registry ({$this->production_image_name}).'"],
|
[
|
||||||
|
"echo '{$this->docker_compose_base64}' | base64 -d > $composeFileName",
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"echo '{$readme}' > $this->configuration_dir/README.md",
|
||||||
|
]
|
||||||
|
);
|
||||||
|
if ($this->use_build_server) {
|
||||||
|
$this->server = $this->build_server;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private function push_to_docker_registry($forceFail = false)
|
||||||
|
{
|
||||||
|
ray((str($this->saved_outputs->get('local_image_found'))->isNotEmpty() && !$this->application->isConfigurationChanged()));
|
||||||
|
if (
|
||||||
|
$this->application->docker_registry_image_name &&
|
||||||
|
$this->application->build_pack !== 'dockerimage' &&
|
||||||
|
!$this->application->destination->server->isSwarm() &&
|
||||||
|
!$this->restart_only &&
|
||||||
|
!(str($this->saved_outputs->get('local_image_found'))->isNotEmpty() && !$this->application->isConfigurationChanged())
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
instant_remote_process(["docker images --format '{{json .}}' {$this->production_image_name}"], $this->server);
|
||||||
|
$this->application_deployment_queue->addLogEntry("----------------------------------------");
|
||||||
|
$this->application_deployment_queue->addLogEntry("Pushing image to docker registry ({$this->production_image_name}).");
|
||||||
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, "docker push {$this->production_image_name}"), 'hidden' => true
|
executeInDocker($this->deployment_uuid, "docker push {$this->production_image_name}"), 'hidden' => true
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
if ($this->application->docker_registry_image_tag) {
|
if ($this->application->docker_registry_image_tag) {
|
||||||
// Tag image with latest
|
// Tag image with latest
|
||||||
|
$this->application_deployment_queue->addLogEntry("Tagging and pushing image with latest tag.");
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
['echo -n "Tagging and pushing image with latest tag."'],
|
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, "docker tag {$this->production_image_name} {$this->application->docker_registry_image_name}:{$this->application->docker_registry_image_tag}"), 'ignore_errors' => true, 'hidden' => true
|
executeInDocker($this->deployment_uuid, "docker tag {$this->production_image_name} {$this->application->docker_registry_image_name}:{$this->application->docker_registry_image_tag}"), 'ignore_errors' => true, 'hidden' => true
|
||||||
],
|
],
|
||||||
@@ -290,19 +340,16 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$this->execute_remote_command([
|
$this->application_deployment_queue->addLogEntry("Image pushed to docker registry.'");
|
||||||
"echo -n 'Image pushed to docker registry.'"
|
|
||||||
]);
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
if ($this->application->destination->server->isSwarm()) {
|
$this->application_deployment_queue->addLogEntry("Failed to push image to docker registry. Please check debug logs for more information.'");
|
||||||
|
if ($forceFail) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
$this->execute_remote_command(
|
|
||||||
["echo -n 'Failed to push image to docker registry. Please check debug logs for more information.'"],
|
|
||||||
);
|
|
||||||
ray($e);
|
ray($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private function generate_image_names()
|
private function generate_image_names()
|
||||||
{
|
{
|
||||||
if ($this->application->dockerfile) {
|
if ($this->application->dockerfile) {
|
||||||
@@ -336,17 +383,14 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
}
|
}
|
||||||
private function just_restart()
|
private function just_restart()
|
||||||
{
|
{
|
||||||
$this->execute_remote_command(
|
$this->application_deployment_queue->addLogEntry("Starting deployment of {$this->customRepository}:{$this->application->git_branch}.'");
|
||||||
[
|
|
||||||
"echo 'Starting deployment of {$this->customRepository}:{$this->application->git_branch}.'"
|
|
||||||
],
|
|
||||||
);
|
|
||||||
$this->prepare_builder_image();
|
$this->prepare_builder_image();
|
||||||
$this->check_git_if_build_needed();
|
$this->check_git_if_build_needed();
|
||||||
$this->set_base_dir();
|
$this->set_base_dir();
|
||||||
$this->generate_image_names();
|
$this->generate_image_names();
|
||||||
$this->check_image_locally_or_remotely();
|
$this->check_image_locally_or_remotely();
|
||||||
if (str($this->saved_outputs->get('local_image_found'))->isNotEmpty()) {
|
if (str($this->saved_outputs->get('local_image_found'))->isNotEmpty()) {
|
||||||
|
$this->application_deployment_queue->addLogEntry("Image found ({$this->production_image_name}) with the same Git Commit SHA. Restarting container.");
|
||||||
$this->create_workdir();
|
$this->create_workdir();
|
||||||
$this->generate_compose_file();
|
$this->generate_compose_file();
|
||||||
$this->rolling_update();
|
$this->rolling_update();
|
||||||
@@ -390,16 +434,15 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
|
|
||||||
private function deploy_simple_dockerfile()
|
private function deploy_simple_dockerfile()
|
||||||
{
|
{
|
||||||
|
if ($this->use_build_server) {
|
||||||
|
$this->server = $this->build_server;
|
||||||
|
}
|
||||||
$dockerfile_base64 = base64_encode($this->application->dockerfile);
|
$dockerfile_base64 = base64_encode($this->application->dockerfile);
|
||||||
$this->execute_remote_command(
|
$this->application_deployment_queue->addLogEntry("Starting deployment of {$this->application->name}.");
|
||||||
[
|
|
||||||
"echo 'Starting deployment of {$this->application->name}.'"
|
|
||||||
],
|
|
||||||
);
|
|
||||||
$this->prepare_builder_image();
|
$this->prepare_builder_image();
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, "echo '$dockerfile_base64' | base64 -d > $this->workdir$this->dockerfile_location")
|
executeInDocker($this->deployment_uuid, "echo '$dockerfile_base64' | base64 -d > {$this->workdir}{$this->dockerfile_location}")
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
$this->generate_image_names();
|
$this->generate_image_names();
|
||||||
@@ -415,11 +458,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
$this->dockerImage = $this->application->docker_registry_image_name;
|
$this->dockerImage = $this->application->docker_registry_image_name;
|
||||||
$this->dockerImageTag = $this->application->docker_registry_image_tag;
|
$this->dockerImageTag = $this->application->docker_registry_image_tag;
|
||||||
ray("echo 'Starting deployment of {$this->dockerImage}:{$this->dockerImageTag}.'");
|
ray("echo 'Starting deployment of {$this->dockerImage}:{$this->dockerImageTag}.'");
|
||||||
$this->execute_remote_command(
|
$this->application_deployment_queue->addLogEntry("Starting deployment of {$this->dockerImage}:{$this->dockerImageTag}.");
|
||||||
[
|
|
||||||
"echo 'Starting deployment of {$this->dockerImage}:{$this->dockerImageTag}.'"
|
|
||||||
],
|
|
||||||
);
|
|
||||||
$this->generate_image_names();
|
$this->generate_image_names();
|
||||||
$this->prepare_builder_image();
|
$this->prepare_builder_image();
|
||||||
$this->generate_compose_file();
|
$this->generate_compose_file();
|
||||||
@@ -470,7 +509,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} -f {$this->workdir}{$this->docker_compose_location} build"), "hidden" => true],
|
[executeInDocker($this->deployment_uuid, "SOURCE_COMMIT={$this->commit} docker compose --project-directory {$this->workdir} -f {$this->workdir}{$this->docker_compose_location} build"), "hidden" => true],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -489,24 +528,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
"docker network connect {$networkId} coolify-proxy || true", "hidden" => true, "ignore_errors" => true
|
"docker network connect {$networkId} coolify-proxy || true", "hidden" => true, "ignore_errors" => true
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
if (isset($this->docker_compose_base64)) {
|
$this->write_deployment_configurations();
|
||||||
$readme = generate_readme_file($this->application->name, $this->application_deployment_queue->updated_at);
|
|
||||||
$composeFileName = "$this->configuration_dir/docker-compose.yml";
|
|
||||||
if ($this->pull_request_id !== 0) {
|
|
||||||
$composeFileName = "$this->configuration_dir/docker-compose-pr-{$this->pull_request_id}.yml";
|
|
||||||
}
|
|
||||||
$this->execute_remote_command(
|
|
||||||
[
|
|
||||||
"mkdir -p $this->configuration_dir"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"echo '{$this->docker_compose_base64}' | base64 -d > $composeFileName",
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"echo '{$readme}' > $this->configuration_dir/README.md",
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// Start compose file
|
// Start compose file
|
||||||
if ($this->docker_compose_custom_start_command) {
|
if ($this->docker_compose_custom_start_command) {
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
@@ -514,21 +536,20 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} -f {$this->workdir}{$this->docker_compose_location} up -d"), "hidden" => true],
|
[executeInDocker($this->deployment_uuid, "SOURCE_COMMIT={$this->commit} docker compose --project-directory {$this->workdir} -f {$this->workdir}{$this->docker_compose_location} up -d"), "hidden" => true],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$this->application_deployment_queue->addLogEntry("New container started.");
|
$this->application_deployment_queue->addLogEntry("New container started.");
|
||||||
}
|
}
|
||||||
private function deploy_dockerfile_buildpack()
|
private function deploy_dockerfile_buildpack()
|
||||||
{
|
{
|
||||||
|
if ($this->use_build_server) {
|
||||||
|
$this->server = $this->build_server;
|
||||||
|
}
|
||||||
if (data_get($this->application, 'dockerfile_location')) {
|
if (data_get($this->application, 'dockerfile_location')) {
|
||||||
$this->dockerfile_location = $this->application->dockerfile_location;
|
$this->dockerfile_location = $this->application->dockerfile_location;
|
||||||
}
|
}
|
||||||
$this->execute_remote_command(
|
$this->application_deployment_queue->addLogEntry("Starting deployment of {$this->customRepository}:{$this->application->git_branch}.");
|
||||||
[
|
|
||||||
"echo 'Starting deployment of {$this->customRepository}:{$this->application->git_branch}.'"
|
|
||||||
],
|
|
||||||
);
|
|
||||||
$this->prepare_builder_image();
|
$this->prepare_builder_image();
|
||||||
$this->check_git_if_build_needed();
|
$this->check_git_if_build_needed();
|
||||||
$this->clone_repository();
|
$this->clone_repository();
|
||||||
@@ -548,11 +569,10 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
}
|
}
|
||||||
private function deploy_nixpacks_buildpack()
|
private function deploy_nixpacks_buildpack()
|
||||||
{
|
{
|
||||||
$this->execute_remote_command(
|
if ($this->use_build_server) {
|
||||||
[
|
$this->server = $this->build_server;
|
||||||
"echo 'Starting deployment of {$this->customRepository}:{$this->application->git_branch}.'"
|
}
|
||||||
],
|
$this->application_deployment_queue->addLogEntry("Starting deployment of {$this->customRepository}:{$this->application->git_branch}.");
|
||||||
);
|
|
||||||
$this->prepare_builder_image();
|
$this->prepare_builder_image();
|
||||||
$this->check_git_if_build_needed();
|
$this->check_git_if_build_needed();
|
||||||
$this->set_base_dir();
|
$this->set_base_dir();
|
||||||
@@ -561,17 +581,13 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
$this->check_image_locally_or_remotely();
|
$this->check_image_locally_or_remotely();
|
||||||
if (str($this->saved_outputs->get('local_image_found'))->isNotEmpty() && !$this->application->isConfigurationChanged()) {
|
if (str($this->saved_outputs->get('local_image_found'))->isNotEmpty() && !$this->application->isConfigurationChanged()) {
|
||||||
$this->create_workdir();
|
$this->create_workdir();
|
||||||
$this->execute_remote_command([
|
$this->application_deployment_queue->addLogEntry("No configuration changed & image found ({$this->production_image_name}) with the same Git Commit SHA. Build step skipped.");
|
||||||
"echo 'No configuration changed & image found ({$this->production_image_name}) with the same Git Commit SHA. Build step skipped.'",
|
|
||||||
]);
|
|
||||||
$this->generate_compose_file();
|
$this->generate_compose_file();
|
||||||
$this->rolling_update();
|
$this->rolling_update();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($this->application->isConfigurationChanged()) {
|
if ($this->application->isConfigurationChanged()) {
|
||||||
$this->execute_remote_command([
|
$this->application_deployment_queue->addLogEntry("Configuration changed. Rebuilding image.");
|
||||||
"echo 'Configuration changed. Rebuilding image.'",
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->clone_repository();
|
$this->clone_repository();
|
||||||
@@ -579,17 +595,16 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
$this->generate_nixpacks_confs();
|
$this->generate_nixpacks_confs();
|
||||||
$this->generate_compose_file();
|
$this->generate_compose_file();
|
||||||
$this->generate_build_env_variables();
|
$this->generate_build_env_variables();
|
||||||
$this->add_build_env_variables_to_dockerfile();
|
// $this->add_build_env_variables_to_dockerfile();
|
||||||
$this->build_image();
|
$this->build_image();
|
||||||
$this->rolling_update();
|
$this->rolling_update();
|
||||||
}
|
}
|
||||||
private function deploy_static_buildpack()
|
private function deploy_static_buildpack()
|
||||||
{
|
{
|
||||||
$this->execute_remote_command(
|
if ($this->use_build_server) {
|
||||||
[
|
$this->server = $this->build_server;
|
||||||
"echo 'Starting deployment of {$this->customRepository}:{$this->application->git_branch}.'"
|
}
|
||||||
],
|
$this->application_deployment_queue->addLogEntry("Starting deployment of {$this->customRepository}:{$this->application->git_branch}.");
|
||||||
);
|
|
||||||
$this->prepare_builder_image();
|
$this->prepare_builder_image();
|
||||||
$this->check_git_if_build_needed();
|
$this->check_git_if_build_needed();
|
||||||
$this->set_base_dir();
|
$this->set_base_dir();
|
||||||
@@ -601,11 +616,25 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
$this->rolling_update();
|
$this->rolling_update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function framework_based_notification()
|
||||||
|
{
|
||||||
|
// Laravel old env variables
|
||||||
|
if ($this->pull_request_id === 0) {
|
||||||
|
$nixpacks_php_fallback_path = $this->application->environment_variables->where('key', 'NIXPACKS_PHP_FALLBACK_PATH')->first();
|
||||||
|
$nixpacks_php_root_dir = $this->application->environment_variables->where('key', 'NIXPACKS_PHP_ROOT_DIR')->first();
|
||||||
|
} else {
|
||||||
|
$nixpacks_php_fallback_path = $this->application->environment_variables_preview->where('key', 'NIXPACKS_PHP_FALLBACK_PATH')->first();
|
||||||
|
$nixpacks_php_root_dir = $this->application->environment_variables_preview->where('key', 'NIXPACKS_PHP_ROOT_DIR')->first();
|
||||||
|
}
|
||||||
|
if ($nixpacks_php_fallback_path?->value === '/index.php' && $nixpacks_php_root_dir?->value === '/app/public' && $this->newVersionIsHealthy === false) {
|
||||||
|
$this->application_deployment_queue->addLogEntry("There was a change in how Laravel is deployed. Please update your environment variables to match the new deployment method. More details here: https://coolify.io/docs/frameworks/laravel#requirements", 'stderr');
|
||||||
|
}
|
||||||
|
}
|
||||||
private function rolling_update()
|
private function rolling_update()
|
||||||
{
|
{
|
||||||
if ($this->server->isSwarm()) {
|
if ($this->server->isSwarm()) {
|
||||||
if ($this->build_pack !== 'dockerimage') {
|
if ($this->build_pack !== 'dockerimage') {
|
||||||
$this->push_to_docker_registry();
|
$this->push_to_docker_registry(forceFail: true);
|
||||||
}
|
}
|
||||||
$this->application_deployment_queue->addLogEntry("Rolling update started.");
|
$this->application_deployment_queue->addLogEntry("Rolling update started.");
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
@@ -615,28 +644,26 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
);
|
);
|
||||||
$this->application_deployment_queue->addLogEntry("Rolling update completed.");
|
$this->application_deployment_queue->addLogEntry("Rolling update completed.");
|
||||||
} else {
|
} else {
|
||||||
|
if ($this->use_build_server) {
|
||||||
|
$this->push_to_docker_registry(forceFail: true);
|
||||||
|
$this->write_deployment_configurations();
|
||||||
|
$this->server = $this->original_server;
|
||||||
|
}
|
||||||
if (count($this->application->ports_mappings_array) > 0) {
|
if (count($this->application->ports_mappings_array) > 0) {
|
||||||
$this->execute_remote_command(
|
$this->application_deployment_queue->addLogEntry("----------------------------------------");
|
||||||
[
|
$this->application_deployment_queue->addLogEntry("Application has ports mapped to the host system, rolling update is not supported.");
|
||||||
"echo '\n----------------------------------------'",
|
|
||||||
],
|
|
||||||
["echo -n 'Application has ports mapped to the host system, rolling update is not supported.'"],
|
|
||||||
);
|
|
||||||
$this->stop_running_container(force: true);
|
$this->stop_running_container(force: true);
|
||||||
$this->start_by_compose_file();
|
$this->start_by_compose_file();
|
||||||
} else {
|
} else {
|
||||||
$this->execute_remote_command(
|
$this->application_deployment_queue->addLogEntry("----------------------------------------");
|
||||||
[
|
$this->application_deployment_queue->addLogEntry("Rolling update started.");
|
||||||
"echo '\n----------------------------------------'",
|
|
||||||
],
|
|
||||||
["echo -n 'Rolling update started.'"],
|
|
||||||
);
|
|
||||||
$this->start_by_compose_file();
|
$this->start_by_compose_file();
|
||||||
$this->health_check();
|
$this->health_check();
|
||||||
$this->stop_running_container();
|
$this->stop_running_container();
|
||||||
$this->application_deployment_queue->addLogEntry("Rolling update completed.");
|
$this->application_deployment_queue->addLogEntry("Rolling update completed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->framework_based_notification();
|
||||||
}
|
}
|
||||||
private function health_check()
|
private function health_check()
|
||||||
{
|
{
|
||||||
@@ -650,40 +677,29 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
// ray('New container name: ', $this->container_name);
|
// ray('New container name: ', $this->container_name);
|
||||||
if ($this->container_name) {
|
if ($this->container_name) {
|
||||||
$counter = 1;
|
$counter = 1;
|
||||||
$this->execute_remote_command(
|
$this->application_deployment_queue->addLogEntry("Waiting for healthcheck to pass on the new container.");
|
||||||
[
|
|
||||||
"echo 'Waiting for healthcheck to pass on the new container.'"
|
|
||||||
]
|
|
||||||
);
|
|
||||||
if ($this->full_healthcheck_url) {
|
if ($this->full_healthcheck_url) {
|
||||||
$this->execute_remote_command(
|
$this->application_deployment_queue->addLogEntry("Healthcheck URL (inside the container): {$this->full_healthcheck_url}");
|
||||||
[
|
|
||||||
"echo 'Healthcheck URL (inside the container): {$this->full_healthcheck_url}'"
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
while ($counter < $this->application->health_check_retries) {
|
while ($counter < $this->application->health_check_retries) {
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
"docker inspect --format='{{json .State.Health.Status}}' {$this->container_name}",
|
"docker inspect --format='{{json .State.Health.Status}}' {$this->container_name}",
|
||||||
"hidden" => true,
|
"hidden" => true,
|
||||||
"save" => "health_check"
|
"save" => "health_check",
|
||||||
|
"append" => false
|
||||||
],
|
],
|
||||||
|
|
||||||
);
|
);
|
||||||
$this->execute_remote_command(
|
$this->application_deployment_queue->addLogEntry("Attempt {$counter} of {$this->application->health_check_retries} | Healthcheck status: {$this->saved_outputs->get('health_check')}");
|
||||||
[
|
if (Str::of($this->saved_outputs->get('health_check'))->replace('"', '')->value() === 'healthy') {
|
||||||
"echo 'Attempt {$counter} of {$this->application->health_check_retries} | Healthcheck status: {$this->saved_outputs->get('health_check')}'"
|
|
||||||
],
|
|
||||||
);
|
|
||||||
if (Str::of($this->saved_outputs->get('health_check'))->contains('healthy')) {
|
|
||||||
$this->newVersionIsHealthy = true;
|
$this->newVersionIsHealthy = true;
|
||||||
$this->application->update(['status' => 'running']);
|
$this->application->update(['status' => 'running']);
|
||||||
$this->execute_remote_command(
|
$this->application_deployment_queue->addLogEntry("New container is healthy.");
|
||||||
[
|
break;
|
||||||
"echo 'New container is healthy.'"
|
}
|
||||||
],
|
if (Str::of($this->saved_outputs->get('health_check'))->replace('"', '')->value() === 'unhealthy') {
|
||||||
);
|
$this->newVersionIsHealthy = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$counter++;
|
$counter++;
|
||||||
@@ -694,11 +710,12 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
}
|
}
|
||||||
private function deploy_pull_request()
|
private function deploy_pull_request()
|
||||||
{
|
{
|
||||||
|
if ($this->use_build_server) {
|
||||||
|
$this->server = $this->build_server;
|
||||||
|
}
|
||||||
$this->newVersionIsHealthy = true;
|
$this->newVersionIsHealthy = true;
|
||||||
$this->generate_image_names();
|
$this->generate_image_names();
|
||||||
$this->execute_remote_command([
|
$this->application_deployment_queue->addLogEntry("Starting pull request (#{$this->pull_request_id}) deployment of {$this->customRepository}:{$this->application->git_branch}.");
|
||||||
"echo 'Starting pull request (#{$this->pull_request_id}) deployment of {$this->customRepository}:{$this->application->git_branch}.'",
|
|
||||||
]);
|
|
||||||
$this->prepare_builder_image();
|
$this->prepare_builder_image();
|
||||||
$this->clone_repository();
|
$this->clone_repository();
|
||||||
$this->set_base_dir();
|
$this->set_base_dir();
|
||||||
@@ -707,13 +724,15 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
$this->generate_nixpacks_confs();
|
$this->generate_nixpacks_confs();
|
||||||
}
|
}
|
||||||
$this->generate_compose_file();
|
$this->generate_compose_file();
|
||||||
|
|
||||||
// Needs separate preview variables
|
// Needs separate preview variables
|
||||||
$this->generate_build_env_variables();
|
$this->generate_build_env_variables();
|
||||||
|
if ($this->application->build_pack !== 'nixpacks') {
|
||||||
$this->add_build_env_variables_to_dockerfile();
|
$this->add_build_env_variables_to_dockerfile();
|
||||||
|
}
|
||||||
$this->build_image();
|
$this->build_image();
|
||||||
$this->stop_running_container();
|
$this->stop_running_container();
|
||||||
if ($this->application->destination->server->isSwarm()) {
|
if ($this->application->destination->server->isSwarm()) {
|
||||||
ray("{$this->workdir}{$this->docker_compose_location}");
|
|
||||||
$this->push_to_docker_registry();
|
$this->push_to_docker_registry();
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
@@ -721,10 +740,16 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
$this->application_deployment_queue->addLogEntry("Starting preview deployment.");
|
||||||
|
if ($this->use_build_server) {
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
["echo -n 'Starting preview deployment.'"],
|
["SOURCE_COMMIT={$this->commit} docker compose --project-directory {$this->configuration_dir} -f {$this->configuration_dir}{$this->docker_compose_location} up --build -d", "hidden" => true],
|
||||||
[executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} up -d"), "hidden" => true],
|
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
$this->execute_remote_command(
|
||||||
|
[executeInDocker($this->deployment_uuid, "SOURCE_COMMIT={$this->commit} docker compose --project-directory {$this->workdir} -f {$this->workdir}{$this->docker_compose_location} up --build -d"), "hidden" => true],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private function create_workdir()
|
private function create_workdir()
|
||||||
@@ -741,16 +766,20 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
// Get user home directory
|
// Get user home directory
|
||||||
$this->serverUserHomeDir = instant_remote_process(["echo \$HOME"], $this->server);
|
$this->serverUserHomeDir = instant_remote_process(["echo \$HOME"], $this->server);
|
||||||
$this->dockerConfigFileExists = instant_remote_process(["test -f {$this->serverUserHomeDir}/.docker/config.json && echo 'OK' || echo 'NOK'"], $this->server);
|
$this->dockerConfigFileExists = instant_remote_process(["test -f {$this->serverUserHomeDir}/.docker/config.json && echo 'OK' || echo 'NOK'"], $this->server);
|
||||||
|
if ($this->use_build_server) {
|
||||||
|
if ($this->dockerConfigFileExists === 'NOK') {
|
||||||
|
throw new RuntimeException('Docker config file (~/.docker/config.json) not found on the build server. Please run "docker login" to login to the docker registry on the server.');
|
||||||
|
}
|
||||||
|
$runCommand = "docker run -d --name {$this->deployment_uuid} --rm -v {$this->serverUserHomeDir}/.docker/config.json:/root/.docker/config.json:ro -v /var/run/docker.sock:/var/run/docker.sock {$helperImage}";
|
||||||
|
} else {
|
||||||
if ($this->dockerConfigFileExists === 'OK') {
|
if ($this->dockerConfigFileExists === 'OK') {
|
||||||
$runCommand = "docker run -d --network {$this->destination->network} --name {$this->deployment_uuid} --rm -v {$this->serverUserHomeDir}/.docker/config.json:/root/.docker/config.json:ro -v /var/run/docker.sock:/var/run/docker.sock {$helperImage}";
|
$runCommand = "docker run -d --network {$this->destination->network} --name {$this->deployment_uuid} --rm -v {$this->serverUserHomeDir}/.docker/config.json:/root/.docker/config.json:ro -v /var/run/docker.sock:/var/run/docker.sock {$helperImage}";
|
||||||
} else {
|
} else {
|
||||||
$runCommand = "docker run -d --network {$this->destination->network} --name {$this->deployment_uuid} --rm -v /var/run/docker.sock:/var/run/docker.sock {$helperImage}";
|
$runCommand = "docker run -d --network {$this->destination->network} --name {$this->deployment_uuid} --rm -v /var/run/docker.sock:/var/run/docker.sock {$helperImage}";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
$this->application_deployment_queue->addLogEntry("Preparing container with helper image: $helperImage.");
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
|
||||||
"echo -n 'Preparing container with helper image: $helperImage.'",
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
$runCommand,
|
$runCommand,
|
||||||
"hidden" => true,
|
"hidden" => true,
|
||||||
@@ -768,19 +797,11 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
$destination = StandaloneDocker::find($destination_id);
|
$destination = StandaloneDocker::find($destination_id);
|
||||||
$server = $destination->server;
|
$server = $destination->server;
|
||||||
if ($server->team_id !== $this->mainServer->team_id) {
|
if ($server->team_id !== $this->mainServer->team_id) {
|
||||||
$this->execute_remote_command(
|
$this->application_deployment_queue->addLogEntry("Skipping deployment to {$server->name}. Not in the same team?!");
|
||||||
[
|
|
||||||
"echo -n 'Skipping deployment to {$server->name}. Not in the same team?!'",
|
|
||||||
],
|
|
||||||
);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$this->server = $server;
|
$this->server = $server;
|
||||||
$this->execute_remote_command(
|
$this->application_deployment_queue->addLogEntry("Deploying to {$this->server->name}.");
|
||||||
[
|
|
||||||
"echo -n 'Deploying to {$this->server->name}.'",
|
|
||||||
],
|
|
||||||
);
|
|
||||||
$this->prepare_builder_image();
|
$this->prepare_builder_image();
|
||||||
$this->generate_image_names();
|
$this->generate_image_names();
|
||||||
$this->rolling_update();
|
$this->rolling_update();
|
||||||
@@ -788,11 +809,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
}
|
}
|
||||||
private function set_base_dir()
|
private function set_base_dir()
|
||||||
{
|
{
|
||||||
$this->execute_remote_command(
|
$this->application_deployment_queue->addLogEntry("Setting base directory to {$this->workdir}.");
|
||||||
[
|
|
||||||
"echo -n 'Setting base directory to {$this->workdir}.'"
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
private function check_git_if_build_needed()
|
private function check_git_if_build_needed()
|
||||||
{
|
{
|
||||||
@@ -825,7 +842,6 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->saved_outputs->get('git_commit_sha')) {
|
if ($this->saved_outputs->get('git_commit_sha')) {
|
||||||
$this->commit = $this->saved_outputs->get('git_commit_sha')->before("\t");
|
$this->commit = $this->saved_outputs->get('git_commit_sha')->before("\t");
|
||||||
}
|
}
|
||||||
@@ -866,24 +882,36 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
private function generate_nixpacks_confs()
|
private function generate_nixpacks_confs()
|
||||||
{
|
{
|
||||||
$nixpacks_command = $this->nixpacks_build_cmd();
|
$nixpacks_command = $this->nixpacks_build_cmd();
|
||||||
|
$this->application_deployment_queue->addLogEntry("Generating nixpacks configuration with: $nixpacks_command");
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[executeInDocker($this->deployment_uuid, $nixpacks_command), "save" => "nixpacks_plan", "hidden" => true],
|
||||||
"echo -n 'Generating nixpacks configuration with: $nixpacks_command'",
|
[executeInDocker($this->deployment_uuid, "nixpacks detect {$this->workdir}"), "save" => "nixpacks_type", "hidden" => true],
|
||||||
],
|
|
||||||
[executeInDocker($this->deployment_uuid, $nixpacks_command)],
|
|
||||||
[executeInDocker($this->deployment_uuid, "cp {$this->workdir}/.nixpacks/Dockerfile {$this->workdir}/Dockerfile")],
|
|
||||||
[executeInDocker($this->deployment_uuid, "rm -f {$this->workdir}/.nixpacks/Dockerfile")]
|
|
||||||
);
|
);
|
||||||
|
if ($this->saved_outputs->get('nixpacks_type')) {
|
||||||
|
$this->nixpacks_type = $this->saved_outputs->get('nixpacks_type');
|
||||||
|
if (str($this->nixpacks_type)->isEmpty()) {
|
||||||
|
throw new RuntimeException('Nixpacks failed to detect the application type. Please check the documentation of Nixpacks: https://nixpacks.com/docs/providers');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($this->saved_outputs->get('nixpacks_plan')) {
|
||||||
|
$this->nixpacks_plan = $this->saved_outputs->get('nixpacks_plan');
|
||||||
|
if ($this->nixpacks_plan) {
|
||||||
|
$this->application_deployment_queue->addLogEntry("Found application type: {$this->nixpacks_type}.");
|
||||||
|
$this->application_deployment_queue->addLogEntry("If you need further customization, please check the documentation of Nixpacks: https://nixpacks.com/docs/providers/{$this->nixpacks_type}");
|
||||||
|
$parsed = Toml::Parse($this->nixpacks_plan);
|
||||||
|
// Do any modifications here
|
||||||
|
$this->generate_env_variables();
|
||||||
|
$merged_envs = $this->env_args->merge(collect(data_get($parsed, 'variables', [])));
|
||||||
|
data_set($parsed, 'variables', $merged_envs->toArray());
|
||||||
|
$this->nixpacks_plan = json_encode($parsed, JSON_PRETTY_PRINT);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function nixpacks_build_cmd()
|
private function nixpacks_build_cmd()
|
||||||
{
|
{
|
||||||
$this->generate_env_variables();
|
$this->generate_nixpacks_env_variables();
|
||||||
// $cacheKey = $this->application->uuid;
|
$nixpacks_command = "nixpacks plan -f toml {$this->env_nixpacks_args}";
|
||||||
// if ($this->pull_request_id !== 0) {
|
|
||||||
// $cacheKey = "{$this->application->uuid}-pr-{$this->pull_request_id}";
|
|
||||||
// }
|
|
||||||
$nixpacks_command = "nixpacks build {$this->env_args} --no-error-without-start";
|
|
||||||
if ($this->application->build_command) {
|
if ($this->application->build_command) {
|
||||||
$nixpacks_command .= " --build-cmd \"{$this->application->build_command}\"";
|
$nixpacks_command .= " --build-cmd \"{$this->application->build_command}\"";
|
||||||
}
|
}
|
||||||
@@ -893,24 +921,37 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
if ($this->application->install_command) {
|
if ($this->application->install_command) {
|
||||||
$nixpacks_command .= " --install-cmd \"{$this->application->install_command}\"";
|
$nixpacks_command .= " --install-cmd \"{$this->application->install_command}\"";
|
||||||
}
|
}
|
||||||
$nixpacks_command .= " -o {$this->workdir} {$this->workdir}";
|
$nixpacks_command .= " {$this->workdir}";
|
||||||
return $nixpacks_command;
|
return $nixpacks_command;
|
||||||
}
|
}
|
||||||
|
private function generate_nixpacks_env_variables()
|
||||||
|
{
|
||||||
|
$this->env_nixpacks_args = collect([]);
|
||||||
|
if ($this->pull_request_id === 0) {
|
||||||
|
foreach ($this->application->nixpacks_environment_variables as $env) {
|
||||||
|
$this->env_nixpacks_args->push("--env {$env->key}={$env->value}");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
foreach ($this->application->nixpacks_environment_variables_preview as $env) {
|
||||||
|
$this->env_nixpacks_args->push("--env {$env->key}={$env->value}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->env_nixpacks_args = $this->env_nixpacks_args->implode(' ');
|
||||||
|
}
|
||||||
private function generate_env_variables()
|
private function generate_env_variables()
|
||||||
{
|
{
|
||||||
$this->env_args = collect([]);
|
$this->env_args = collect([]);
|
||||||
if ($this->pull_request_id === 0) {
|
if ($this->pull_request_id === 0) {
|
||||||
foreach ($this->application->nixpacks_environment_variables as $env) {
|
foreach ($this->application->build_environment_variables as $env) {
|
||||||
$this->env_args->push("--env {$env->key}={$env->value}");
|
$this->env_args->put($env->key, $env->value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach ($this->application->nixpacks_environment_variables_preview as $env) {
|
foreach ($this->application->build_environment_variables_preview as $env) {
|
||||||
$this->env_args->push("--env {$env->key}={$env->value}");
|
$this->env_args->put($env->key, $env->value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->env_args->put('SOURCE_COMMIT', $this->commit);
|
||||||
$this->env_args = $this->env_args->implode(' ');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generate_compose_file()
|
private function generate_compose_file()
|
||||||
@@ -963,7 +1004,6 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
'mem_swappiness' => $this->application->limits_memory_swappiness,
|
'mem_swappiness' => $this->application->limits_memory_swappiness,
|
||||||
'mem_reservation' => $this->application->limits_memory_reservation,
|
'mem_reservation' => $this->application->limits_memory_reservation,
|
||||||
'cpus' => (float) $this->application->limits_cpus,
|
'cpus' => (float) $this->application->limits_cpus,
|
||||||
'cpuset' => $this->application->limits_cpuset,
|
|
||||||
'cpu_shares' => $this->application->limits_cpu_shares,
|
'cpu_shares' => $this->application->limits_cpu_shares,
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@@ -975,6 +1015,9 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
if (!is_null($this->application->limits_cpuset)) {
|
||||||
|
data_set($docker_compose, 'services.' . $this->container_name . '.cpuset', $this->application->limits_cpuset);
|
||||||
|
}
|
||||||
if ($this->server->isSwarm()) {
|
if ($this->server->isSwarm()) {
|
||||||
data_forget($docker_compose, 'services.' . $this->container_name . '.container_name');
|
data_forget($docker_compose, 'services.' . $this->container_name . '.container_name');
|
||||||
data_forget($docker_compose, 'services.' . $this->container_name . '.expose');
|
data_forget($docker_compose, 'services.' . $this->container_name . '.expose');
|
||||||
@@ -1135,12 +1178,14 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add PORT if not exists, use the first port as default
|
// Add PORT if not exists, use the first port as default
|
||||||
if ($environment_variables->filter(fn ($env) => Str::of($env)->contains('PORT'))->isEmpty()) {
|
if ($environment_variables->filter(fn ($env) => Str::of($env)->startsWith('PORT'))->isEmpty()) {
|
||||||
$environment_variables->push("PORT={$ports[0]}");
|
$environment_variables->push("PORT={$ports[0]}");
|
||||||
}
|
}
|
||||||
if ($environment_variables->filter(fn ($env) => Str::of($env)->contains('SOURCE_COMMIT'))->isEmpty()) {
|
if ($environment_variables->filter(fn ($env) => Str::of($env)->startsWith('SOURCE_COMMIT'))->isEmpty()) {
|
||||||
if (!is_null($this->commit)) {
|
if (!is_null($this->commit)) {
|
||||||
$environment_variables->push("SOURCE_COMMIT={$this->commit}");
|
$environment_variables->push("SOURCE_COMMIT={$this->commit}");
|
||||||
|
} else {
|
||||||
|
$environment_variables->push("SOURCE_COMMIT=unknown");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $environment_variables->all();
|
return $environment_variables->all();
|
||||||
@@ -1175,9 +1220,8 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
}
|
}
|
||||||
private function pull_latest_image($image)
|
private function pull_latest_image($image)
|
||||||
{
|
{
|
||||||
|
$this->application_deployment_queue->addLogEntry("Pulling latest image ($image) from the registry.");
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
["echo -n 'Pulling latest image ($image) from the registry.'"],
|
|
||||||
|
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, "docker pull {$image}"), "hidden" => true
|
executeInDocker($this->deployment_uuid, "docker pull {$image}"), "hidden" => true
|
||||||
]
|
]
|
||||||
@@ -1185,25 +1229,18 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
}
|
}
|
||||||
private function build_image()
|
private function build_image()
|
||||||
{
|
{
|
||||||
|
$this->application_deployment_queue->addLogEntry("----------------------------------------");
|
||||||
if ($this->application->build_pack === 'static') {
|
if ($this->application->build_pack === 'static') {
|
||||||
$this->execute_remote_command([
|
$this->application_deployment_queue->addLogEntry("Static deployment. Copying static assets to the image.");
|
||||||
"echo -n 'Static deployment. Copying static assets to the image.'",
|
|
||||||
]);
|
|
||||||
} else {
|
} else {
|
||||||
$this->execute_remote_command(
|
$this->application_deployment_queue->addLogEntry("Building docker image started.");
|
||||||
[
|
$this->application_deployment_queue->addLogEntry("To check the current progress, click on Show Debug Logs.");
|
||||||
"echo -n 'Building docker image started.'",
|
|
||||||
],
|
|
||||||
["echo -n 'To check the current progress, click on Show Debug Logs.'"]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->application->settings->is_static || $this->application->build_pack === 'static') {
|
if ($this->application->settings->is_static || $this->application->build_pack === 'static') {
|
||||||
if ($this->application->static_image) {
|
if ($this->application->static_image) {
|
||||||
$this->pull_latest_image($this->application->static_image);
|
$this->pull_latest_image($this->application->static_image);
|
||||||
$this->execute_remote_command(
|
$this->application_deployment_queue->addLogEntry("Continuing with the building process.");
|
||||||
["echo -n 'Continue with the building process.'"],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if ($this->application->build_pack === 'static') {
|
if ($this->application->build_pack === 'static') {
|
||||||
$dockerfile = base64_encode("FROM {$this->application->static_image}
|
$dockerfile = base64_encode("FROM {$this->application->static_image}
|
||||||
@@ -1231,22 +1268,35 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
}");
|
}");
|
||||||
} else {
|
} else {
|
||||||
if ($this->application->build_pack === 'nixpacks') {
|
if ($this->application->build_pack === 'nixpacks') {
|
||||||
$this->execute_remote_command(
|
$this->nixpacks_plan = base64_encode($this->nixpacks_plan);
|
||||||
[
|
$this->execute_remote_command([executeInDocker($this->deployment_uuid, "echo '{$this->nixpacks_plan}' | base64 -d > /artifacts/thegameplan.json"), "hidden" => true]);
|
||||||
executeInDocker($this->deployment_uuid, "cp {$this->workdir}/Dockerfile {$this->workdir}/.nixpacks/Dockerfile")
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if ($this->force_rebuild) {
|
if ($this->force_rebuild) {
|
||||||
$this->execute_remote_command([
|
$this->execute_remote_command([
|
||||||
executeInDocker($this->deployment_uuid, "docker build --no-cache $this->buildTarget $this->addHosts --network host -f {$this->workdir}{$this->dockerfile_location} {$this->build_args} --progress plain -t $this->build_image_name {$this->workdir}"), "hidden" => true
|
executeInDocker($this->deployment_uuid, "nixpacks build -c /artifacts/thegameplan.json --no-cache --no-error-without-start -n {$this->build_image_name} {$this->workdir}"), "hidden" => true
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
$this->execute_remote_command([
|
$this->execute_remote_command([
|
||||||
executeInDocker($this->deployment_uuid, "docker build $this->buildTarget $this->addHosts --network host -f {$this->workdir}{$this->dockerfile_location} {$this->build_args} --progress plain -t $this->build_image_name {$this->workdir}"), "hidden" => true
|
executeInDocker($this->deployment_uuid, "nixpacks build -c /artifacts/thegameplan.json --cache-key '{$this->application->uuid}' --no-error-without-start -n {$this->build_image_name} {$this->workdir}"), "hidden" => true
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
// }
|
$this->execute_remote_command([executeInDocker($this->deployment_uuid, "rm /artifacts/thegameplan.json"), "hidden" => true]);
|
||||||
|
} else {
|
||||||
|
if ($this->force_rebuild) {
|
||||||
|
$build_command = "docker build --no-cache {$this->buildTarget} --network {$this->destination->network} -f {$this->workdir}{$this->dockerfile_location} {$this->build_args} --progress plain -t $this->build_image_name {$this->workdir}";
|
||||||
|
$base64_build_command = base64_encode($build_command);
|
||||||
|
} else {
|
||||||
|
$build_command = "docker build {$this->buildTarget} --network {$this->destination->network} -f {$this->workdir}{$this->dockerfile_location} {$this->build_args} --progress plain -t $this->build_image_name {$this->workdir}";
|
||||||
|
$base64_build_command = base64_encode($build_command);
|
||||||
|
}
|
||||||
|
$this->execute_remote_command(
|
||||||
|
[
|
||||||
|
executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d > /artifacts/build.sh"), "hidden" => true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
executeInDocker($this->deployment_uuid, "bash /artifacts/build.sh"), "hidden" => true
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$dockerfile = base64_encode("FROM {$this->application->static_image}
|
$dockerfile = base64_encode("FROM {$this->application->static_image}
|
||||||
WORKDIR /usr/share/nginx/html/
|
WORKDIR /usr/share/nginx/html/
|
||||||
@@ -1271,6 +1321,8 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
}
|
}
|
||||||
}");
|
}");
|
||||||
}
|
}
|
||||||
|
$build_command = "docker build {$this->addHosts} --network host -f {$this->workdir}/Dockerfile {$this->build_args} --progress plain -t {$this->production_image_name} {$this->workdir}";
|
||||||
|
$base64_build_command = base64_encode($build_command);
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, "echo '{$dockerfile}' | base64 -d > {$this->workdir}/Dockerfile")
|
executeInDocker($this->deployment_uuid, "echo '{$dockerfile}' | base64 -d > {$this->workdir}/Dockerfile")
|
||||||
@@ -1279,38 +1331,59 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
executeInDocker($this->deployment_uuid, "echo '{$nginx_config}' | base64 -d > {$this->workdir}/nginx.conf")
|
executeInDocker($this->deployment_uuid, "echo '{$nginx_config}' | base64 -d > {$this->workdir}/nginx.conf")
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, "docker build $this->addHosts --network host -f {$this->workdir}/Dockerfile {$this->build_args} --progress plain -t $this->production_image_name {$this->workdir}"), "hidden" => true
|
executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d > /artifacts/build.sh"), "hidden" => true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
executeInDocker($this->deployment_uuid, "bash /artifacts/build.sh"), "hidden" => true
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Pure Dockerfile based deployment
|
// Pure Dockerfile based deployment
|
||||||
if ($this->application->dockerfile) {
|
if ($this->application->dockerfile) {
|
||||||
$this->execute_remote_command([
|
$build_command = "docker build --pull {$this->buildTarget} {$this->addHosts} --network host -f {$this->workdir}{$this->dockerfile_location} {$this->build_args} --progress plain -t {$this->production_image_name} {$this->workdir}";
|
||||||
executeInDocker($this->deployment_uuid, "docker build --pull $this->buildTarget $this->addHosts --network host -f {$this->workdir}{$this->dockerfile_location} {$this->build_args} --progress plain -t $this->production_image_name {$this->workdir}"), "hidden" => true
|
$base64_build_command = base64_encode($build_command);
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
if ($this->application->build_pack === 'nixpacks') {
|
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, "cp {$this->workdir}/Dockerfile {$this->workdir}/.nixpacks/Dockerfile")
|
executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d > /artifacts/build.sh"), "hidden" => true
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
executeInDocker($this->deployment_uuid, "bash /artifacts/build.sh"), "hidden" => true
|
||||||
|
]
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
|
if ($this->application->build_pack === 'nixpacks') {
|
||||||
|
$this->nixpacks_plan = base64_encode($this->nixpacks_plan);
|
||||||
|
$this->execute_remote_command([executeInDocker($this->deployment_uuid, "echo '{$this->nixpacks_plan}' | base64 -d > /artifacts/thegameplan.json"), "hidden" => true]);
|
||||||
if ($this->force_rebuild) {
|
if ($this->force_rebuild) {
|
||||||
$this->execute_remote_command([
|
$this->execute_remote_command([
|
||||||
executeInDocker($this->deployment_uuid, "docker build --no-cache $this->buildTarget $this->addHosts --network host -f {$this->workdir}{$this->dockerfile_location} {$this->build_args} --progress plain -t $this->production_image_name {$this->workdir}"), "hidden" => true
|
executeInDocker($this->deployment_uuid, "nixpacks build -c /artifacts/thegameplan.json --no-cache --no-error-without-start -n {$this->production_image_name} {$this->workdir}"), "hidden" => true
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
$this->execute_remote_command([
|
$this->execute_remote_command([
|
||||||
executeInDocker($this->deployment_uuid, "docker build $this->buildTarget $this->addHosts --network host -f {$this->workdir}{$this->dockerfile_location} {$this->build_args} --progress plain -t $this->production_image_name {$this->workdir}"), "hidden" => true
|
executeInDocker($this->deployment_uuid, "nixpacks build -c /artifacts/thegameplan.json --cache-key '{$this->application->uuid}' --no-error-without-start -n {$this->production_image_name} {$this->workdir}"), "hidden" => true
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
$this->execute_remote_command([executeInDocker($this->deployment_uuid, "rm /artifacts/thegameplan.json"), "hidden" => true]);
|
||||||
|
} else {
|
||||||
|
if ($this->force_rebuild) {
|
||||||
|
$build_command = "docker build --no-cache {$this->buildTarget} {$this->addHosts} --network host -f {$this->workdir}{$this->dockerfile_location} {$this->build_args} --progress plain -t {$this->production_image_name} {$this->workdir}";
|
||||||
|
$base64_build_command = base64_encode($build_command);
|
||||||
|
} else {
|
||||||
|
$build_command = "docker build {$this->buildTarget} {$this->addHosts} --network host -f {$this->workdir}{$this->dockerfile_location} {$this->build_args} --progress plain -t {$this->production_image_name} {$this->workdir}";
|
||||||
|
$base64_build_command = base64_encode($build_command);
|
||||||
|
}
|
||||||
|
$this->execute_remote_command(
|
||||||
|
[
|
||||||
|
executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d > /artifacts/build.sh"), "hidden" => true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
executeInDocker($this->deployment_uuid, "bash /artifacts/build.sh"), "hidden" => true
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->execute_remote_command([
|
}
|
||||||
"echo -n 'Building docker image completed.'",
|
$this->application_deployment_queue->addLogEntry("Building docker image completed.");
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function stop_running_container(bool $force = false)
|
private function stop_running_container(bool $force = false)
|
||||||
@@ -1347,11 +1420,11 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
$this->application_deployment_queue->addLogEntry("Pulling latest images from the registry.");
|
$this->application_deployment_queue->addLogEntry("Pulling latest images from the registry.");
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} pull"), "hidden" => true],
|
[executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} pull"), "hidden" => true],
|
||||||
[executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} build"), "hidden" => true],
|
[executeInDocker($this->deployment_uuid, "SOURCE_COMMIT={$this->commit} docker compose --project-directory {$this->workdir} build"), "hidden" => true],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} -f {$this->workdir}{$this->docker_compose_location} build"), "hidden" => true],
|
[executeInDocker($this->deployment_uuid, "SOURCE_COMMIT={$this->commit} docker compose --project-directory {$this->workdir} -f {$this->workdir}{$this->docker_compose_location} build"), "hidden" => true],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$this->application_deployment_queue->addLogEntry("New images built.");
|
$this->application_deployment_queue->addLogEntry("New images built.");
|
||||||
@@ -1363,16 +1436,16 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
$this->application_deployment_queue->addLogEntry("Pulling latest images from the registry.");
|
$this->application_deployment_queue->addLogEntry("Pulling latest images from the registry.");
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} pull"), "hidden" => true],
|
[executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} pull"), "hidden" => true],
|
||||||
[executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} up --build -d"), "hidden" => true],
|
[executeInDocker($this->deployment_uuid, "SOURCE_COMMIT={$this->commit} docker compose --project-directory {$this->workdir} up --build -d"), "hidden" => true],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if ($this->docker_compose_location) {
|
if ($this->use_build_server) {
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} -f {$this->workdir}{$this->docker_compose_location} up --build -d"), "hidden" => true],
|
["SOURCE_COMMIT={$this->commit} docker compose --project-directory {$this->configuration_dir} -f {$this->configuration_dir}{$this->docker_compose_location} up --build -d", "hidden" => true],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} up --build -d"), "hidden" => true],
|
[executeInDocker($this->deployment_uuid, "SOURCE_COMMIT={$this->commit} docker compose --project-directory {$this->workdir} -f {$this->workdir}{$this->docker_compose_location} up --build -d"), "hidden" => true],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1384,11 +1457,13 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
$this->build_args = collect(["--build-arg SOURCE_COMMIT=\"{$this->commit}\""]);
|
$this->build_args = collect(["--build-arg SOURCE_COMMIT=\"{$this->commit}\""]);
|
||||||
if ($this->pull_request_id === 0) {
|
if ($this->pull_request_id === 0) {
|
||||||
foreach ($this->application->build_environment_variables as $env) {
|
foreach ($this->application->build_environment_variables as $env) {
|
||||||
$this->build_args->push("--build-arg {$env->key}=\"{$env->value}\"");
|
$value = escapeshellarg($env->value);
|
||||||
|
$this->build_args->push("--build-arg {$env->key}={$value}");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach ($this->application->build_environment_variables_preview as $env) {
|
foreach ($this->application->build_environment_variables_preview as $env) {
|
||||||
$this->build_args->push("--build-arg {$env->key}=\"{$env->value}\"");
|
$value = escapeshellarg($env->value);
|
||||||
|
$this->build_args->push("--build-arg {$env->key}={$value}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1436,13 +1511,12 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
|
|
||||||
public function failed(Throwable $exception): void
|
public function failed(Throwable $exception): void
|
||||||
{
|
{
|
||||||
$this->execute_remote_command(
|
$this->application_deployment_queue->addLogEntry("Oops something is not okay, are you okay? 😢", 'stderr');
|
||||||
["echo 'Oops something is not okay, are you okay? 😢'", 'type' => 'err'],
|
$this->application_deployment_queue->addLogEntry($exception->getMessage(), 'stderr');
|
||||||
["echo '{$exception->getMessage()}'", 'type' => 'err'],
|
|
||||||
);
|
|
||||||
if ($this->application->build_pack !== 'dockercompose') {
|
if ($this->application->build_pack !== 'dockercompose') {
|
||||||
|
$this->application_deployment_queue->addLogEntry("Deployment failed. Removing the new version of your application.", 'stderr');
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
["echo -n 'Deployment failed. Removing the new version of your application.'", 'type' => 'err'],
|
|
||||||
[executeInDocker($this->deployment_uuid, "docker rm -f $this->container_name >/dev/null 2>&1"), "hidden" => true, "ignore_errors" => true]
|
[executeInDocker($this->deployment_uuid, "docker rm -f $this->container_name >/dev/null 2>&1"), "hidden" => true, "ignore_errors" => true]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
|
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
if (!$this->server->isServerReady($this->tries)) {
|
if (!$this->server->isFunctional()) {
|
||||||
return 'Server is not reachable.';
|
return 'Server is not ready.';
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
if ($this->server->isSwarm()) {
|
if ($this->server->isSwarm()) {
|
||||||
@@ -162,6 +162,10 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
// Notify user that this container should not be there.
|
// Notify user that this container should not be there.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (data_get($container,'Name') === '/coolify-db') {
|
||||||
|
$foundDatabases[] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$serviceLabelId = data_get($labels, 'coolify.serviceId');
|
$serviceLabelId = data_get($labels, 'coolify.serviceId');
|
||||||
if ($serviceLabelId) {
|
if ($serviceLabelId) {
|
||||||
@@ -212,7 +216,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
}
|
}
|
||||||
$name = data_get($exitedService, 'name');
|
$name = data_get($exitedService, 'name');
|
||||||
$fqdn = data_get($exitedService, 'fqdn');
|
$fqdn = data_get($exitedService, 'fqdn');
|
||||||
$containerName = $name ? "$name ($fqdn)" : $fqdn;
|
$containerName = $name ? "$name, available at $fqdn" : $fqdn;
|
||||||
$projectUuid = data_get($service, 'environment.project.uuid');
|
$projectUuid = data_get($service, 'environment.project.uuid');
|
||||||
$serviceUuid = data_get($service, 'uuid');
|
$serviceUuid = data_get($service, 'uuid');
|
||||||
$environmentName = data_get($service, 'environment.name');
|
$environmentName = data_get($service, 'environment.name');
|
||||||
|
|||||||
@@ -31,11 +31,16 @@ class DeleteResourceJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$server = $this->resource->destination->server;
|
$server = $this->resource->destination->server;
|
||||||
|
$this->resource->delete();
|
||||||
if (!$server->isFunctional()) {
|
if (!$server->isFunctional()) {
|
||||||
|
if ($this->resource->type() === 'service') {
|
||||||
|
ray('dispatching delete service');
|
||||||
|
DeleteService::dispatch($this->resource);
|
||||||
|
} else {
|
||||||
$this->resource->forceDelete();
|
$this->resource->forceDelete();
|
||||||
|
}
|
||||||
return 'Server is not functional';
|
return 'Server is not functional';
|
||||||
}
|
}
|
||||||
$this->resource->delete();
|
|
||||||
switch ($this->resource->type()) {
|
switch ($this->resource->type()) {
|
||||||
case 'application':
|
case 'application':
|
||||||
StopApplication::run($this->resource);
|
StopApplication::run($this->resource);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Jobs;
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Actions\Server\CleanupDocker;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
|
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
|
||||||
@@ -43,9 +44,7 @@ class DockerCleanupJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
ray('Usage before: ' . $this->usageBefore);
|
ray('Usage before: ' . $this->usageBefore);
|
||||||
if ($this->usageBefore >= $this->server->settings->cleanup_after_percentage) {
|
if ($this->usageBefore >= $this->server->settings->cleanup_after_percentage) {
|
||||||
ray('Cleaning up ' . $this->server->name);
|
ray('Cleaning up ' . $this->server->name);
|
||||||
instant_remote_process(['docker image prune -af'], $this->server, false);
|
CleanupDocker::run($this->server);
|
||||||
instant_remote_process(['docker container prune -f --filter "label=coolify.managed=true"'], $this->server, false);
|
|
||||||
instant_remote_process(['docker builder prune -af'], $this->server, false);
|
|
||||||
$usageAfter = $this->server->getDiskUsage();
|
$usageAfter = $this->server->getDiskUsage();
|
||||||
if ($usageAfter < $this->usageBefore) {
|
if ($usageAfter < $this->usageBefore) {
|
||||||
ray('Saved ' . ($this->usageBefore - $usageAfter) . '% disk space on ' . $this->server->name);
|
ray('Saved ' . ($this->usageBefore - $usageAfter) . '% disk space on ' . $this->server->name);
|
||||||
|
|||||||
115
app/Jobs/ScheduledTaskJob.php
Normal file
115
app/Jobs/ScheduledTaskJob.php
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Models\ScheduledTask;
|
||||||
|
use App\Models\ScheduledTaskExecution;
|
||||||
|
use App\Models\Server;
|
||||||
|
use App\Models\Application;
|
||||||
|
use App\Models\Service;
|
||||||
|
use App\Models\Team;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
class ScheduledTaskJob implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public ?Team $team = null;
|
||||||
|
public Server $server;
|
||||||
|
public ScheduledTask $task;
|
||||||
|
public Application|Service $resource;
|
||||||
|
|
||||||
|
public ?ScheduledTaskExecution $task_log = null;
|
||||||
|
public string $task_status = 'failed';
|
||||||
|
public ?string $task_output = null;
|
||||||
|
public array $containers = [];
|
||||||
|
|
||||||
|
public function __construct($task)
|
||||||
|
{
|
||||||
|
$this->task = $task;
|
||||||
|
if ($service = $task->service()->first()) {
|
||||||
|
$this->resource = $service;
|
||||||
|
} else if ($application = $task->application()->first()) {
|
||||||
|
$this->resource = $application;
|
||||||
|
}
|
||||||
|
$this->team = Team::find($task->team_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function middleware(): array
|
||||||
|
{
|
||||||
|
return [new WithoutOverlapping($this->task->id)];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function uniqueId(): int
|
||||||
|
{
|
||||||
|
return $this->task->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->task_log = ScheduledTaskExecution::create([
|
||||||
|
'scheduled_task_id' => $this->task->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->server = $this->resource->destination->server;
|
||||||
|
|
||||||
|
if ($this->resource->type() == 'application') {
|
||||||
|
$containers = getCurrentApplicationContainerStatus($this->server, $this->resource->id, 0);
|
||||||
|
if ($containers->count() > 0) {
|
||||||
|
$containers->each(function ($container) {
|
||||||
|
$this->containers[] = str_replace('/', '', $container['Names']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif ($this->resource->type() == 'service') {
|
||||||
|
$this->resource->applications()->get()->each(function ($application) {
|
||||||
|
if (str(data_get($application, 'status'))->contains('running')) {
|
||||||
|
$this->containers[] = data_get($application, 'name') . '-' . data_get($this->resource, 'uuid');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($this->containers) == 0) {
|
||||||
|
throw new \Exception('ScheduledTaskJob failed: No containers running.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($this->containers) > 1 && empty($this->task->container)) {
|
||||||
|
throw new \Exception('ScheduledTaskJob failed: More than one container exists but no container name was provided.');
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->containers as $containerName) {
|
||||||
|
if (count($this->containers) == 1 || str_starts_with($containerName, $this->task->container . '-' . $this->resource->uuid)) {
|
||||||
|
$cmd = 'sh -c "' . str_replace('"', '\"', $this->task->command) . '"';
|
||||||
|
$exec = "docker exec {$containerName} {$cmd}";
|
||||||
|
$this->task_output = instant_remote_process([$exec], $this->server, true);
|
||||||
|
$this->task_log->update([
|
||||||
|
'status' => 'success',
|
||||||
|
'message' => $this->task_output,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// No valid container was found.
|
||||||
|
throw new \Exception('ScheduledTaskJob failed: No valid container was found. Is the container name correct?');
|
||||||
|
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
if ($this->task_log) {
|
||||||
|
$this->task_log->update([
|
||||||
|
'status' => 'failed',
|
||||||
|
'message' => $this->task_output ?? $e->getMessage(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
// send_internal_notification('ScheduledTaskJob failed with: ' . $e->getMessage());
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,6 +37,9 @@ class ServerStatusJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
|
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
if (!$this->server->isServerReady($this->tries)) {
|
||||||
|
throw new \RuntimeException('Server is not ready.');
|
||||||
|
};
|
||||||
try {
|
try {
|
||||||
if ($this->server->isFunctional()) {
|
if ($this->server->isFunctional()) {
|
||||||
$this->cleanup(notify: false);
|
$this->cleanup(notify: false);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Livewire;
|
namespace App\Livewire;
|
||||||
|
|
||||||
use App\Enums\ProcessStatus;
|
use App\Enums\ProcessStatus;
|
||||||
|
use App\Models\User;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use Spatie\Activitylog\Models\Activity;
|
use Spatie\Activitylog\Models\Activity;
|
||||||
|
|
||||||
@@ -10,14 +11,16 @@ class ActivityMonitor extends Component
|
|||||||
{
|
{
|
||||||
public ?string $header = null;
|
public ?string $header = null;
|
||||||
public $activityId;
|
public $activityId;
|
||||||
|
public $eventToDispatch = 'activityFinished';
|
||||||
public $isPollingActive = false;
|
public $isPollingActive = false;
|
||||||
|
|
||||||
protected $activity;
|
protected $activity;
|
||||||
protected $listeners = ['newMonitorActivity'];
|
protected $listeners = ['newMonitorActivity'];
|
||||||
|
|
||||||
public function newMonitorActivity($activityId)
|
public function newMonitorActivity($activityId, $eventToDispatch = 'activityFinished')
|
||||||
{
|
{
|
||||||
$this->activityId = $activityId;
|
$this->activityId = $activityId;
|
||||||
|
$this->eventToDispatch = $eventToDispatch;
|
||||||
|
|
||||||
$this->hydrateActivity();
|
$this->hydrateActivity();
|
||||||
|
|
||||||
@@ -35,13 +38,28 @@ class ActivityMonitor extends Component
|
|||||||
// $this->setStatus(ProcessStatus::IN_PROGRESS);
|
// $this->setStatus(ProcessStatus::IN_PROGRESS);
|
||||||
$exit_code = data_get($this->activity, 'properties.exitCode');
|
$exit_code = data_get($this->activity, 'properties.exitCode');
|
||||||
if ($exit_code !== null) {
|
if ($exit_code !== null) {
|
||||||
if ($exit_code === 0) {
|
// if ($exit_code === 0) {
|
||||||
// $this->setStatus(ProcessStatus::FINISHED);
|
// // $this->setStatus(ProcessStatus::FINISHED);
|
||||||
} else {
|
// } else {
|
||||||
// $this->setStatus(ProcessStatus::ERROR);
|
// // $this->setStatus(ProcessStatus::ERROR);
|
||||||
}
|
// }
|
||||||
$this->isPollingActive = false;
|
$this->isPollingActive = false;
|
||||||
$this->dispatch('activityFinished');
|
if ($exit_code === 0) {
|
||||||
|
if ($this->eventToDispatch !== null) {
|
||||||
|
if (str($this->eventToDispatch)->startsWith('App\\Events\\')) {
|
||||||
|
$causer_id = data_get($this->activity, 'causer_id');
|
||||||
|
$user = User::find($causer_id);
|
||||||
|
if ($user) {
|
||||||
|
foreach($user->teams as $team) {
|
||||||
|
$teamId = $team->id;
|
||||||
|
$this->eventToDispatch::dispatch($teamId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->dispatch($this->eventToDispatch);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
|
|||||||
{
|
{
|
||||||
$this->skipBoarding();
|
$this->skipBoarding();
|
||||||
return redirect()->route(
|
return redirect()->route(
|
||||||
'project.resources.new',
|
'project.resource.create',
|
||||||
[
|
[
|
||||||
'project_uuid' => $this->createdProject->uuid,
|
'project_uuid' => $this->createdProject->uuid,
|
||||||
'environment_name' => 'production',
|
'environment_name' => 'production',
|
||||||
|
|||||||
18
app/Livewire/CommandCenter/Index.php
Normal file
18
app/Livewire/CommandCenter/Index.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\CommandCenter;
|
||||||
|
|
||||||
|
use App\Models\Server;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Index extends Component
|
||||||
|
{
|
||||||
|
public $servers = [];
|
||||||
|
public function mount() {
|
||||||
|
$this->servers = Server::isReachable()->get();
|
||||||
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.command-center.index');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,6 +22,10 @@ class ForcePasswordReset extends Component
|
|||||||
{
|
{
|
||||||
$this->email = auth()->user()->email;
|
$this->email = auth()->user()->email;
|
||||||
}
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.force-password-reset')->layout('layouts.simple');
|
||||||
|
}
|
||||||
public function submit()
|
public function submit()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -5,21 +5,19 @@ namespace App\Livewire\Profile;
|
|||||||
use Livewire\Attributes\Validate;
|
use Livewire\Attributes\Validate;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class Form extends Component
|
class Index extends Component
|
||||||
{
|
{
|
||||||
public int $userId;
|
public int $userId;
|
||||||
public string $email;
|
public string $email;
|
||||||
|
|
||||||
#[Validate('required')]
|
#[Validate('required')]
|
||||||
public string $name;
|
public string $name;
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
$this->userId = auth()->user()->id;
|
$this->userId = auth()->user()->id;
|
||||||
$this->name = auth()->user()->name;
|
$this->name = auth()->user()->name;
|
||||||
$this->email = auth()->user()->email;
|
$this->email = auth()->user()->email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function submit()
|
public function submit()
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -34,4 +32,8 @@ class Form extends Component
|
|||||||
return handleError($e, $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.profile.index');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ class AddEnvironment extends Component
|
|||||||
'project_id' => $this->project->id,
|
'project_id' => $this->project->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return redirect()->route('project.resources', [
|
return redirect()->route('project.resource.index', [
|
||||||
'project_uuid' => $this->project->uuid,
|
'project_uuid' => $this->project->uuid,
|
||||||
'environment_name' => $environment->name,
|
'environment_name' => $environment->name,
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class Advanced extends Component
|
|||||||
'application.settings.is_force_https_enabled' => 'boolean|required',
|
'application.settings.is_force_https_enabled' => 'boolean|required',
|
||||||
'application.settings.is_log_drain_enabled' => 'boolean|required',
|
'application.settings.is_log_drain_enabled' => 'boolean|required',
|
||||||
'application.settings.is_gpu_enabled' => 'boolean|required',
|
'application.settings.is_gpu_enabled' => 'boolean|required',
|
||||||
|
'application.settings.is_build_server_enabled' => 'boolean|required',
|
||||||
'application.settings.gpu_driver' => 'string|required',
|
'application.settings.gpu_driver' => 'string|required',
|
||||||
'application.settings.gpu_count' => 'string|required',
|
'application.settings.gpu_count' => 'string|required',
|
||||||
'application.settings.gpu_device_ids' => 'string|required',
|
'application.settings.gpu_device_ids' => 'string|required',
|
||||||
|
|||||||
@@ -4,13 +4,14 @@ namespace App\Livewire\Project\Application;
|
|||||||
|
|
||||||
use App\Models\Application;
|
use App\Models\Application;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\StandaloneDocker;
|
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class Configuration extends Component
|
class Configuration extends Component
|
||||||
{
|
{
|
||||||
public Application $application;
|
public Application $application;
|
||||||
public $servers;
|
public $servers;
|
||||||
|
protected $listeners = ['build_pack_updated' => '$refresh'];
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Livewire\Project\Application;
|
namespace App\Livewire\Project\Application\Deployment;
|
||||||
|
|
||||||
use App\Models\Application;
|
use App\Models\Application;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class Deployments extends Component
|
class Index extends Component
|
||||||
{
|
{
|
||||||
public Application $application;
|
public Application $application;
|
||||||
public Array|Collection $deployments = [];
|
public array|Collection $deployments = [];
|
||||||
public int $deployments_count = 0;
|
public int $deployments_count = 0;
|
||||||
public string $current_url;
|
public string $current_url;
|
||||||
public int $skip = 0;
|
public int $skip = 0;
|
||||||
@@ -19,11 +19,28 @@ class Deployments extends Component
|
|||||||
protected $queryString = ['pull_request_id'];
|
protected $queryString = ['pull_request_id'];
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
|
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
||||||
|
if (!$project) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
|
||||||
|
if (!$environment) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
$application = $environment->applications->where('uuid', request()->route('application_uuid'))->first();
|
||||||
|
if (!$application) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
['deployments' => $deployments, 'count' => $count] = $application->deployments(0, 40);
|
||||||
|
$this->application = $application;
|
||||||
|
$this->deployments = $deployments;
|
||||||
|
$this->deployments_count = $count;
|
||||||
$this->current_url = url()->current();
|
$this->current_url = url()->current();
|
||||||
$this->show_pull_request_only();
|
$this->show_pull_request_only();
|
||||||
$this->show_more();
|
$this->show_more();
|
||||||
}
|
}
|
||||||
private function show_pull_request_only() {
|
private function show_pull_request_only()
|
||||||
|
{
|
||||||
if ($this->pull_request_id) {
|
if ($this->pull_request_id) {
|
||||||
$this->deployments = $this->deployments->where('pull_request_id', $this->pull_request_id);
|
$this->deployments = $this->deployments->where('pull_request_id', $this->pull_request_id);
|
||||||
}
|
}
|
||||||
@@ -57,4 +74,8 @@ class Deployments extends Component
|
|||||||
$this->show_pull_request_only();
|
$this->show_pull_request_only();
|
||||||
$this->show_more();
|
$this->show_more();
|
||||||
}
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.project.application.deployment.index');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,35 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Livewire\Project\Application\Deployment;
|
||||||
|
|
||||||
|
use App\Models\Application;
|
||||||
use App\Models\ApplicationDeploymentQueue;
|
use App\Models\ApplicationDeploymentQueue;
|
||||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
use Livewire\Component;
|
||||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
|
||||||
|
|
||||||
class ApplicationController extends Controller
|
class Show extends Component
|
||||||
{
|
{
|
||||||
use AuthorizesRequests, ValidatesRequests;
|
public Application $application;
|
||||||
|
public ApplicationDeploymentQueue $application_deployment_queue;
|
||||||
|
public string $deployment_uuid;
|
||||||
|
public $isKeepAliveOn = true;
|
||||||
|
protected $listeners = ['refreshQueue'];
|
||||||
|
|
||||||
public function deployments()
|
public function mount() {
|
||||||
{
|
|
||||||
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
|
||||||
if (!$project) {
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
|
|
||||||
if (!$environment) {
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
$application = $environment->applications->where('uuid', request()->route('application_uuid'))->first();
|
|
||||||
if (!$application) {
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
['deployments' => $deployments, 'count' => $count] = $application->deployments(0, 40);
|
|
||||||
return view('project.application.deployments', ['application' => $application, 'deployments' => $deployments, 'deployments_count' => $count]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deployment()
|
|
||||||
{
|
|
||||||
$deploymentUuid = request()->route('deployment_uuid');
|
$deploymentUuid = request()->route('deployment_uuid');
|
||||||
|
|
||||||
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
||||||
@@ -46,7 +31,7 @@ class ApplicationController extends Controller
|
|||||||
}
|
}
|
||||||
// $activity = Activity::where('properties->type_uuid', '=', $deploymentUuid)->first();
|
// $activity = Activity::where('properties->type_uuid', '=', $deploymentUuid)->first();
|
||||||
// if (!$activity) {
|
// if (!$activity) {
|
||||||
// return redirect()->route('project.application.deployments', [
|
// return redirect()->route('project.application.deployment.index', [
|
||||||
// 'project_uuid' => $project->uuid,
|
// 'project_uuid' => $project->uuid,
|
||||||
// 'environment_name' => $environment->name,
|
// 'environment_name' => $environment->name,
|
||||||
// 'application_uuid' => $application->uuid,
|
// 'application_uuid' => $application->uuid,
|
||||||
@@ -54,17 +39,32 @@ class ApplicationController extends Controller
|
|||||||
// }
|
// }
|
||||||
$application_deployment_queue = ApplicationDeploymentQueue::where('deployment_uuid', $deploymentUuid)->first();
|
$application_deployment_queue = ApplicationDeploymentQueue::where('deployment_uuid', $deploymentUuid)->first();
|
||||||
if (!$application_deployment_queue) {
|
if (!$application_deployment_queue) {
|
||||||
return redirect()->route('project.application.deployments', [
|
return redirect()->route('project.application.deployment.index', [
|
||||||
'project_uuid' => $project->uuid,
|
'project_uuid' => $project->uuid,
|
||||||
'environment_name' => $environment->name,
|
'environment_name' => $environment->name,
|
||||||
'application_uuid' => $application->uuid,
|
'application_uuid' => $application->uuid,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
return view('project.application.deployment', [
|
$this->application = $application;
|
||||||
'application' => $application,
|
$this->application_deployment_queue = $application_deployment_queue;
|
||||||
// 'activity' => $activity,
|
$this->deployment_uuid = $deploymentUuid;
|
||||||
'application_deployment_queue' => $application_deployment_queue,
|
}
|
||||||
'deployment_uuid' => $deploymentUuid,
|
|
||||||
]);
|
public function refreshQueue()
|
||||||
|
{
|
||||||
|
$this->application_deployment_queue->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function polling()
|
||||||
|
{
|
||||||
|
$this->dispatch('deploymentFinished');
|
||||||
|
$this->application_deployment_queue->refresh();
|
||||||
|
if (data_get($this->application_deployment_queue, 'status') == 'finished' || data_get($this->application_deployment_queue, 'status') == 'failed') {
|
||||||
|
$this->isKeepAliveOn = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.project.application.deployment.show');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Livewire\Project\Application;
|
|
||||||
|
|
||||||
use App\Models\ApplicationDeploymentQueue;
|
|
||||||
use Livewire\Component;
|
|
||||||
|
|
||||||
class DeploymentLogs extends Component
|
|
||||||
{
|
|
||||||
public ApplicationDeploymentQueue $application_deployment_queue;
|
|
||||||
public $isKeepAliveOn = true;
|
|
||||||
protected $listeners = ['refreshQueue'];
|
|
||||||
|
|
||||||
public function refreshQueue()
|
|
||||||
{
|
|
||||||
$this->application_deployment_queue->refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function polling()
|
|
||||||
{
|
|
||||||
$this->dispatch('deploymentFinished');
|
|
||||||
$this->application_deployment_queue->refresh();
|
|
||||||
if (data_get($this->application_deployment_queue, 'status') == 'finished' || data_get($this->application_deployment_queue, 'status') == 'failed') {
|
|
||||||
$this->isKeepAliveOn = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -67,6 +67,7 @@ class General extends Component
|
|||||||
'application.docker_compose_custom_start_command' => 'nullable',
|
'application.docker_compose_custom_start_command' => 'nullable',
|
||||||
'application.docker_compose_custom_build_command' => 'nullable',
|
'application.docker_compose_custom_build_command' => 'nullable',
|
||||||
'application.settings.is_raw_compose_deployment_enabled' => 'boolean|required',
|
'application.settings.is_raw_compose_deployment_enabled' => 'boolean|required',
|
||||||
|
'application.settings.is_build_server_enabled' => 'boolean|required',
|
||||||
];
|
];
|
||||||
protected $validationAttributes = [
|
protected $validationAttributes = [
|
||||||
'application.name' => 'name',
|
'application.name' => 'name',
|
||||||
@@ -100,6 +101,7 @@ class General extends Component
|
|||||||
'application.docker_compose_custom_start_command' => 'Docker compose custom start command',
|
'application.docker_compose_custom_start_command' => 'Docker compose custom start command',
|
||||||
'application.docker_compose_custom_build_command' => 'Docker compose custom build command',
|
'application.docker_compose_custom_build_command' => 'Docker compose custom build command',
|
||||||
'application.settings.is_raw_compose_deployment_enabled' => 'Is raw compose deployment enabled',
|
'application.settings.is_raw_compose_deployment_enabled' => 'Is raw compose deployment enabled',
|
||||||
|
'application.settings.is_build_server_enabled' => 'Is build server enabled',
|
||||||
];
|
];
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
@@ -117,7 +119,7 @@ class General extends Component
|
|||||||
$this->isConfigurationChanged = $this->application->isConfigurationChanged();
|
$this->isConfigurationChanged = $this->application->isConfigurationChanged();
|
||||||
$this->customLabels = $this->application->parseContainerLabels();
|
$this->customLabels = $this->application->parseContainerLabels();
|
||||||
if (!$this->customLabels && $this->application->destination->server->proxyType() === 'TRAEFIK_V2') {
|
if (!$this->customLabels && $this->application->destination->server->proxyType() === 'TRAEFIK_V2') {
|
||||||
$this->customLabels = str(implode(",", generateLabelsApplication($this->application)))->replace(',', "\n");
|
$this->customLabels = str(implode("|", generateLabelsApplication($this->application)))->replace("|", "\n");
|
||||||
$this->application->custom_labels = base64_encode($this->customLabels);
|
$this->application->custom_labels = base64_encode($this->customLabels);
|
||||||
$this->application->save();
|
$this->application->save();
|
||||||
}
|
}
|
||||||
@@ -165,16 +167,24 @@ class General extends Component
|
|||||||
if ($this->application->build_pack !== 'nixpacks') {
|
if ($this->application->build_pack !== 'nixpacks') {
|
||||||
$this->application->settings->is_static = false;
|
$this->application->settings->is_static = false;
|
||||||
$this->application->settings->save();
|
$this->application->settings->save();
|
||||||
|
} else {
|
||||||
|
$this->application->ports_exposes = $this->ports_exposes = 3000;
|
||||||
|
$this->resetDefaultLabels(false);
|
||||||
}
|
}
|
||||||
if ($this->application->build_pack === 'dockercompose') {
|
if ($this->application->build_pack === 'dockercompose') {
|
||||||
$this->application->fqdn = null;
|
$this->application->fqdn = null;
|
||||||
$this->application->settings->save();
|
$this->application->settings->save();
|
||||||
}
|
}
|
||||||
|
if ($this->application->build_pack === 'static') {
|
||||||
|
$this->application->ports_exposes = $this->ports_exposes = 80;
|
||||||
|
$this->resetDefaultLabels(false);
|
||||||
|
}
|
||||||
$this->submit();
|
$this->submit();
|
||||||
|
$this->dispatch('build_pack_updated');
|
||||||
}
|
}
|
||||||
public function checkLabelUpdates()
|
public function checkLabelUpdates()
|
||||||
{
|
{
|
||||||
if (md5($this->application->custom_labels) !== md5(implode(",", generateLabelsApplication($this->application)))) {
|
if (md5($this->application->custom_labels) !== md5(implode("|", generateLabelsApplication($this->application)))) {
|
||||||
$this->labelsChanged = true;
|
$this->labelsChanged = true;
|
||||||
} else {
|
} else {
|
||||||
$this->labelsChanged = false;
|
$this->labelsChanged = false;
|
||||||
@@ -193,7 +203,7 @@ class General extends Component
|
|||||||
}
|
}
|
||||||
public function resetDefaultLabels($showToaster = true)
|
public function resetDefaultLabels($showToaster = true)
|
||||||
{
|
{
|
||||||
$this->customLabels = str(implode(",", generateLabelsApplication($this->application)))->replace(',', "\n");
|
$this->customLabels = str(implode("|", generateLabelsApplication($this->application)))->replace("|", "\n");
|
||||||
$this->ports_exposes = $this->application->ports_exposes;
|
$this->ports_exposes = $this->application->ports_exposes;
|
||||||
$this->submit($showToaster);
|
$this->submit($showToaster);
|
||||||
}
|
}
|
||||||
@@ -201,13 +211,13 @@ class General extends Component
|
|||||||
public function updatedApplicationFqdn()
|
public function updatedApplicationFqdn()
|
||||||
{
|
{
|
||||||
$this->resetDefaultLabels(false);
|
$this->resetDefaultLabels(false);
|
||||||
$this->dispatch('success', 'Labels reseted to default!');
|
// $this->dispatch('success', 'Labels reset to default!');
|
||||||
}
|
}
|
||||||
public function submit($showToaster = true)
|
public function submit($showToaster = true)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (!$this->customLabels && $this->application->destination->server->proxyType() === 'TRAEFIK_V2') {
|
if (!$this->customLabels && $this->application->destination->server->proxyType() === 'TRAEFIK_V2') {
|
||||||
$this->customLabels = str(implode(",", generateLabelsApplication($this->application)))->replace(',', "\n");
|
$this->customLabels = str(implode("|", generateLabelsApplication($this->application)))->replace("|", "\n");
|
||||||
$this->application->custom_labels = base64_encode($this->customLabels);
|
$this->application->custom_labels = base64_encode($this->customLabels);
|
||||||
$this->application->save();
|
$this->application->save();
|
||||||
}
|
}
|
||||||
@@ -219,7 +229,6 @@ class General extends Component
|
|||||||
if ($this->ports_exposes !== $this->application->ports_exposes) {
|
if ($this->ports_exposes !== $this->application->ports_exposes) {
|
||||||
$this->resetDefaultLabels(false);
|
$this->resetDefaultLabels(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data_get($this->application, 'build_pack') === 'dockerimage') {
|
if (data_get($this->application, 'build_pack') === 'dockerimage') {
|
||||||
$this->validate([
|
$this->validate([
|
||||||
'application.docker_registry_image_name' => 'required',
|
'application.docker_registry_image_name' => 'required',
|
||||||
@@ -227,9 +236,16 @@ class General extends Component
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
if (data_get($this->application, 'fqdn')) {
|
if (data_get($this->application, 'fqdn')) {
|
||||||
$domains = Str::of($this->application->fqdn)->trim()->explode(',')->map(function ($domain) {
|
$this->application->fqdn = str($this->application->fqdn)->replaceEnd(',', '')->trim();
|
||||||
return Str::of($domain)->trim()->lower();
|
$domains = str($this->application->fqdn)->trim()->explode(',')->map(function ($domain) {
|
||||||
|
return str($domain)->trim()->lower();
|
||||||
});
|
});
|
||||||
|
$domains = $domains->unique();
|
||||||
|
foreach ($domains as $domain) {
|
||||||
|
if (!validate_dns_entry($domain, $this->application->destination->server)) {
|
||||||
|
$showToaster && $this->dispatch('error', "Validating DNS settings for: $domain failed.<br>Make sure you have added the DNS records correctly.<br><br>Check this <a target='_blank' class='underline' href='https://coolify.io/docs/dns-settings'>documentation</a> for further help.");
|
||||||
|
}
|
||||||
|
}
|
||||||
$this->application->fqdn = $domains->implode(',');
|
$this->application->fqdn = $domains->implode(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class Heading extends Component
|
|||||||
} else {
|
} else {
|
||||||
dispatch(new ServerStatusJob($this->application->destination->server));
|
dispatch(new ServerStatusJob($this->application->destination->server));
|
||||||
}
|
}
|
||||||
if ($showNotification) $this->dispatch('success', 'Application status updated.');
|
if ($showNotification) $this->dispatch('success', "Application status updated.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function force_deploy_without_cache()
|
public function force_deploy_without_cache()
|
||||||
@@ -60,7 +60,7 @@ class Heading extends Component
|
|||||||
force_rebuild: false,
|
force_rebuild: false,
|
||||||
is_new_deployment: true,
|
is_new_deployment: true,
|
||||||
);
|
);
|
||||||
return redirect()->route('project.application.deployment', [
|
return redirect()->route('project.application.deployment.show', [
|
||||||
'project_uuid' => $this->parameters['project_uuid'],
|
'project_uuid' => $this->parameters['project_uuid'],
|
||||||
'application_uuid' => $this->parameters['application_uuid'],
|
'application_uuid' => $this->parameters['application_uuid'],
|
||||||
'deployment_uuid' => $this->deploymentUuid,
|
'deployment_uuid' => $this->deploymentUuid,
|
||||||
@@ -74,7 +74,11 @@ class Heading extends Component
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($this->application->destination->server->isSwarm() && is_null($this->application->docker_registry_image_name)) {
|
if ($this->application->destination->server->isSwarm() && is_null($this->application->docker_registry_image_name)) {
|
||||||
$this->dispatch('error', 'Please set a Docker image name first.');
|
$this->dispatch('error', 'To deploy to a Swarm cluster you must set a Docker image name first.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (data_get($this->application, 'settings.is_build_server_enabled') && is_null($this->application->docker_registry_image_name)) {
|
||||||
|
$this->dispatch('error', 'To use a build server you must set a Docker image name first.<br>More information here: <a target="_blank" class="underline" href="https://coolify.io/docs/server/build-server">documentation</a>');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->setDeploymentUuid();
|
$this->setDeploymentUuid();
|
||||||
@@ -83,7 +87,7 @@ class Heading extends Component
|
|||||||
deployment_uuid: $this->deploymentUuid,
|
deployment_uuid: $this->deploymentUuid,
|
||||||
force_rebuild: $force_rebuild,
|
force_rebuild: $force_rebuild,
|
||||||
);
|
);
|
||||||
return redirect()->route('project.application.deployment', [
|
return redirect()->route('project.application.deployment.show', [
|
||||||
'project_uuid' => $this->parameters['project_uuid'],
|
'project_uuid' => $this->parameters['project_uuid'],
|
||||||
'application_uuid' => $this->parameters['application_uuid'],
|
'application_uuid' => $this->parameters['application_uuid'],
|
||||||
'deployment_uuid' => $this->deploymentUuid,
|
'deployment_uuid' => $this->deploymentUuid,
|
||||||
@@ -113,7 +117,7 @@ class Heading extends Component
|
|||||||
restart_only: true,
|
restart_only: true,
|
||||||
is_new_deployment: true,
|
is_new_deployment: true,
|
||||||
);
|
);
|
||||||
return redirect()->route('project.application.deployment', [
|
return redirect()->route('project.application.deployment.show', [
|
||||||
'project_uuid' => $this->parameters['project_uuid'],
|
'project_uuid' => $this->parameters['project_uuid'],
|
||||||
'application_uuid' => $this->parameters['application_uuid'],
|
'application_uuid' => $this->parameters['application_uuid'],
|
||||||
'deployment_uuid' => $this->deploymentUuid,
|
'deployment_uuid' => $this->deploymentUuid,
|
||||||
@@ -128,7 +132,7 @@ class Heading extends Component
|
|||||||
deployment_uuid: $this->deploymentUuid,
|
deployment_uuid: $this->deploymentUuid,
|
||||||
restart_only: true,
|
restart_only: true,
|
||||||
);
|
);
|
||||||
return redirect()->route('project.application.deployment', [
|
return redirect()->route('project.application.deployment.show', [
|
||||||
'project_uuid' => $this->parameters['project_uuid'],
|
'project_uuid' => $this->parameters['project_uuid'],
|
||||||
'application_uuid' => $this->parameters['application_uuid'],
|
'application_uuid' => $this->parameters['application_uuid'],
|
||||||
'deployment_uuid' => $this->deploymentUuid,
|
'deployment_uuid' => $this->deploymentUuid,
|
||||||
|
|||||||
@@ -49,10 +49,11 @@ class Previews extends Component
|
|||||||
queue_application_deployment(
|
queue_application_deployment(
|
||||||
application_id: $this->application->id,
|
application_id: $this->application->id,
|
||||||
deployment_uuid: $this->deployment_uuid,
|
deployment_uuid: $this->deployment_uuid,
|
||||||
force_rebuild: true,
|
force_rebuild: false,
|
||||||
pull_request_id: $pull_request_id,
|
pull_request_id: $pull_request_id,
|
||||||
|
git_type: $found->git_type ?? null,
|
||||||
);
|
);
|
||||||
return redirect()->route('project.application.deployment', [
|
return redirect()->route('project.application.deployment.show', [
|
||||||
'project_uuid' => $this->parameters['project_uuid'],
|
'project_uuid' => $this->parameters['project_uuid'],
|
||||||
'application_uuid' => $this->parameters['application_uuid'],
|
'application_uuid' => $this->parameters['application_uuid'],
|
||||||
'deployment_uuid' => $this->deployment_uuid,
|
'deployment_uuid' => $this->deployment_uuid,
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class Rollback extends Component
|
|||||||
commit: $commit,
|
commit: $commit,
|
||||||
force_rebuild: false,
|
force_rebuild: false,
|
||||||
);
|
);
|
||||||
return redirect()->route('project.application.deployment', [
|
return redirect()->route('project.application.deployment.show', [
|
||||||
'project_uuid' => $this->parameters['project_uuid'],
|
'project_uuid' => $this->parameters['project_uuid'],
|
||||||
'application_uuid' => $this->parameters['application_uuid'],
|
'application_uuid' => $this->parameters['application_uuid'],
|
||||||
'deployment_uuid' => $deployment_uuid,
|
'deployment_uuid' => $deployment_uuid,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use App\Models\Server;
|
|||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use Visus\Cuid2\Cuid2;
|
use Visus\Cuid2\Cuid2;
|
||||||
|
|
||||||
class CloneProject extends Component
|
class CloneMe extends Component
|
||||||
{
|
{
|
||||||
public string $project_uuid;
|
public string $project_uuid;
|
||||||
public string $environment_name;
|
public string $environment_name;
|
||||||
@@ -41,7 +41,7 @@ class CloneProject extends Component
|
|||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return view('livewire.project.clone-project');
|
return view('livewire.project.clone-me');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function selectServer($server_id, $destination_id)
|
public function selectServer($server_id, $destination_id)
|
||||||
@@ -152,7 +152,7 @@ class CloneProject extends Component
|
|||||||
}
|
}
|
||||||
$newService->parse();
|
$newService->parse();
|
||||||
}
|
}
|
||||||
return redirect()->route('project.resources', [
|
return redirect()->route('project.resource.index', [
|
||||||
'project_uuid' => $newProject->uuid,
|
'project_uuid' => $newProject->uuid,
|
||||||
'environment_name' => $newEnvironment->name,
|
'environment_name' => $newEnvironment->name,
|
||||||
]);
|
]);
|
||||||
41
app/Livewire/Project/Database/Backup/Execution.php
Normal file
41
app/Livewire/Project/Database/Backup/Execution.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Project\Database\Backup;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Execution extends Component
|
||||||
|
{
|
||||||
|
public $database;
|
||||||
|
public $backup;
|
||||||
|
public $executions;
|
||||||
|
public $s3s;
|
||||||
|
public function mount() {
|
||||||
|
$backup_uuid = request()->route('backup_uuid');
|
||||||
|
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
||||||
|
if (!$project) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
|
||||||
|
if (!$environment) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
$database = $environment->databases()->where('uuid', request()->route('database_uuid'))->first();
|
||||||
|
if (!$database) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
$backup = $database->scheduledBackups->where('uuid', $backup_uuid)->first();
|
||||||
|
if (!$backup) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
$executions = collect($backup->executions)->sortByDesc('created_at');
|
||||||
|
$this->database = $database;
|
||||||
|
$this->backup = $backup;
|
||||||
|
$this->executions = $executions;
|
||||||
|
$this->s3s = currentTeam()->s3s;
|
||||||
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.project.database.backup.execution');
|
||||||
|
}
|
||||||
|
}
|
||||||
39
app/Livewire/Project/Database/Backup/Index.php
Normal file
39
app/Livewire/Project/Database/Backup/Index.php
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Project\Database\Backup;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Index extends Component
|
||||||
|
{
|
||||||
|
public $database;
|
||||||
|
public $s3s;
|
||||||
|
public function mount() {
|
||||||
|
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
||||||
|
if (!$project) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
|
||||||
|
if (!$environment) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
$database = $environment->databases()->where('uuid', request()->route('database_uuid'))->first();
|
||||||
|
if (!$database) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
// No backups for redis
|
||||||
|
if ($database->getMorphClass() === 'App\Models\StandaloneRedis') {
|
||||||
|
return redirect()->route('project.database.configuration', [
|
||||||
|
'project_uuid' => $project->uuid,
|
||||||
|
'environment_name' => $environment->name,
|
||||||
|
'database_uuid' => $database->uuid,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
$this->database = $database;
|
||||||
|
$this->s3s = currentTeam()->s3s;
|
||||||
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.project.database.backup.index');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -52,7 +52,7 @@ class BackupEdit extends Component
|
|||||||
$url = $url->getPath() . "#{$url->getFragment()}";
|
$url = $url->getPath() . "#{$url->getFragment()}";
|
||||||
return redirect($url);
|
return redirect($url);
|
||||||
} else {
|
} else {
|
||||||
return redirect()->route('project.database.backups.all', $this->parameters);
|
return redirect()->route('project.database.backup.index', $this->parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
29
app/Livewire/Project/Database/Configuration.php
Normal file
29
app/Livewire/Project/Database/Configuration.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Project\Database;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Configuration extends Component
|
||||||
|
{
|
||||||
|
public $database;
|
||||||
|
public function mount() {
|
||||||
|
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
||||||
|
if (!$project) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
|
||||||
|
if (!$environment) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
$database = $environment->databases()->where('uuid', request()->route('database_uuid'))->first();
|
||||||
|
if (!$database) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
$this->database = $database;
|
||||||
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.project.database.configuration');
|
||||||
|
}
|
||||||
|
}
|
||||||
139
app/Livewire/Project/Database/Import.php
Normal file
139
app/Livewire/Project/Database/Import.php
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Project\Database;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Livewire\Component;
|
||||||
|
use Livewire\WithFileUploads;
|
||||||
|
use App\Models\Server;
|
||||||
|
use App\Models\StandaloneMariadb;
|
||||||
|
use App\Models\StandaloneMongodb;
|
||||||
|
use App\Models\StandaloneMysql;
|
||||||
|
use App\Models\StandalonePostgresql;
|
||||||
|
use App\Models\StandaloneRedis;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class Import extends Component
|
||||||
|
{
|
||||||
|
use WithFileUploads;
|
||||||
|
|
||||||
|
public $file;
|
||||||
|
public $resource;
|
||||||
|
public $parameters;
|
||||||
|
public $containers;
|
||||||
|
public bool $validated = true;
|
||||||
|
public bool $scpInProgress = false;
|
||||||
|
public bool $importRunning = false;
|
||||||
|
public string $validationMsg = '';
|
||||||
|
public Server $server;
|
||||||
|
public string $container;
|
||||||
|
public array $importCommands = [];
|
||||||
|
public string $postgresqlRestoreCommand = 'pg_restore -U $POSTGRES_USER -d $POSTGRES_DB';
|
||||||
|
public string $mysqlRestoreCommand = 'mysql -u $MYSQL_USER -p $MYSQL_PASSWORD $MYSQL_DATABASE';
|
||||||
|
public string $mariadbRestoreCommand = 'mariadb -u $MARIADB_USER -p $MARIADB_PASSWORD $MARIADB_DATABASE';
|
||||||
|
|
||||||
|
public function getListeners()
|
||||||
|
{
|
||||||
|
$userId = auth()->user()->id;
|
||||||
|
return [
|
||||||
|
"echo-private:user.{$userId},DatabaseStatusChanged" => '$refresh',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
$this->parameters = get_route_parameters();
|
||||||
|
$this->getContainers();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getContainers()
|
||||||
|
{
|
||||||
|
$this->containers = collect();
|
||||||
|
if (!data_get($this->parameters, 'database_uuid')) {
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$resource = StandalonePostgresql::where('uuid', $this->parameters['database_uuid'])->first();
|
||||||
|
if (is_null($resource)) {
|
||||||
|
$resource = StandaloneRedis::where('uuid', $this->parameters['database_uuid'])->first();
|
||||||
|
if (is_null($resource)) {
|
||||||
|
$resource = StandaloneMongodb::where('uuid', $this->parameters['database_uuid'])->first();
|
||||||
|
if (is_null($resource)) {
|
||||||
|
$resource = StandaloneMysql::where('uuid', $this->parameters['database_uuid'])->first();
|
||||||
|
if (is_null($resource)) {
|
||||||
|
$resource = StandaloneMariadb::where('uuid', $this->parameters['database_uuid'])->first();
|
||||||
|
if (is_null($resource)) {
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->resource = $resource;
|
||||||
|
$this->server = $this->resource->destination->server;
|
||||||
|
$this->container = $this->resource->uuid;
|
||||||
|
if (str(data_get($this, 'resource.status'))->startsWith('running')) {
|
||||||
|
$this->containers->push($this->container);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->containers->count() > 1) {
|
||||||
|
$this->validated = false;
|
||||||
|
$this->validationMsg = 'The database service has more than one container running. Cannot import.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
$this->resource->getMorphClass() == 'App\Models\StandaloneRedis'
|
||||||
|
|| $this->resource->getMorphClass() == 'App\Models\StandaloneMongodb'
|
||||||
|
) {
|
||||||
|
$this->validated = false;
|
||||||
|
$this->validationMsg = 'This database type is not currently supported.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function runImport()
|
||||||
|
{
|
||||||
|
$this->validate([
|
||||||
|
'file' => 'required|file|max:102400'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->importRunning = true;
|
||||||
|
$this->scpInProgress = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$uploadedFilename = $this->file->store('backup-import');
|
||||||
|
$path = Storage::path($uploadedFilename);
|
||||||
|
$tmpPath = '/tmp/' . basename($uploadedFilename);
|
||||||
|
|
||||||
|
// SCP the backup file to the server.
|
||||||
|
instant_scp($path, $tmpPath, $this->server);
|
||||||
|
$this->scpInProgress = false;
|
||||||
|
|
||||||
|
$this->importCommands[] = "docker cp {$tmpPath} {$this->container}:{$tmpPath}";
|
||||||
|
|
||||||
|
switch ($this->resource->getMorphClass()) {
|
||||||
|
case 'App\Models\StandaloneMariadb':
|
||||||
|
$this->importCommands[] = "docker exec {$this->container} sh -c '{$this->mariadbRestoreCommand} < {$tmpPath}'";
|
||||||
|
$this->importCommands[] = "rm {$tmpPath}";
|
||||||
|
break;
|
||||||
|
case 'App\Models\StandaloneMysql':
|
||||||
|
$this->importCommands[] = "docker exec {$this->container} sh -c '{$this->mysqlRestoreCommand} < {$tmpPath}'";
|
||||||
|
$this->importCommands[] = "rm {$tmpPath}";
|
||||||
|
break;
|
||||||
|
case 'App\Models\StandalonePostgresql':
|
||||||
|
$this->importCommands[] = "docker exec {$this->container} sh -c '{$this->postgresqlRestoreCommand} {$tmpPath}'";
|
||||||
|
$this->importCommands[] = "rm {$tmpPath}";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->importCommands[] = "docker exec {$this->container} sh -c 'rm {$tmpPath}'";
|
||||||
|
$this->importCommands[] = "docker exec {$this->container} sh -c 'echo \"Import finished with exit code $?\"'";
|
||||||
|
|
||||||
|
if (!empty($this->importCommands)) {
|
||||||
|
$activity = remote_process($this->importCommands, $this->server, ignore_errors: true);
|
||||||
|
$this->dispatch('newMonitorActivity', $activity->id);
|
||||||
|
}
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->validated = false;
|
||||||
|
$this->validationMsg = $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,6 +25,6 @@ class DeleteProject extends Component
|
|||||||
return $this->dispatch('error', 'Project has resources defined, please delete them first.');
|
return $this->dispatch('error', 'Project has resources defined, please delete them first.');
|
||||||
}
|
}
|
||||||
$project->delete();
|
$project->delete();
|
||||||
return redirect()->route('projects');
|
return redirect()->route('project.index');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,15 @@ class Edit extends Component
|
|||||||
'project.name' => 'required|min:3|max:255',
|
'project.name' => 'required|min:3|max:255',
|
||||||
'project.description' => 'nullable|string|max:255',
|
'project.description' => 'nullable|string|max:255',
|
||||||
];
|
];
|
||||||
|
public function mount() {
|
||||||
|
$projectUuid = request()->route('project_uuid');
|
||||||
|
$teamId = currentTeam()->id;
|
||||||
|
$project = Project::where('team_id', $teamId)->where('uuid', $projectUuid)->first();
|
||||||
|
if (!$project) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
$this->project = $project;
|
||||||
|
}
|
||||||
|
|
||||||
public function submit()
|
public function submit()
|
||||||
{
|
{
|
||||||
|
|||||||
21
app/Livewire/Project/Index.php
Normal file
21
app/Livewire/Project/Index.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Project;
|
||||||
|
|
||||||
|
use App\Models\Project;
|
||||||
|
use App\Models\Server;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Index extends Component
|
||||||
|
{
|
||||||
|
public $projects;
|
||||||
|
public $servers;
|
||||||
|
public function mount() {
|
||||||
|
$this->projects = Project::ownedByCurrentTeam()->get();
|
||||||
|
$this->servers = Server::ownedByCurrentTeam()->count();
|
||||||
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.project.index');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,18 +30,22 @@ class PublicGitRepository extends Component
|
|||||||
public GithubApp|GitlabApp|string $git_source = 'other';
|
public GithubApp|GitlabApp|string $git_source = 'other';
|
||||||
public string $git_host;
|
public string $git_host;
|
||||||
public string $git_repository;
|
public string $git_repository;
|
||||||
|
public $build_pack;
|
||||||
|
public bool $show_is_static = true;
|
||||||
|
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'repository_url' => 'required|url',
|
'repository_url' => 'required|url',
|
||||||
'port' => 'required|numeric',
|
'port' => 'required|numeric',
|
||||||
'is_static' => 'required|boolean',
|
'is_static' => 'required|boolean',
|
||||||
'publish_directory' => 'nullable|string',
|
'publish_directory' => 'nullable|string',
|
||||||
|
'build_pack' => 'required|string',
|
||||||
];
|
];
|
||||||
protected $validationAttributes = [
|
protected $validationAttributes = [
|
||||||
'repository_url' => 'repository',
|
'repository_url' => 'repository',
|
||||||
'port' => 'port',
|
'port' => 'port',
|
||||||
'is_static' => 'static',
|
'is_static' => 'static',
|
||||||
'publish_directory' => 'publish directory',
|
'publish_directory' => 'publish directory',
|
||||||
|
'build_pack' => 'build pack',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
@@ -53,7 +57,18 @@ class PublicGitRepository extends Component
|
|||||||
$this->parameters = get_route_parameters();
|
$this->parameters = get_route_parameters();
|
||||||
$this->query = request()->query();
|
$this->query = request()->query();
|
||||||
}
|
}
|
||||||
|
public function updatedBuildPack()
|
||||||
|
{
|
||||||
|
if ($this->build_pack === 'nixpacks') {
|
||||||
|
$this->show_is_static = true;
|
||||||
|
} else if ($this->build_pack === 'static') {
|
||||||
|
$this->show_is_static = false;
|
||||||
|
$this->is_static = false;
|
||||||
|
} else {
|
||||||
|
$this->show_is_static = false;
|
||||||
|
$this->is_static = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
public function instantSave()
|
public function instantSave()
|
||||||
{
|
{
|
||||||
if ($this->is_static) {
|
if ($this->is_static) {
|
||||||
@@ -157,6 +172,7 @@ class PublicGitRepository extends Component
|
|||||||
'environment_id' => $environment->id,
|
'environment_id' => $environment->id,
|
||||||
'destination_id' => $destination->id,
|
'destination_id' => $destination->id,
|
||||||
'destination_type' => $destination_class,
|
'destination_type' => $destination_class,
|
||||||
|
'build_pack' => $this->build_pack,
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
$application_init = [
|
$application_init = [
|
||||||
@@ -170,7 +186,8 @@ class PublicGitRepository extends Component
|
|||||||
'destination_id' => $destination->id,
|
'destination_id' => $destination->id,
|
||||||
'destination_type' => $destination_class,
|
'destination_type' => $destination_class,
|
||||||
'source_id' => $this->git_source->id,
|
'source_id' => $this->git_source->id,
|
||||||
'source_type' => $this->git_source->getMorphClass()
|
'source_type' => $this->git_source->getMorphClass(),
|
||||||
|
'build_pack' => $this->build_pack,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class Select extends Component
|
|||||||
|
|
||||||
public function updatedSelectedEnvironment()
|
public function updatedSelectedEnvironment()
|
||||||
{
|
{
|
||||||
return redirect()->route('project.resources.new', [
|
return redirect()->route('project.resource.create', [
|
||||||
'project_uuid' => $this->parameters['project_uuid'],
|
'project_uuid' => $this->parameters['project_uuid'],
|
||||||
'environment_name' => $this->selectedEnvironment,
|
'environment_name' => $this->selectedEnvironment,
|
||||||
]);
|
]);
|
||||||
@@ -104,7 +104,7 @@ class Select extends Component
|
|||||||
if ($this->includeSwarm) {
|
if ($this->includeSwarm) {
|
||||||
$this->servers = $this->allServers;
|
$this->servers = $this->allServers;
|
||||||
} else {
|
} else {
|
||||||
$this->servers = $this->allServers->where('settings.is_swarm_worker', false)->where('settings.is_swarm_manager', false);
|
$this->servers = $this->allServers->where('settings.is_swarm_worker', false)->where('settings.is_swarm_manager', false)->where('settings.is_build_server', false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function setType(string $type)
|
public function setType(string $type)
|
||||||
@@ -120,13 +120,13 @@ class Select extends Component
|
|||||||
case 'mongodb':
|
case 'mongodb':
|
||||||
$this->isDatabase = true;
|
$this->isDatabase = true;
|
||||||
$this->includeSwarm = false;
|
$this->includeSwarm = false;
|
||||||
$this->servers = $this->allServers->where('settings.is_swarm_worker', false)->where('settings.is_swarm_manager', false);
|
$this->servers = $this->allServers->where('settings.is_swarm_worker', false)->where('settings.is_swarm_manager', false)->where('settings.is_build_server', false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (str($type)->startsWith('one-click-service') || str($type)->startsWith('docker-compose-empty')) {
|
if (str($type)->startsWith('one-click-service') || str($type)->startsWith('docker-compose-empty')) {
|
||||||
$this->isDatabase = true;
|
$this->isDatabase = true;
|
||||||
$this->includeSwarm = false;
|
$this->includeSwarm = false;
|
||||||
$this->servers = $this->allServers->where('settings.is_swarm_worker', false)->where('settings.is_swarm_manager', false);
|
$this->servers = $this->allServers->where('settings.is_swarm_worker', false)->where('settings.is_swarm_manager', false)->where('settings.is_build_server', false);
|
||||||
}
|
}
|
||||||
if ($type === "existing-postgresql") {
|
if ($type === "existing-postgresql") {
|
||||||
$this->current_step = $type;
|
$this->current_step = $type;
|
||||||
@@ -157,7 +157,7 @@ class Select extends Component
|
|||||||
public function setDestination(string $destination_uuid)
|
public function setDestination(string $destination_uuid)
|
||||||
{
|
{
|
||||||
$this->destination_uuid = $destination_uuid;
|
$this->destination_uuid = $destination_uuid;
|
||||||
return redirect()->route('project.resources.new', [
|
return redirect()->route('project.resource.create', [
|
||||||
'project_uuid' => $this->parameters['project_uuid'],
|
'project_uuid' => $this->parameters['project_uuid'],
|
||||||
'environment_name' => $this->parameters['environment_name'],
|
'environment_name' => $this->parameters['environment_name'],
|
||||||
'type' => $this->type,
|
'type' => $this->type,
|
||||||
|
|||||||
@@ -1,52 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Livewire\Project\Resource;
|
||||||
|
|
||||||
use App\Models\EnvironmentVariable;
|
use App\Models\EnvironmentVariable;
|
||||||
use App\Models\Project;
|
|
||||||
use App\Models\Server;
|
|
||||||
use App\Models\Service;
|
use App\Models\Service;
|
||||||
use App\Models\StandaloneDocker;
|
use App\Models\StandaloneDocker;
|
||||||
use Illuminate\Support\Str;
|
use Livewire\Component;
|
||||||
|
|
||||||
class ProjectController extends Controller
|
class Create extends Component
|
||||||
{
|
|
||||||
public function all()
|
|
||||||
{
|
|
||||||
return view('projects', [
|
|
||||||
'projects' => Project::ownedByCurrentTeam()->get(),
|
|
||||||
'servers' => Server::ownedByCurrentTeam()->count(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function edit()
|
|
||||||
{
|
|
||||||
$projectUuid = request()->route('project_uuid');
|
|
||||||
$teamId = currentTeam()->id;
|
|
||||||
$project = Project::where('team_id', $teamId)->where('uuid', $projectUuid)->first();
|
|
||||||
if (!$project) {
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
return view('project.edit', ['project' => $project]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function show()
|
|
||||||
{
|
|
||||||
$projectUuid = request()->route('project_uuid');
|
|
||||||
$teamId = currentTeam()->id;
|
|
||||||
|
|
||||||
$project = Project::where('team_id', $teamId)->where('uuid', $projectUuid)->first();
|
|
||||||
if (!$project) {
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
$project->load(['environments']);
|
|
||||||
return view('project.show', ['project' => $project]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function new()
|
|
||||||
{
|
{
|
||||||
|
public $type;
|
||||||
|
public function mount() {
|
||||||
$services = getServiceTemplates();
|
$services = getServiceTemplates();
|
||||||
$type = Str::of(request()->query('type'));
|
$type = str(request()->query('type'));
|
||||||
$destination_uuid = request()->query('destination');
|
$destination_uuid = request()->query('destination');
|
||||||
$server_id = request()->query('server_id');
|
$server_id = request()->query('server_id');
|
||||||
|
|
||||||
@@ -81,14 +47,14 @@ class ProjectController extends Controller
|
|||||||
$oneClickService = data_get($services, "$oneClickServiceName.compose");
|
$oneClickService = data_get($services, "$oneClickServiceName.compose");
|
||||||
$oneClickDotEnvs = data_get($services, "$oneClickServiceName.envs", null);
|
$oneClickDotEnvs = data_get($services, "$oneClickServiceName.envs", null);
|
||||||
if ($oneClickDotEnvs) {
|
if ($oneClickDotEnvs) {
|
||||||
$oneClickDotEnvs = Str::of(base64_decode($oneClickDotEnvs))->split('/\r\n|\r|\n/')->filter(function ($value) {
|
$oneClickDotEnvs = str(base64_decode($oneClickDotEnvs))->split('/\r\n|\r|\n/')->filter(function ($value) {
|
||||||
return !empty($value);
|
return !empty($value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if ($oneClickService) {
|
if ($oneClickService) {
|
||||||
$destination = StandaloneDocker::whereUuid($destination_uuid)->first();
|
$destination = StandaloneDocker::whereUuid($destination_uuid)->first();
|
||||||
$service = Service::create([
|
$service = Service::create([
|
||||||
'name' => "$oneClickServiceName-" . Str::random(10),
|
'name' => "$oneClickServiceName-" . str()->random(10),
|
||||||
'docker_compose_raw' => base64_decode($oneClickService),
|
'docker_compose_raw' => base64_decode($oneClickService),
|
||||||
'environment_id' => $environment->id,
|
'environment_id' => $environment->id,
|
||||||
'server_id' => (int) $server_id,
|
'server_id' => (int) $server_id,
|
||||||
@@ -99,8 +65,8 @@ class ProjectController extends Controller
|
|||||||
$service->save();
|
$service->save();
|
||||||
if ($oneClickDotEnvs?->count() > 0) {
|
if ($oneClickDotEnvs?->count() > 0) {
|
||||||
$oneClickDotEnvs->each(function ($value) use ($service) {
|
$oneClickDotEnvs->each(function ($value) use ($service) {
|
||||||
$key = Str::before($value, '=');
|
$key = str()->before($value, '=');
|
||||||
$value = Str::of(Str::after($value, '='));
|
$value = str(str()->after($value, '='));
|
||||||
$generatedValue = $value;
|
$generatedValue = $value;
|
||||||
if ($value->contains('SERVICE_')) {
|
if ($value->contains('SERVICE_')) {
|
||||||
$command = $value->after('SERVICE_')->beforeLast('_');
|
$command = $value->after('SERVICE_')->beforeLast('_');
|
||||||
@@ -123,24 +89,10 @@ class ProjectController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return view('project.new', [
|
$this->type = $type->value();
|
||||||
'type' => $type->value()
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
public function render()
|
||||||
public function resources()
|
|
||||||
{
|
{
|
||||||
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
return view('livewire.project.resource.create');
|
||||||
if (!$project) {
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first();
|
|
||||||
if (!$environment) {
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
return view('project.resources', [
|
|
||||||
'project' => $project,
|
|
||||||
'environment' => $environment
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
115
app/Livewire/Project/Resource/Index.php
Normal file
115
app/Livewire/Project/Resource/Index.php
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Project\Resource;
|
||||||
|
|
||||||
|
use App\Models\Environment;
|
||||||
|
use App\Models\Project;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Index extends Component
|
||||||
|
{
|
||||||
|
public Project $project;
|
||||||
|
public Environment $environment;
|
||||||
|
public $applications = [];
|
||||||
|
public $postgresqls = [];
|
||||||
|
public $redis = [];
|
||||||
|
public $mongodbs = [];
|
||||||
|
public $mysqls = [];
|
||||||
|
public $mariadbs = [];
|
||||||
|
public $services = [];
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
||||||
|
if (!$project) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first();
|
||||||
|
if (!$environment) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
$this->project = $project;
|
||||||
|
$this->environment = $environment;
|
||||||
|
$this->applications = $environment->applications->sortBy('name');
|
||||||
|
$this->applications = $this->applications->map(function ($application) {
|
||||||
|
if (data_get($application, 'environment.project.uuid')) {
|
||||||
|
$application->hrefLink = route('project.application.configuration', [
|
||||||
|
'project_uuid' => data_get($application, 'environment.project.uuid'),
|
||||||
|
'environment_name' => data_get($application, 'environment.name'),
|
||||||
|
'application_uuid' => data_get($application, 'uuid')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return $application;
|
||||||
|
});
|
||||||
|
$this->postgresqls = $environment->postgresqls->sortBy('name');
|
||||||
|
$this->postgresqls = $this->postgresqls->map(function ($postgresql) {
|
||||||
|
if (data_get($postgresql, 'environment.project.uuid')) {
|
||||||
|
$postgresql->hrefLink = route('project.database.configuration', [
|
||||||
|
'project_uuid' => data_get($postgresql, 'environment.project.uuid'),
|
||||||
|
'environment_name' => data_get($postgresql, 'environment.name'),
|
||||||
|
'database_uuid' => data_get($postgresql, 'uuid')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return $postgresql;
|
||||||
|
});
|
||||||
|
$this->redis = $environment->redis->sortBy('name');
|
||||||
|
$this->redis = $this->redis->map(function ($redis) {
|
||||||
|
if (data_get($redis, 'environment.project.uuid')) {
|
||||||
|
$redis->hrefLink = route('project.database.configuration', [
|
||||||
|
'project_uuid' => data_get($redis, 'environment.project.uuid'),
|
||||||
|
'environment_name' => data_get($redis, 'environment.name'),
|
||||||
|
'database_uuid' => data_get($redis, 'uuid')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return $redis;
|
||||||
|
});
|
||||||
|
$this->mongodbs = $environment->mongodbs->sortBy('name');
|
||||||
|
$this->mongodbs = $this->mongodbs->map(function ($mongodb) {
|
||||||
|
if (data_get($mongodb, 'environment.project.uuid')) {
|
||||||
|
$mongodb->hrefLink = route('project.database.configuration', [
|
||||||
|
'project_uuid' => data_get($mongodb, 'environment.project.uuid'),
|
||||||
|
'environment_name' => data_get($mongodb, 'environment.name'),
|
||||||
|
'database_uuid' => data_get($mongodb, 'uuid')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return $mongodb;
|
||||||
|
});
|
||||||
|
$this->mysqls = $environment->mysqls->sortBy('name');
|
||||||
|
$this->mysqls = $this->mysqls->map(function ($mysql) {
|
||||||
|
if (data_get($mysql, 'environment.project.uuid')) {
|
||||||
|
$mysql->hrefLink = route('project.database.configuration', [
|
||||||
|
'project_uuid' => data_get($mysql, 'environment.project.uuid'),
|
||||||
|
'environment_name' => data_get($mysql, 'environment.name'),
|
||||||
|
'database_uuid' => data_get($mysql, 'uuid')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return $mysql;
|
||||||
|
});
|
||||||
|
$this->mariadbs = $environment->mariadbs->sortBy('name');
|
||||||
|
$this->mariadbs = $this->mariadbs->map(function ($mariadb) {
|
||||||
|
if (data_get($mariadb, 'environment.project.uuid')) {
|
||||||
|
$mariadb->hrefLink = route('project.database.configuration', [
|
||||||
|
'project_uuid' => data_get($mariadb, 'environment.project.uuid'),
|
||||||
|
'environment_name' => data_get($mariadb, 'environment.name'),
|
||||||
|
'database_uuid' => data_get($mariadb, 'uuid')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return $mariadb;
|
||||||
|
});
|
||||||
|
$this->services = $environment->services->sortBy('name');
|
||||||
|
$this->services = $this->services->map(function ($service) {
|
||||||
|
if (data_get($service, 'environment.project.uuid')) {
|
||||||
|
$service->hrefLink = route('project.service.configuration', [
|
||||||
|
'project_uuid' => data_get($service, 'environment.project.uuid'),
|
||||||
|
'environment_name' => data_get($service, 'environment.name'),
|
||||||
|
'service_uuid' => data_get($service, 'uuid')
|
||||||
|
]);
|
||||||
|
$service->status = serviceStatus($service);
|
||||||
|
}
|
||||||
|
return $service;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.project.resource.index');
|
||||||
|
}
|
||||||
|
}
|
||||||
54
app/Livewire/Project/Service/Configuration.php
Normal file
54
app/Livewire/Project/Service/Configuration.php
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Project\Service;
|
||||||
|
|
||||||
|
use App\Jobs\ContainerStatusJob;
|
||||||
|
use App\Models\Service;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Configuration extends Component
|
||||||
|
{
|
||||||
|
public Service $service;
|
||||||
|
public $applications;
|
||||||
|
public $databases;
|
||||||
|
public array $parameters;
|
||||||
|
public array $query;
|
||||||
|
public function getListeners()
|
||||||
|
{
|
||||||
|
$userId = auth()->user()->id;
|
||||||
|
return [
|
||||||
|
"echo-private:user.{$userId},ServiceStatusChanged" => 'checkStatus',
|
||||||
|
"refreshStacks",
|
||||||
|
"checkStatus",
|
||||||
|
];
|
||||||
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.project.service.configuration');
|
||||||
|
}
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
$this->parameters = get_route_parameters();
|
||||||
|
$this->query = request()->query();
|
||||||
|
$this->service = Service::whereUuid($this->parameters['service_uuid'])->firstOrFail();
|
||||||
|
$this->applications = $this->service->applications->sort();
|
||||||
|
$this->databases = $this->service->databases->sort();
|
||||||
|
}
|
||||||
|
public function checkStatus()
|
||||||
|
{
|
||||||
|
dispatch_sync(new ContainerStatusJob($this->service->server));
|
||||||
|
$this->refreshStacks();
|
||||||
|
$this->dispatch('serviceStatusChanged');
|
||||||
|
}
|
||||||
|
public function refreshStacks()
|
||||||
|
{
|
||||||
|
$this->applications = $this->service->applications->sort();
|
||||||
|
$this->applications->each(function ($application) {
|
||||||
|
$application->refresh();
|
||||||
|
});
|
||||||
|
$this->databases = $this->service->databases->sort();
|
||||||
|
$this->databases->each(function ($database) {
|
||||||
|
$database->refresh();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,53 +2,51 @@
|
|||||||
|
|
||||||
namespace App\Livewire\Project\Service;
|
namespace App\Livewire\Project\Service;
|
||||||
|
|
||||||
use App\Jobs\ContainerStatusJob;
|
|
||||||
use App\Models\Service;
|
use App\Models\Service;
|
||||||
|
use App\Models\ServiceApplication;
|
||||||
|
use App\Models\ServiceDatabase;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class Index extends Component
|
class Index extends Component
|
||||||
{
|
{
|
||||||
public Service $service;
|
public Service $service;
|
||||||
public $applications;
|
public ?ServiceApplication $serviceApplication = null;
|
||||||
public $databases;
|
public ?ServiceDatabase $serviceDatabase = null;
|
||||||
public array $parameters;
|
public array $parameters;
|
||||||
public array $query;
|
public array $query;
|
||||||
public function getListeners()
|
public Collection $services;
|
||||||
|
public $s3s;
|
||||||
|
|
||||||
|
protected $listeners = ['generateDockerCompose'];
|
||||||
|
|
||||||
|
public function mount()
|
||||||
{
|
{
|
||||||
$userId = auth()->user()->id;
|
try {
|
||||||
return [
|
$this->services = collect([]);
|
||||||
"echo-private:user.{$userId},ServiceStatusChanged" => 'checkStatus',
|
$this->parameters = get_route_parameters();
|
||||||
"refreshStacks",
|
$this->query = request()->query();
|
||||||
"checkStatus",
|
$this->service = Service::whereUuid($this->parameters['service_uuid'])->firstOrFail();
|
||||||
];
|
$service = $this->service->applications()->whereName($this->parameters['service_name'])->first();
|
||||||
|
if ($service) {
|
||||||
|
$this->serviceApplication = $service;
|
||||||
|
$this->serviceApplication->getFilesFromServer();
|
||||||
|
} else {
|
||||||
|
$this->serviceDatabase = $this->service->databases()->whereName($this->parameters['service_name'])->first();
|
||||||
|
$this->serviceDatabase->getFilesFromServer();
|
||||||
|
}
|
||||||
|
$this->s3s = currentTeam()->s3s;
|
||||||
|
} catch(\Throwable $e) {
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public function generateDockerCompose()
|
||||||
|
{
|
||||||
|
$this->service->parse();
|
||||||
}
|
}
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return view('livewire.project.service.index');
|
return view('livewire.project.service.index');
|
||||||
}
|
}
|
||||||
public function mount()
|
|
||||||
{
|
|
||||||
$this->parameters = get_route_parameters();
|
|
||||||
$this->query = request()->query();
|
|
||||||
$this->service = Service::whereUuid($this->parameters['service_uuid'])->firstOrFail();
|
|
||||||
$this->applications = $this->service->applications->sort();
|
|
||||||
$this->databases = $this->service->databases->sort();
|
|
||||||
}
|
|
||||||
public function checkStatus()
|
|
||||||
{
|
|
||||||
dispatch_sync(new ContainerStatusJob($this->service->server));
|
|
||||||
$this->refreshStacks();
|
|
||||||
$this->dispatch('serviceStatusChanged');
|
|
||||||
}
|
|
||||||
public function refreshStacks()
|
|
||||||
{
|
|
||||||
$this->applications = $this->service->applications->sort();
|
|
||||||
$this->applications->each(function ($application) {
|
|
||||||
$application->refresh();
|
|
||||||
});
|
|
||||||
$this->databases = $this->service->databases->sort();
|
|
||||||
$this->databases->each(function ($database) {
|
|
||||||
$database->refresh();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Livewire\Project\Service;
|
|
||||||
|
|
||||||
use App\Models\Service;
|
|
||||||
use App\Models\ServiceApplication;
|
|
||||||
use App\Models\ServiceDatabase;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Livewire\Component;
|
|
||||||
|
|
||||||
class Show extends Component
|
|
||||||
{
|
|
||||||
public Service $service;
|
|
||||||
public ?ServiceApplication $serviceApplication = null;
|
|
||||||
public ?ServiceDatabase $serviceDatabase = null;
|
|
||||||
public array $parameters;
|
|
||||||
public array $query;
|
|
||||||
public Collection $services;
|
|
||||||
public $s3s;
|
|
||||||
|
|
||||||
protected $listeners = ['generateDockerCompose'];
|
|
||||||
|
|
||||||
public function mount()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$this->services = collect([]);
|
|
||||||
$this->parameters = get_route_parameters();
|
|
||||||
$this->query = request()->query();
|
|
||||||
$this->service = Service::whereUuid($this->parameters['service_uuid'])->firstOrFail();
|
|
||||||
$service = $this->service->applications()->whereName($this->parameters['service_name'])->first();
|
|
||||||
if ($service) {
|
|
||||||
$this->serviceApplication = $service;
|
|
||||||
$this->serviceApplication->getFilesFromServer();
|
|
||||||
} else {
|
|
||||||
$this->serviceDatabase = $this->service->databases()->whereName($this->parameters['service_name'])->first();
|
|
||||||
$this->serviceDatabase->getFilesFromServer();
|
|
||||||
}
|
|
||||||
$this->s3s = currentTeam()->s3s;
|
|
||||||
} catch(\Throwable $e) {
|
|
||||||
return handleError($e, $this);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
public function generateDockerCompose()
|
|
||||||
{
|
|
||||||
$this->service->parse();
|
|
||||||
}
|
|
||||||
public function render()
|
|
||||||
{
|
|
||||||
return view('livewire.project.service.show');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -25,7 +25,7 @@ class Danger extends Component
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
DeleteResourceJob::dispatchSync($this->resource);
|
DeleteResourceJob::dispatchSync($this->resource);
|
||||||
return redirect()->route('project.resources', [
|
return redirect()->route('project.resource.index', [
|
||||||
'project_uuid' => $this->projectUuid,
|
'project_uuid' => $this->projectUuid,
|
||||||
'environment_name' => $this->environmentName
|
'environment_name' => $this->environmentName
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -8,5 +8,5 @@ class Destination extends Component
|
|||||||
{
|
{
|
||||||
public $resource;
|
public $resource;
|
||||||
public $servers = [];
|
public $servers = [];
|
||||||
public $additionalServers = [];
|
public $additional_servers = [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ use App\Models\StandaloneMongodb;
|
|||||||
use App\Models\StandaloneMysql;
|
use App\Models\StandaloneMysql;
|
||||||
use App\Models\StandalonePostgresql;
|
use App\Models\StandalonePostgresql;
|
||||||
use App\Models\StandaloneRedis;
|
use App\Models\StandaloneRedis;
|
||||||
use Illuminate\Support\Sleep;
|
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class ExecuteContainerCommand extends Component
|
class ExecuteContainerCommand extends Component
|
||||||
@@ -109,8 +108,7 @@ class ExecuteContainerCommand extends Component
|
|||||||
$this->validate();
|
$this->validate();
|
||||||
try {
|
try {
|
||||||
// Wrap command to prevent escaped execution in the host.
|
// Wrap command to prevent escaped execution in the host.
|
||||||
$cmd = 'sh -c "' . str_replace('"', '\"', $this->command) . '"';
|
$cmd = 'sh -c "if [ -f ~/.profile ]; then . ~/.profile; fi; ' . str_replace('"', '\"', $this->command) . '"';
|
||||||
|
|
||||||
if (!empty($this->workDir)) {
|
if (!empty($this->workDir)) {
|
||||||
$exec = "docker exec -w {$this->workDir} {$this->container} {$cmd}";
|
$exec = "docker exec -w {$this->workDir} {$this->container} {$cmd}";
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ class ResourceLimits extends Component
|
|||||||
if (!$this->resource->limits_cpus) {
|
if (!$this->resource->limits_cpus) {
|
||||||
$this->resource->limits_cpus = "0";
|
$this->resource->limits_cpus = "0";
|
||||||
}
|
}
|
||||||
if (!$this->resource->limits_cpuset) {
|
if ($this->resource->limits_cpuset === "") {
|
||||||
$this->resource->limits_cpuset = "0";
|
$this->resource->limits_cpuset = null;
|
||||||
}
|
}
|
||||||
if (!$this->resource->limits_cpu_shares) {
|
if (!$this->resource->limits_cpu_shares) {
|
||||||
$this->resource->limits_cpu_shares = 1024;
|
$this->resource->limits_cpu_shares = 1024;
|
||||||
|
|||||||
58
app/Livewire/Project/Shared/ScheduledTask/Add.php
Normal file
58
app/Livewire/Project/Shared/ScheduledTask/Add.php
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Project\Shared\ScheduledTask;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Add extends Component
|
||||||
|
{
|
||||||
|
public $parameters;
|
||||||
|
public string $name;
|
||||||
|
public string $command;
|
||||||
|
public string $frequency;
|
||||||
|
public ?string $container = '';
|
||||||
|
|
||||||
|
protected $listeners = ['clearScheduledTask' => 'clear'];
|
||||||
|
protected $rules = [
|
||||||
|
'name' => 'required|string',
|
||||||
|
'command' => 'required|string',
|
||||||
|
'frequency' => 'required|string',
|
||||||
|
'container' => 'nullable|string',
|
||||||
|
];
|
||||||
|
protected $validationAttributes = [
|
||||||
|
'name' => 'name',
|
||||||
|
'command' => 'command',
|
||||||
|
'frequency' => 'frequency',
|
||||||
|
'container' => 'container',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
$this->parameters = get_route_parameters();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function submit()
|
||||||
|
{
|
||||||
|
$this->validate();
|
||||||
|
$isValid = validate_cron_expression($this->frequency);
|
||||||
|
if (!$isValid) {
|
||||||
|
$this->dispatch('error', 'Invalid Cron / Human expression.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->dispatch('saveScheduledTask', [
|
||||||
|
'name' => $this->name,
|
||||||
|
'command' => $this->command,
|
||||||
|
'frequency' => $this->frequency,
|
||||||
|
'container' => $this->container,
|
||||||
|
]);
|
||||||
|
$this->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clear()
|
||||||
|
{
|
||||||
|
$this->name = '';
|
||||||
|
$this->command = '';
|
||||||
|
$this->frequency = '';
|
||||||
|
$this->container = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
56
app/Livewire/Project/Shared/ScheduledTask/All.php
Normal file
56
app/Livewire/Project/Shared/ScheduledTask/All.php
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Project\Shared\ScheduledTask;
|
||||||
|
|
||||||
|
use App\Models\ScheduledTask;
|
||||||
|
use Livewire\Component;
|
||||||
|
use Visus\Cuid2\Cuid2;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class All extends Component
|
||||||
|
{
|
||||||
|
public $resource;
|
||||||
|
public string|null $modalId = null;
|
||||||
|
public ?string $variables = null;
|
||||||
|
public array $parameters;
|
||||||
|
protected $listeners = ['refreshTasks', 'saveScheduledTask' => 'submit'];
|
||||||
|
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
$this->parameters = get_route_parameters();
|
||||||
|
$this->modalId = new Cuid2(7);
|
||||||
|
}
|
||||||
|
public function refreshTasks()
|
||||||
|
{
|
||||||
|
$this->resource->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function submit($data)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$task = new ScheduledTask();
|
||||||
|
$task->name = $data['name'];
|
||||||
|
$task->command = $data['command'];
|
||||||
|
$task->frequency = $data['frequency'];
|
||||||
|
$task->container = $data['container'];
|
||||||
|
$task->team_id = currentTeam()->id;
|
||||||
|
|
||||||
|
switch ($this->resource->type()) {
|
||||||
|
case 'application':
|
||||||
|
$task->application_id = $this->resource->id;
|
||||||
|
break;
|
||||||
|
case 'standalone-postgresql':
|
||||||
|
$task->standalone_postgresql_id = $this->resource->id;
|
||||||
|
break;
|
||||||
|
case 'service':
|
||||||
|
$task->service_id = $this->resource->id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$task->save();
|
||||||
|
$this->refreshTasks();
|
||||||
|
$this->dispatch('success', 'Scheduled task added successfully.');
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
27
app/Livewire/Project/Shared/ScheduledTask/Executions.php
Normal file
27
app/Livewire/Project/Shared/ScheduledTask/Executions.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Project\Shared\ScheduledTask;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Executions extends Component
|
||||||
|
{
|
||||||
|
public $executions = [];
|
||||||
|
public $selectedKey;
|
||||||
|
public function getListeners()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
"selectTask",
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function selectTask($key): void
|
||||||
|
{
|
||||||
|
if ($key == $this->selectedKey) {
|
||||||
|
$this->selectedKey = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->selectedKey = $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
72
app/Livewire/Project/Shared/ScheduledTask/Show.php
Normal file
72
app/Livewire/Project/Shared/ScheduledTask/Show.php
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Project\Shared\ScheduledTask;
|
||||||
|
|
||||||
|
use App\Models\ScheduledTask as ModelsScheduledTask;
|
||||||
|
use Livewire\Component;
|
||||||
|
use App\Models\Application;
|
||||||
|
use App\Models\Service;
|
||||||
|
use Visus\Cuid2\Cuid2;
|
||||||
|
|
||||||
|
class Show extends Component
|
||||||
|
{
|
||||||
|
public $parameters;
|
||||||
|
public Application|Service $resource;
|
||||||
|
public ModelsScheduledTask $task;
|
||||||
|
public ?string $modalId = null;
|
||||||
|
public string $type;
|
||||||
|
|
||||||
|
protected $rules = [
|
||||||
|
'task.name' => 'required|string',
|
||||||
|
'task.command' => 'required|string',
|
||||||
|
'task.frequency' => 'required|string',
|
||||||
|
'task.container' => 'nullable|string',
|
||||||
|
];
|
||||||
|
protected $validationAttributes = [
|
||||||
|
'name' => 'name',
|
||||||
|
'command' => 'command',
|
||||||
|
'frequency' => 'frequency',
|
||||||
|
'container' => 'container',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
$this->parameters = get_route_parameters();
|
||||||
|
|
||||||
|
if (data_get($this->parameters, 'application_uuid')) {
|
||||||
|
$this->type = 'application';
|
||||||
|
$this->resource = Application::where('uuid', $this->parameters['application_uuid'])->firstOrFail();
|
||||||
|
} else if (data_get($this->parameters, 'service_uuid')) {
|
||||||
|
$this->type = 'service';
|
||||||
|
$this->resource = Service::where('uuid', $this->parameters['service_uuid'])->firstOrFail();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->modalId = new Cuid2(7);
|
||||||
|
$this->task = ModelsScheduledTask::where('uuid', request()->route('task_uuid'))->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function submit()
|
||||||
|
{
|
||||||
|
$this->validate();
|
||||||
|
$this->task->save();
|
||||||
|
$this->dispatch('success', 'Scheduled task updated successfully.');
|
||||||
|
$this->dispatch('refreshTasks');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->task->delete();
|
||||||
|
|
||||||
|
if ($this->type == 'application') {
|
||||||
|
return redirect()->route('project.application.configuration', $this->parameters);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return redirect()->route('project.service.configuration', $this->parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return handleError($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
26
app/Livewire/Project/Show.php
Normal file
26
app/Livewire/Project/Show.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Project;
|
||||||
|
|
||||||
|
use App\Models\Project;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Show extends Component
|
||||||
|
{
|
||||||
|
public Project $project;
|
||||||
|
public function mount() {
|
||||||
|
$projectUuid = request()->route('project_uuid');
|
||||||
|
$teamId = currentTeam()->id;
|
||||||
|
|
||||||
|
$project = Project::where('team_id', $teamId)->where('uuid', $projectUuid)->first();
|
||||||
|
if (!$project) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
$project->load(['environments']);
|
||||||
|
$this->project = $project;
|
||||||
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.project.show');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Livewire\PrivateKey;
|
namespace App\Livewire\Security\PrivateKey;
|
||||||
|
|
||||||
use App\Models\PrivateKey;
|
use App\Models\PrivateKey;
|
||||||
use DanHarrin\LivewireRateLimiting\WithRateLimiting;
|
use DanHarrin\LivewireRateLimiting\WithRateLimiting;
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Livewire\PrivateKey;
|
namespace App\Livewire\Security\PrivateKey;
|
||||||
|
|
||||||
use App\Models\PrivateKey;
|
use App\Models\PrivateKey;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class Change extends Component
|
class Show extends Component
|
||||||
{
|
{
|
||||||
public PrivateKey $private_key;
|
public PrivateKey $private_key;
|
||||||
public $public_key;
|
public $public_key;
|
||||||
@@ -24,6 +24,7 @@ class Change extends Component
|
|||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
$this->private_key = PrivateKey::ownedByCurrentTeam(['name', 'description', 'private_key', 'is_git_related'])->whereUuid(request()->private_key_uuid)->firstOrFail();
|
||||||
$this->public_key = $this->private_key->publicKey();
|
$this->public_key = $this->private_key->publicKey();
|
||||||
}catch(\Throwable $e) {
|
}catch(\Throwable $e) {
|
||||||
return handleError($e, $this);
|
return handleError($e, $this);
|
||||||
@@ -19,7 +19,7 @@ class Delete extends Component
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->server->delete();
|
$this->server->delete();
|
||||||
return redirect()->route('server.all');
|
return redirect()->route('server.index');
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return handleError($e, $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class Show extends Component
|
|||||||
try {
|
try {
|
||||||
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
|
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
|
||||||
if (is_null($this->server)) {
|
if (is_null($this->server)) {
|
||||||
return redirect()->route('server.all');
|
return redirect()->route('server.index');
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return handleError($e, $this);
|
return handleError($e, $this);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class Form extends Component
|
|||||||
'server.settings.is_reachable' => 'required',
|
'server.settings.is_reachable' => 'required',
|
||||||
'server.settings.is_swarm_manager' => 'required|boolean',
|
'server.settings.is_swarm_manager' => 'required|boolean',
|
||||||
'server.settings.is_swarm_worker' => 'required|boolean',
|
'server.settings.is_swarm_worker' => 'required|boolean',
|
||||||
|
'server.settings.is_build_server' => 'required|boolean',
|
||||||
'wildcard_domain' => 'nullable|url',
|
'wildcard_domain' => 'nullable|url',
|
||||||
];
|
];
|
||||||
protected $validationAttributes = [
|
protected $validationAttributes = [
|
||||||
@@ -38,6 +39,7 @@ class Form extends Component
|
|||||||
'server.settings.is_reachable' => 'Is reachable',
|
'server.settings.is_reachable' => 'Is reachable',
|
||||||
'server.settings.is_swarm_manager' => 'Swarm Manager',
|
'server.settings.is_swarm_manager' => 'Swarm Manager',
|
||||||
'server.settings.is_swarm_worker' => 'Swarm Worker',
|
'server.settings.is_swarm_worker' => 'Swarm Worker',
|
||||||
|
'server.settings.is_build_server' => 'Build Server',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
@@ -76,7 +78,7 @@ class Form extends Component
|
|||||||
$this->server->settings->is_usable = true;
|
$this->server->settings->is_usable = true;
|
||||||
$this->server->settings->save();
|
$this->server->settings->save();
|
||||||
} else {
|
} else {
|
||||||
$this->dispatch('error', 'Server is not reachable. Please check your connection and configuration.');
|
$this->dispatch('error', 'Server is not reachable.<br>Please validate your configuration and connection.<br><br>Check this <a target="_blank" class="underline" href="https://coolify.io/docs/server/openssh">documentation</a> for further help.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,12 +87,12 @@ class Form extends Component
|
|||||||
try {
|
try {
|
||||||
$uptime = $this->server->validateConnection();
|
$uptime = $this->server->validateConnection();
|
||||||
if (!$uptime) {
|
if (!$uptime) {
|
||||||
$install && $this->dispatch('error', 'Server is not reachable. Please check your connection and configuration.');
|
$install && $this->dispatch('error', 'Server is not reachable.<br>Please validate your configuration and connection.<br><br>Check this <a target="_blank" class="underline" href="https://coolify.io/docs/server/openssh">documentation</a> for further help.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$supported_os_type = $this->server->validateOS();
|
$supported_os_type = $this->server->validateOS();
|
||||||
if (!$supported_os_type) {
|
if (!$supported_os_type) {
|
||||||
$install && $this->dispatch('error', 'Server OS type is not supported for automated installation. Please install Docker manually before continuing: <a target="_blank" class="underline" href="https://coolify.io/docs/servers#install-docker-engine-manually">documentation</a>.');
|
$install && $this->dispatch('error', 'Server OS type is not supported for automated installation. Please install Docker manually before continuing: <a target="_blank" class="underline" href="https://docs.docker.com/engine/install/#server">documentation</a>.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$dockerInstalled = $this->server->validateDockerEngine();
|
$dockerInstalled = $this->server->validateDockerEngine();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use App\Models\Server;
|
|||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class All extends Component
|
class Index extends Component
|
||||||
{
|
{
|
||||||
public ?Collection $servers = null;
|
public ?Collection $servers = null;
|
||||||
|
|
||||||
@@ -15,6 +15,6 @@ class All extends Component
|
|||||||
}
|
}
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return view('livewire.server.all');
|
return view('livewire.server.index');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ class LogDrains extends Component
|
|||||||
try {
|
try {
|
||||||
$server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
|
$server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
|
||||||
if (is_null($server)) {
|
if (is_null($server)) {
|
||||||
return redirect()->route('server.all');
|
return redirect()->route('server.index');
|
||||||
}
|
}
|
||||||
$this->server = $server;
|
$this->server = $server;
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ class ByIp extends Component
|
|||||||
public bool $is_swarm_worker = false;
|
public bool $is_swarm_worker = false;
|
||||||
public $selected_swarm_cluster = null;
|
public $selected_swarm_cluster = null;
|
||||||
|
|
||||||
|
public bool $is_build_server = false;
|
||||||
|
|
||||||
public $swarm_managers = [];
|
public $swarm_managers = [];
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'name' => 'required|string',
|
'name' => 'required|string',
|
||||||
@@ -34,6 +36,7 @@ class ByIp extends Component
|
|||||||
'port' => 'required|integer',
|
'port' => 'required|integer',
|
||||||
'is_swarm_manager' => 'required|boolean',
|
'is_swarm_manager' => 'required|boolean',
|
||||||
'is_swarm_worker' => 'required|boolean',
|
'is_swarm_worker' => 'required|boolean',
|
||||||
|
'is_build_server' => 'required|boolean',
|
||||||
];
|
];
|
||||||
protected $validationAttributes = [
|
protected $validationAttributes = [
|
||||||
'name' => 'Name',
|
'name' => 'Name',
|
||||||
@@ -43,6 +46,7 @@ class ByIp extends Component
|
|||||||
'port' => 'Port',
|
'port' => 'Port',
|
||||||
'is_swarm_manager' => 'Swarm Manager',
|
'is_swarm_manager' => 'Swarm Manager',
|
||||||
'is_swarm_worker' => 'Swarm Worker',
|
'is_swarm_worker' => 'Swarm Worker',
|
||||||
|
'is_build_server' => 'Build Server',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
@@ -89,8 +93,14 @@ class ByIp extends Component
|
|||||||
$payload['swarm_cluster'] = $this->selected_swarm_cluster;
|
$payload['swarm_cluster'] = $this->selected_swarm_cluster;
|
||||||
}
|
}
|
||||||
$server = Server::create($payload);
|
$server = Server::create($payload);
|
||||||
|
if ($this->is_build_server) {
|
||||||
|
$this->is_swarm_manager = false;
|
||||||
|
$this->is_swarm_worker = false;
|
||||||
|
} else {
|
||||||
$server->settings->is_swarm_manager = $this->is_swarm_manager;
|
$server->settings->is_swarm_manager = $this->is_swarm_manager;
|
||||||
$server->settings->is_swarm_worker = $this->is_swarm_worker;
|
$server->settings->is_swarm_worker = $this->is_swarm_worker;
|
||||||
|
}
|
||||||
|
$server->settings->is_build_server = $this->is_build_server;
|
||||||
$server->settings->save();
|
$server->settings->save();
|
||||||
$server->addInitialNetwork();
|
$server->addInitialNetwork();
|
||||||
return redirect()->route('server.show', $server->uuid);
|
return redirect()->route('server.show', $server->uuid);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class Show extends Component
|
|||||||
try {
|
try {
|
||||||
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
|
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
|
||||||
if (is_null($this->server)) {
|
if (is_null($this->server)) {
|
||||||
return redirect()->route('server.all');
|
return redirect()->route('server.index');
|
||||||
}
|
}
|
||||||
$this->privateKeys = PrivateKey::ownedByCurrentTeam()->get()->where('is_git_related', false);
|
$this->privateKeys = PrivateKey::ownedByCurrentTeam()->get()->where('is_git_related', false);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ class Proxy extends Component
|
|||||||
{
|
{
|
||||||
$this->server->proxy = null;
|
$this->server->proxy = null;
|
||||||
$this->server->save();
|
$this->server->save();
|
||||||
$this->dispatch('proxyStatusUpdated');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function select_proxy($proxy_type)
|
public function select_proxy($proxy_type)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace App\Livewire\Server\Proxy;
|
|||||||
|
|
||||||
use App\Actions\Proxy\CheckProxy;
|
use App\Actions\Proxy\CheckProxy;
|
||||||
use App\Actions\Proxy\StartProxy;
|
use App\Actions\Proxy\StartProxy;
|
||||||
|
use App\Events\ProxyStatusChanged;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
@@ -14,7 +15,17 @@ class Deploy extends Component
|
|||||||
public ?string $currentRoute = null;
|
public ?string $currentRoute = null;
|
||||||
public ?string $serverIp = null;
|
public ?string $serverIp = null;
|
||||||
|
|
||||||
protected $listeners = ['proxyStatusUpdated', 'traefikDashboardAvailable', 'serverRefresh' => 'proxyStatusUpdated', "checkProxy", "startProxy"];
|
public function getListeners()
|
||||||
|
{
|
||||||
|
$teamId = auth()->user()->currentTeam()->id;
|
||||||
|
return [
|
||||||
|
"echo-private:team.{$teamId},ProxyStatusChanged" => 'proxyStarted',
|
||||||
|
'proxyStatusUpdated',
|
||||||
|
'traefikDashboardAvailable',
|
||||||
|
'serverRefresh' => 'proxyStatusUpdated',
|
||||||
|
"checkProxy", "startProxy"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
@@ -29,12 +40,22 @@ class Deploy extends Component
|
|||||||
{
|
{
|
||||||
$this->traefikDashboardAvailable = $data;
|
$this->traefikDashboardAvailable = $data;
|
||||||
}
|
}
|
||||||
|
public function proxyStarted()
|
||||||
|
{
|
||||||
|
CheckProxy::run($this->server, true);
|
||||||
|
$this->dispatch('success', 'Proxy started.');
|
||||||
|
}
|
||||||
public function proxyStatusUpdated()
|
public function proxyStatusUpdated()
|
||||||
{
|
{
|
||||||
$this->server->refresh();
|
$this->server->refresh();
|
||||||
}
|
}
|
||||||
public function ip()
|
public function restart() {
|
||||||
{
|
try {
|
||||||
|
$this->stop();
|
||||||
|
$this->dispatch('checkProxy');
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public function checkProxy()
|
public function checkProxy()
|
||||||
{
|
{
|
||||||
@@ -50,7 +71,7 @@ class Deploy extends Component
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$activity = StartProxy::run($this->server);
|
$activity = StartProxy::run($this->server);
|
||||||
$this->dispatch('newMonitorActivity', $activity->id);
|
$this->dispatch('newMonitorActivity', $activity->id, ProxyStatusChanged::class);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return handleError($e, $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
@@ -77,6 +98,5 @@ class Deploy extends Component
|
|||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return handleError($e, $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class Logs extends Component
|
|||||||
try {
|
try {
|
||||||
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
|
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
|
||||||
if (is_null($this->server)) {
|
if (is_null($this->server)) {
|
||||||
return redirect()->route('server.all');
|
return redirect()->route('server.index');
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return handleError($e, $this);
|
return handleError($e, $this);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class Show extends Component
|
|||||||
try {
|
try {
|
||||||
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
|
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
|
||||||
if (is_null($this->server)) {
|
if (is_null($this->server)) {
|
||||||
return redirect()->route('server.all');
|
return redirect()->route('server.index');
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return handleError($e, $this);
|
return handleError($e, $this);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class Show extends Component
|
|||||||
try {
|
try {
|
||||||
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
|
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
|
||||||
if (is_null($this->server)) {
|
if (is_null($this->server)) {
|
||||||
return redirect()->route('server.all');
|
return redirect()->route('server.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class ShowPrivateKey extends Component
|
|||||||
if ($uptime) {
|
if ($uptime) {
|
||||||
$this->dispatch('success', 'Server is reachable.');
|
$this->dispatch('success', 'Server is reachable.');
|
||||||
} else {
|
} else {
|
||||||
$this->dispatch('error', 'Server is not reachable. Please check your connection and private key configuration.');
|
$this->dispatch('error', 'Server is not reachable.<br>Please validate your configuration and connection.<br><br>Check this <a target="_blank" class="underline" href="https://coolify.io/docs/configuration#openssh-server">documentation</a> for further help.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class Configuration extends Component
|
|||||||
public bool $do_not_track;
|
public bool $do_not_track;
|
||||||
public bool $is_auto_update_enabled;
|
public bool $is_auto_update_enabled;
|
||||||
public bool $is_registration_enabled;
|
public bool $is_registration_enabled;
|
||||||
|
public bool $is_dns_validation_enabled;
|
||||||
public bool $next_channel;
|
public bool $next_channel;
|
||||||
protected string $dynamic_config_path = '/data/coolify/proxy/dynamic';
|
protected string $dynamic_config_path = '/data/coolify/proxy/dynamic';
|
||||||
protected Server $server;
|
protected Server $server;
|
||||||
@@ -24,12 +25,14 @@ class Configuration extends Component
|
|||||||
'settings.resale_license' => 'nullable',
|
'settings.resale_license' => 'nullable',
|
||||||
'settings.public_port_min' => 'required',
|
'settings.public_port_min' => 'required',
|
||||||
'settings.public_port_max' => 'required',
|
'settings.public_port_max' => 'required',
|
||||||
|
'settings.custom_dns_servers' => 'nullable',
|
||||||
];
|
];
|
||||||
protected $validationAttributes = [
|
protected $validationAttributes = [
|
||||||
'settings.fqdn' => 'FQDN',
|
'settings.fqdn' => 'FQDN',
|
||||||
'settings.resale_license' => 'Resale License',
|
'settings.resale_license' => 'Resale License',
|
||||||
'settings.public_port_min' => 'Public port min',
|
'settings.public_port_min' => 'Public port min',
|
||||||
'settings.public_port_max' => 'Public port max',
|
'settings.public_port_max' => 'Public port max',
|
||||||
|
'settings.custom_dns_servers' => 'Custom DNS servers',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
@@ -38,6 +41,7 @@ class Configuration extends Component
|
|||||||
$this->is_auto_update_enabled = $this->settings->is_auto_update_enabled;
|
$this->is_auto_update_enabled = $this->settings->is_auto_update_enabled;
|
||||||
$this->is_registration_enabled = $this->settings->is_registration_enabled;
|
$this->is_registration_enabled = $this->settings->is_registration_enabled;
|
||||||
$this->next_channel = $this->settings->next_channel;
|
$this->next_channel = $this->settings->next_channel;
|
||||||
|
$this->is_dns_validation_enabled = $this->settings->is_dns_validation_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function instantSave()
|
public function instantSave()
|
||||||
@@ -45,6 +49,7 @@ class Configuration extends Component
|
|||||||
$this->settings->do_not_track = $this->do_not_track;
|
$this->settings->do_not_track = $this->do_not_track;
|
||||||
$this->settings->is_auto_update_enabled = $this->is_auto_update_enabled;
|
$this->settings->is_auto_update_enabled = $this->is_auto_update_enabled;
|
||||||
$this->settings->is_registration_enabled = $this->is_registration_enabled;
|
$this->settings->is_registration_enabled = $this->is_registration_enabled;
|
||||||
|
$this->settings->is_dns_validation_enabled = $this->is_dns_validation_enabled;
|
||||||
if ($this->next_channel) {
|
if ($this->next_channel) {
|
||||||
$this->settings->next_channel = false;
|
$this->settings->next_channel = false;
|
||||||
$this->next_channel = false;
|
$this->next_channel = false;
|
||||||
@@ -63,6 +68,14 @@ class Configuration extends Component
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->validate();
|
$this->validate();
|
||||||
|
|
||||||
|
$this->settings->custom_dns_servers = str($this->settings->custom_dns_servers)->replaceEnd(',', '')->trim();
|
||||||
|
$this->settings->custom_dns_servers = str($this->settings->custom_dns_servers)->trim()->explode(',')->map(function ($dns) {
|
||||||
|
return str($dns)->trim()->lower();
|
||||||
|
});
|
||||||
|
$this->settings->custom_dns_servers = $this->settings->custom_dns_servers->unique();
|
||||||
|
$this->settings->custom_dns_servers = $this->settings->custom_dns_servers->implode(',');
|
||||||
|
|
||||||
$this->settings->save();
|
$this->settings->save();
|
||||||
$this->server = Server::findOrFail(0);
|
$this->server = Server::findOrFail(0);
|
||||||
$this->setup_instance_fqdn();
|
$this->setup_instance_fqdn();
|
||||||
|
|||||||
38
app/Livewire/Settings/Index.php
Normal file
38
app/Livewire/Settings/Index.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Settings;
|
||||||
|
|
||||||
|
use App\Models\InstanceSettings;
|
||||||
|
use App\Models\S3Storage;
|
||||||
|
use App\Models\StandalonePostgresql;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Index extends Component
|
||||||
|
{
|
||||||
|
public InstanceSettings $settings;
|
||||||
|
public StandalonePostgresql $database;
|
||||||
|
public $s3s;
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
if (isInstanceAdmin()) {
|
||||||
|
$settings = InstanceSettings::get();
|
||||||
|
$database = StandalonePostgresql::whereName('coolify-db')->first();
|
||||||
|
$s3s = S3Storage::whereTeamId(0)->get() ?? [];
|
||||||
|
if ($database) {
|
||||||
|
if ($database->status !== 'running') {
|
||||||
|
$database->status = 'running';
|
||||||
|
$database->save();
|
||||||
|
}
|
||||||
|
$this->database = $database;
|
||||||
|
}
|
||||||
|
$this->settings = $settings;
|
||||||
|
$this->s3s = $s3s;
|
||||||
|
} else {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.settings.index');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Livewire;
|
namespace App\Livewire\Settings;
|
||||||
|
|
||||||
use App\Actions\License\CheckResaleLicense;
|
use App\Actions\License\CheckResaleLicense;
|
||||||
use App\Models\InstanceSettings;
|
use App\Models\InstanceSettings;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class CheckLicense extends Component
|
class License extends Component
|
||||||
{
|
{
|
||||||
public InstanceSettings|null $settings = null;
|
public InstanceSettings $settings;
|
||||||
public string|null $instance_id = null;
|
public string|null $instance_id = null;
|
||||||
|
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'settings.resale_license' => 'nullable',
|
'settings.resale_license' => 'nullable',
|
||||||
'settings.is_resale_license_active' => 'nullable',
|
'settings.is_resale_license_active' => 'nullable',
|
||||||
@@ -20,12 +21,17 @@ class CheckLicense extends Component
|
|||||||
'settings.is_resale_license_active' => 'Is License Active',
|
'settings.is_resale_license_active' => 'Is License Active',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function mount()
|
public function mount () {
|
||||||
{
|
if (!isCloud()) {
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
$this->instance_id = config('app.id');
|
$this->instance_id = config('app.id');
|
||||||
$this->settings = InstanceSettings::get();
|
$this->settings = InstanceSettings::get();
|
||||||
}
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.settings.license')->layout('layouts.subscription');
|
||||||
|
}
|
||||||
public function submit()
|
public function submit()
|
||||||
{
|
{
|
||||||
$this->validate();
|
$this->validate();
|
||||||
@@ -6,7 +6,7 @@ use App\Models\InstanceSettings;
|
|||||||
use App\Providers\RouteServiceProvider;
|
use App\Providers\RouteServiceProvider;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class Show extends Component
|
class Index extends Component
|
||||||
{
|
{
|
||||||
public InstanceSettings $settings;
|
public InstanceSettings $settings;
|
||||||
public bool $alreadySubscribed = false;
|
public bool $alreadySubscribed = false;
|
||||||
@@ -26,6 +26,6 @@ class Show extends Component
|
|||||||
}
|
}
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return view('livewire.subscription.show')->layout('layouts.subscription');
|
return view('livewire.subscription.index')->layout('layouts.subscription');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Livewire\Team;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Livewire\Component;
|
|
||||||
|
|
||||||
class Delete extends Component
|
|
||||||
{
|
|
||||||
public function delete()
|
|
||||||
{
|
|
||||||
$currentTeam = currentTeam();
|
|
||||||
$currentTeam->delete();
|
|
||||||
|
|
||||||
$currentTeam->members->each(function ($user) use ($currentTeam) {
|
|
||||||
if ($user->id === auth()->user()->id) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$user->teams()->detach($currentTeam);
|
|
||||||
$session = DB::table('sessions')->where('user_id', $user->id)->first();
|
|
||||||
if ($session) {
|
|
||||||
DB::table('sessions')->where('id', $session->id)->delete();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
refreshSession();
|
|
||||||
return redirect()->route('team.index');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Livewire\Team;
|
|
||||||
|
|
||||||
use App\Models\Team;
|
|
||||||
use Livewire\Component;
|
|
||||||
|
|
||||||
class Form extends Component
|
|
||||||
{
|
|
||||||
public Team $team;
|
|
||||||
protected $rules = [
|
|
||||||
'team.name' => 'required|min:3|max:255',
|
|
||||||
'team.description' => 'nullable|min:3|max:255',
|
|
||||||
];
|
|
||||||
protected $validationAttributes = [
|
|
||||||
'team.name' => 'name',
|
|
||||||
'team.description' => 'description',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function mount()
|
|
||||||
{
|
|
||||||
$this->team = currentTeam();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function submit()
|
|
||||||
{
|
|
||||||
$this->validate();
|
|
||||||
try {
|
|
||||||
$this->team->save();
|
|
||||||
refreshSession();
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
return handleError($e, $this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
65
app/Livewire/Team/Index.php
Normal file
65
app/Livewire/Team/Index.php
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Team;
|
||||||
|
|
||||||
|
use App\Models\Team;
|
||||||
|
use App\Models\TeamInvitation;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Index extends Component
|
||||||
|
{
|
||||||
|
public $invitations = [];
|
||||||
|
public Team $team;
|
||||||
|
protected $rules = [
|
||||||
|
'team.name' => 'required|min:3|max:255',
|
||||||
|
'team.description' => 'nullable|min:3|max:255',
|
||||||
|
];
|
||||||
|
protected $validationAttributes = [
|
||||||
|
'team.name' => 'name',
|
||||||
|
'team.description' => 'description',
|
||||||
|
];
|
||||||
|
public function mount() {
|
||||||
|
$this->team = currentTeam();
|
||||||
|
|
||||||
|
if (auth()->user()->isAdminFromSession()) {
|
||||||
|
$this->invitations = TeamInvitation::whereTeamId(currentTeam()->id)->get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.team.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function submit()
|
||||||
|
{
|
||||||
|
$this->validate();
|
||||||
|
try {
|
||||||
|
$this->team->save();
|
||||||
|
refreshSession();
|
||||||
|
$this->dispatch('success', 'Team updated successfully.');
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete()
|
||||||
|
{
|
||||||
|
$currentTeam = currentTeam();
|
||||||
|
$currentTeam->delete();
|
||||||
|
|
||||||
|
$currentTeam->members->each(function ($user) use ($currentTeam) {
|
||||||
|
if ($user->id === auth()->user()->id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$user->teams()->detach($currentTeam);
|
||||||
|
$session = DB::table('sessions')->where('user_id', $user->id)->first();
|
||||||
|
if ($session) {
|
||||||
|
DB::table('sessions')->where('id', $session->id)->delete();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
refreshSession();
|
||||||
|
return redirect()->route('team.index');
|
||||||
|
}
|
||||||
|
}
|
||||||
20
app/Livewire/Team/Member/Index.php
Normal file
20
app/Livewire/Team/Member/Index.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Team\Member;
|
||||||
|
|
||||||
|
use App\Models\TeamInvitation;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Index extends Component
|
||||||
|
{
|
||||||
|
public $invitations = [];
|
||||||
|
public function mount() {
|
||||||
|
if (auth()->user()->isAdminFromSession()) {
|
||||||
|
$this->invitations = TeamInvitation::whereTeamId(currentTeam()->id)->get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.team.member.index');
|
||||||
|
}
|
||||||
|
}
|
||||||
13
app/Livewire/Team/Notification/Index.php
Normal file
13
app/Livewire/Team/Notification/Index.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Team\Notification;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Index extends Component
|
||||||
|
{
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.team.notification.index');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -65,7 +65,7 @@ class Create extends Component
|
|||||||
$this->storage->team_id = currentTeam()->id;
|
$this->storage->team_id = currentTeam()->id;
|
||||||
$this->storage->testConnection();
|
$this->storage->testConnection();
|
||||||
$this->storage->save();
|
$this->storage->save();
|
||||||
return redirect()->route('team.storages.show', $this->storage->uuid);
|
return redirect()->route('team.storage.show', $this->storage->uuid);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return handleError($e, $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class Form extends Component
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->storage->delete();
|
$this->storage->delete();
|
||||||
return redirect()->route('team.storages.all');
|
return redirect()->route('team.storage.index');
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return handleError($e, $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
|
|||||||
18
app/Livewire/Team/Storage/Index.php
Normal file
18
app/Livewire/Team/Storage/Index.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Team\Storage;
|
||||||
|
|
||||||
|
use App\Models\S3Storage;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Index extends Component
|
||||||
|
{
|
||||||
|
public $s3;
|
||||||
|
public function mount() {
|
||||||
|
$this->s3 = S3Storage::ownedByCurrentTeam()->get();
|
||||||
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.team.storage.index');
|
||||||
|
}
|
||||||
|
}
|
||||||
22
app/Livewire/Team/Storage/Show.php
Normal file
22
app/Livewire/Team/Storage/Show.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Team\Storage;
|
||||||
|
|
||||||
|
use App\Models\S3Storage;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Show extends Component
|
||||||
|
{
|
||||||
|
public $storage = null;
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
$this->storage = S3Storage::ownedByCurrentTeam()->whereUuid(request()->storage_uuid)->first();
|
||||||
|
if (!$this->storage) {
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.team.storage.show');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -315,6 +315,11 @@ class Application extends BaseModel
|
|||||||
return $this->hasMany(EnvironmentVariable::class)->where('is_preview', true)->where('key', 'like', 'NIXPACKS_%');
|
return $this->hasMany(EnvironmentVariable::class)->where('is_preview', true)->where('key', 'like', 'NIXPACKS_%');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scheduled_tasks(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(ScheduledTask::class)->orderBy('name', 'asc');
|
||||||
|
}
|
||||||
|
|
||||||
public function private_key()
|
public function private_key()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(PrivateKey::class);
|
return $this->belongsTo(PrivateKey::class);
|
||||||
@@ -424,7 +429,7 @@ class Application extends BaseModel
|
|||||||
}
|
}
|
||||||
public function isConfigurationChanged($save = false)
|
public function isConfigurationChanged($save = false)
|
||||||
{
|
{
|
||||||
$newConfigHash = $this->fqdn . $this->git_repository . $this->git_branch . $this->git_commit_sha . $this->build_pack . $this->static_image . $this->install_command . $this->build_command . $this->start_command . $this->port_exposes . $this->port_mappings . $this->base_directory . $this->publish_directory . $this->health_check_path . $this->health_check_port . $this->health_check_host . $this->health_check_method . $this->health_check_return_code . $this->health_check_scheme . $this->health_check_response_text . $this->health_check_interval . $this->health_check_timeout . $this->health_check_retries . $this->health_check_start_period . $this->health_check_enabled . $this->limits_memory . $this->limits_swap . $this->limits_swappiness . $this->limits_reservation . $this->limits_cpus . $this->limits_cpuset . $this->limits_cpu_shares . $this->dockerfile . $this->dockerfile_location . $this->custom_labels;
|
$newConfigHash = $this->fqdn . $this->git_repository . $this->git_branch . $this->git_commit_sha . $this->build_pack . $this->static_image . $this->install_command . $this->build_command . $this->start_command . $this->port_exposes . $this->port_mappings . $this->base_directory . $this->publish_directory . $this->dockerfile . $this->dockerfile_location . $this->custom_labels;
|
||||||
if ($this->pull_request_id === 0 || $this->pull_request_id === null) {
|
if ($this->pull_request_id === 0 || $this->pull_request_id === null) {
|
||||||
$newConfigHash .= json_encode($this->environment_variables->all());
|
$newConfigHash .= json_encode($this->environment_variables->all());
|
||||||
} else {
|
} else {
|
||||||
@@ -637,7 +642,6 @@ class Application extends BaseModel
|
|||||||
'mem_swappiness' => $this->limits_memory_swappiness,
|
'mem_swappiness' => $this->limits_memory_swappiness,
|
||||||
'mem_reservation' => $this->limits_memory_reservation,
|
'mem_reservation' => $this->limits_memory_reservation,
|
||||||
'cpus' => (float) $this->limits_cpus,
|
'cpus' => (float) $this->limits_cpus,
|
||||||
'cpuset' => $this->limits_cpuset,
|
|
||||||
'cpu_shares' => $this->limits_cpu_shares,
|
'cpu_shares' => $this->limits_cpu_shares,
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@@ -649,6 +653,9 @@ class Application extends BaseModel
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
if (!is_null($this->limits_cpuset)) {
|
||||||
|
data_set($docker_compose, "services.{$container_name}.cpuset", $this->limits_cpuset);
|
||||||
|
}
|
||||||
if ($server->isSwarm()) {
|
if ($server->isSwarm()) {
|
||||||
data_forget($docker_compose, 'services.' . $container_name . '.container_name');
|
data_forget($docker_compose, 'services.' . $container_name . '.container_name');
|
||||||
data_forget($docker_compose, 'services.' . $container_name . '.expose');
|
data_forget($docker_compose, 'services.' . $container_name . '.expose');
|
||||||
@@ -755,7 +762,6 @@ class Application extends BaseModel
|
|||||||
// if (count($this->ports_mappings_array) > 0) {
|
// if (count($this->ports_mappings_array) > 0) {
|
||||||
// $deployment->addLogEntry('Application has ports mapped to the host system, rolling update is not supported.');
|
// $deployment->addLogEntry('Application has ports mapped to the host system, rolling update is not supported.');
|
||||||
$containers = getCurrentApplicationContainerStatus($server, $this->id, $pullRequestId);
|
$containers = getCurrentApplicationContainerStatus($server, $this->id, $pullRequestId);
|
||||||
ray($containers);
|
|
||||||
// if ($pullRequestId === 0) {
|
// if ($pullRequestId === 0) {
|
||||||
// $containers = $containers->filter(function ($container) use ($containerName) {
|
// $containers = $containers->filter(function ($container) use ($containerName) {
|
||||||
// return data_get($container, 'Names') !== $containerName;
|
// return data_get($container, 'Names') !== $containerName;
|
||||||
@@ -867,7 +873,6 @@ class Application extends BaseModel
|
|||||||
} else {
|
} else {
|
||||||
$git_clone_command = $this->setGitImportSettings($deployment_uuid, $git_clone_command_base);
|
$git_clone_command = $this->setGitImportSettings($deployment_uuid, $git_clone_command_base);
|
||||||
}
|
}
|
||||||
ray($git_clone_command);
|
|
||||||
if ($exec_in_docker) {
|
if ($exec_in_docker) {
|
||||||
$commands = collect([
|
$commands = collect([
|
||||||
executeInDocker($deployment_uuid, "mkdir -p /root/.ssh"),
|
executeInDocker($deployment_uuid, "mkdir -p /root/.ssh"),
|
||||||
@@ -1061,7 +1066,7 @@ class Application extends BaseModel
|
|||||||
$customLabels = base64_decode($this->custom_labels);
|
$customLabels = base64_decode($this->custom_labels);
|
||||||
if (mb_detect_encoding($customLabels, 'ASCII', true) === false) {
|
if (mb_detect_encoding($customLabels, 'ASCII', true) === false) {
|
||||||
ray('custom_labels contains non-ascii characters');
|
ray('custom_labels contains non-ascii characters');
|
||||||
$customLabels = str(implode(",", generateLabelsApplication($this, $preview)))->replace(',', "\n");
|
$customLabels = str(implode("|", generateLabelsApplication($this, $preview)))->replace("|", "\n");
|
||||||
}
|
}
|
||||||
$this->custom_labels = base64_encode($customLabels);
|
$this->custom_labels = base64_encode($customLabels);
|
||||||
$this->save();
|
$this->save();
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class S3Storage extends BaseModel
|
|||||||
if ($this->unusable_email_sent === false && is_transactional_emails_active()) {
|
if ($this->unusable_email_sent === false && is_transactional_emails_active()) {
|
||||||
$mail = new MailMessage();
|
$mail = new MailMessage();
|
||||||
$mail->subject('Coolify: S3 Storage Connection Error');
|
$mail->subject('Coolify: S3 Storage Connection Error');
|
||||||
$mail->view('emails.s3-connection-error', ['name' => $this->name, 'reason' => $e->getMessage(), 'url' => route('team.storages.show', ['storage_uuid' => $this->uuid])]);
|
$mail->view('emails.s3-connection-error', ['name' => $this->name, 'reason' => $e->getMessage(), 'url' => route('team.storage.show', ['storage_uuid' => $this->uuid])]);
|
||||||
$users = collect([]);
|
$users = collect([]);
|
||||||
$members = $this->team->members()->get();
|
$members = $this->team->members()->get();
|
||||||
foreach ($members as $user) {
|
foreach ($members as $user) {
|
||||||
|
|||||||
28
app/Models/ScheduledTask.php
Normal file
28
app/Models/ScheduledTask.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
|
|
||||||
|
class ScheduledTask extends BaseModel
|
||||||
|
{
|
||||||
|
protected $guarded = [];
|
||||||
|
|
||||||
|
public function service()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Service::class);
|
||||||
|
}
|
||||||
|
public function application()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Application::class);
|
||||||
|
}
|
||||||
|
public function latest_log(): HasOne
|
||||||
|
{
|
||||||
|
return $this->hasOne(ScheduledTaskExecution::class)->latest();
|
||||||
|
}
|
||||||
|
public function executions(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(ScheduledTaskExecution::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
15
app/Models/ScheduledTaskExecution.php
Normal file
15
app/Models/ScheduledTaskExecution.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
class ScheduledTaskExecution extends BaseModel
|
||||||
|
{
|
||||||
|
protected $guarded = [];
|
||||||
|
|
||||||
|
public function scheduledTask(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(ScheduledTask::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -71,7 +71,7 @@ class Server extends BaseModel
|
|||||||
|
|
||||||
static public function isUsable()
|
static public function isUsable()
|
||||||
{
|
{
|
||||||
return Server::ownedByCurrentTeam()->whereRelation('settings', 'is_reachable', true)->whereRelation('settings', 'is_usable', true)->whereRelation('settings', 'is_swarm_worker', false);
|
return Server::ownedByCurrentTeam()->whereRelation('settings', 'is_reachable', true)->whereRelation('settings', 'is_usable', true)->whereRelation('settings', 'is_swarm_worker', false)->whereRelation('settings', 'is_build_server', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function destinationsByServer(string $server_id)
|
static public function destinationsByServer(string $server_id)
|
||||||
@@ -112,7 +112,7 @@ class Server extends BaseModel
|
|||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
StandaloneDocker::create([
|
StandaloneDocker::create([
|
||||||
'name' => 'coolify-overlay',
|
'name' => 'coolify',
|
||||||
'network' => 'coolify',
|
'network' => 'coolify',
|
||||||
'server_id' => $this->id,
|
'server_id' => $this->id,
|
||||||
]);
|
]);
|
||||||
@@ -141,6 +141,10 @@ class Server extends BaseModel
|
|||||||
{
|
{
|
||||||
return $this->ip === 'host.docker.internal' || $this->id === 0;
|
return $this->ip === 'host.docker.internal' || $this->id === 0;
|
||||||
}
|
}
|
||||||
|
static public function buildServers($teamId)
|
||||||
|
{
|
||||||
|
return Server::whereTeamId($teamId)->whereRelation('settings', 'is_reachable', true)->whereRelation('settings', 'is_build_server', true);
|
||||||
|
}
|
||||||
public function skipServer()
|
public function skipServer()
|
||||||
{
|
{
|
||||||
if ($this->ip === '1.2.3.4') {
|
if ($this->ip === '1.2.3.4') {
|
||||||
@@ -194,7 +198,7 @@ class Server extends BaseModel
|
|||||||
foreach ($this->databases() as $database) {
|
foreach ($this->databases() as $database) {
|
||||||
$database->update(['status' => 'exited']);
|
$database->update(['status' => 'exited']);
|
||||||
}
|
}
|
||||||
foreach ($this->services() as $service) {
|
foreach ($this->services()->get() as $service) {
|
||||||
$apps = $service->applications()->get();
|
$apps = $service->applications()->get();
|
||||||
$dbs = $service->databases()->get();
|
$dbs = $service->databases()->get();
|
||||||
foreach ($apps as $app) {
|
foreach ($apps as $app) {
|
||||||
@@ -328,7 +332,7 @@ class Server extends BaseModel
|
|||||||
}
|
}
|
||||||
public function isProxyShouldRun()
|
public function isProxyShouldRun()
|
||||||
{
|
{
|
||||||
if ($this->proxyType() === ProxyTypes::NONE->value) {
|
if ($this->proxyType() === ProxyTypes::NONE->value || $this->settings->is_build_server) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// foreach ($this->applications() as $application) {
|
// foreach ($this->applications() as $application) {
|
||||||
@@ -358,10 +362,10 @@ class Server extends BaseModel
|
|||||||
public function validateOS(): bool | Stringable
|
public function validateOS(): bool | Stringable
|
||||||
{
|
{
|
||||||
$os_release = instant_remote_process(['cat /etc/os-release'], $this);
|
$os_release = instant_remote_process(['cat /etc/os-release'], $this);
|
||||||
$datas = collect(explode("\n", $os_release));
|
$releaseLines = collect(explode("\n", $os_release));
|
||||||
$collectedData = collect([]);
|
$collectedData = collect([]);
|
||||||
foreach ($datas as $data) {
|
foreach ($releaseLines as $line) {
|
||||||
$item = Str::of($data)->trim();
|
$item = Str::of($line)->trim();
|
||||||
$collectedData->put($item->before('=')->value(), $item->after('=')->lower()->replace('"', '')->value());
|
$collectedData->put($item->before('=')->value(), $item->after('=')->lower()->replace('"', '')->value());
|
||||||
}
|
}
|
||||||
$ID = data_get($collectedData, 'ID');
|
$ID = data_get($collectedData, 'ID');
|
||||||
@@ -436,7 +440,7 @@ class Server extends BaseModel
|
|||||||
}
|
}
|
||||||
$this->settings->is_usable = true;
|
$this->settings->is_usable = true;
|
||||||
$this->settings->save();
|
$this->settings->save();
|
||||||
$this->validateCoolifyNetwork(isSwarm: false);
|
$this->validateCoolifyNetwork(isSwarm: false, isBuildServer: $this->settings->is_build_server);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public function validateDockerSwarm()
|
public function validateDockerSwarm()
|
||||||
@@ -466,8 +470,11 @@ class Server extends BaseModel
|
|||||||
$this->settings->save();
|
$this->settings->save();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public function validateCoolifyNetwork($isSwarm = false)
|
public function validateCoolifyNetwork($isSwarm = false, $isBuildServer = false)
|
||||||
{
|
{
|
||||||
|
if ($isBuildServer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ($isSwarm) {
|
if ($isSwarm) {
|
||||||
return instant_remote_process(["docker network create --attachable --driver overlay coolify-overlay >/dev/null 2>&1 || true"], $this, false);
|
return instant_remote_process(["docker network create --attachable --driver overlay coolify-overlay >/dev/null 2>&1 || true"], $this, false);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -396,6 +396,10 @@ class Service extends BaseModel
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
public function scheduled_tasks(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(ScheduledTask::class)->orderBy('name', 'asc');
|
||||||
|
}
|
||||||
public function environment_variables(): HasMany
|
public function environment_variables(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(EnvironmentVariable::class)->orderBy('key', 'asc');
|
return $this->hasMany(EnvironmentVariable::class)->orderBy('key', 'asc');
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ class EmailChannel
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->bootConfigs($notifiable);
|
$this->bootConfigs($notifiable);
|
||||||
$recepients = $notifiable->getRecepients($notification);
|
$recipients = $notifiable->getRecepients($notification);
|
||||||
if (count($recepients) === 0) {
|
if (count($recipients) === 0) {
|
||||||
throw new Exception('No email recipients found');
|
throw new Exception('No email recipients found');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ class EmailChannel
|
|||||||
[],
|
[],
|
||||||
[],
|
[],
|
||||||
fn (Message $message) => $message
|
fn (Message $message) => $message
|
||||||
->to($recepients)
|
->to($recipients)
|
||||||
->subject($mailMessage->subject)
|
->subject($mailMessage->subject)
|
||||||
->html((string)$mailMessage->render())
|
->html((string)$mailMessage->render())
|
||||||
);
|
);
|
||||||
@@ -35,8 +35,8 @@ class EmailChannel
|
|||||||
}
|
}
|
||||||
ray($e->getMessage());
|
ray($e->getMessage());
|
||||||
$message = "EmailChannel error: {$e->getMessage()}. Failed to send email to:";
|
$message = "EmailChannel error: {$e->getMessage()}. Failed to send email to:";
|
||||||
if (isset($recepients)) {
|
if (isset($recipients)) {
|
||||||
$message .= implode(', ', $recepients);
|
$message .= implode(', ', $recipients);
|
||||||
}
|
}
|
||||||
if (isset($mailMessage)) {
|
if (isset($mailMessage)) {
|
||||||
$message .= " with subject: {$mailMessage->subject}";
|
$message .= " with subject: {$mailMessage->subject}";
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class ContainerRestarted extends Notification implements ShouldQueue
|
|||||||
public function toMail(): MailMessage
|
public function toMail(): MailMessage
|
||||||
{
|
{
|
||||||
$mail = new MailMessage();
|
$mail = new MailMessage();
|
||||||
$mail->subject("Coolify: A service ({$this->name}) has been restarted automatically on {$this->server->name}");
|
$mail->subject("Coolify: A resource ({$this->name}) has been restarted automatically on {$this->server->name}");
|
||||||
$mail->view('emails.container-restarted', [
|
$mail->view('emails.container-restarted', [
|
||||||
'containerName' => $this->name,
|
'containerName' => $this->name,
|
||||||
'serverName' => $this->server->name,
|
'serverName' => $this->server->name,
|
||||||
@@ -38,12 +38,12 @@ class ContainerRestarted extends Notification implements ShouldQueue
|
|||||||
|
|
||||||
public function toDiscord(): string
|
public function toDiscord(): string
|
||||||
{
|
{
|
||||||
$message = "Coolify: A service ({$this->name}) has been restarted automatically on {$this->server->name}";
|
$message = "Coolify: A resource ({$this->name}) has been restarted automatically on {$this->server->name}";
|
||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
public function toTelegram(): array
|
public function toTelegram(): array
|
||||||
{
|
{
|
||||||
$message = "Coolify: A service ({$this->name}) has been restarted automatically on {$this->server->name}";
|
$message = "Coolify: A resource ({$this->name}) has been restarted automatically on {$this->server->name}";
|
||||||
$payload = [
|
$payload = [
|
||||||
"message" => $message,
|
"message" => $message,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class ContainerStopped extends Notification implements ShouldQueue
|
|||||||
public function toMail(): MailMessage
|
public function toMail(): MailMessage
|
||||||
{
|
{
|
||||||
$mail = new MailMessage();
|
$mail = new MailMessage();
|
||||||
$mail->subject("Coolify: A service ({$this->name}) has been stopped on {$this->server->name}");
|
$mail->subject("Coolify: A resource has been stopped unexpectedly on {$this->server->name}");
|
||||||
$mail->view('emails.container-stopped', [
|
$mail->view('emails.container-stopped', [
|
||||||
'containerName' => $this->name,
|
'containerName' => $this->name,
|
||||||
'serverName' => $this->server->name,
|
'serverName' => $this->server->name,
|
||||||
@@ -37,12 +37,12 @@ class ContainerStopped extends Notification implements ShouldQueue
|
|||||||
|
|
||||||
public function toDiscord(): string
|
public function toDiscord(): string
|
||||||
{
|
{
|
||||||
$message = "Coolify: A service ({$this->name}) has been stopped on {$this->server->name}";
|
$message = "Coolify: A resource has been stopped unexpectedly on {$this->server->name}";
|
||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
public function toTelegram(): array
|
public function toTelegram(): array
|
||||||
{
|
{
|
||||||
$message = "Coolify: A service ($this->name} has been stopped on {$this->server->name}";
|
$message = "Coolify: A resource has been stopped unexpectedly on {$this->server->name}";
|
||||||
$payload = [
|
$payload = [
|
||||||
"message" => $message,
|
"message" => $message,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -52,13 +52,13 @@ class Unreachable extends Notification implements ShouldQueue
|
|||||||
|
|
||||||
public function toDiscord(): string
|
public function toDiscord(): string
|
||||||
{
|
{
|
||||||
$message = "Coolify: Your server '{$this->server->name}' is unreachable. All automations & integrations are turned off! Please check your server! IMPORTANT: We automatically try to revive your server. If your server is back online, we will automatically turn on all automations & integrations.";
|
$message = "Coolify: Your server '{$this->server->name}' is unreachable. All automations & integrations are turned off! Please check your server! IMPORTANT: We automatically try to revive your server and turn on all automations & integrations.";
|
||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
public function toTelegram(): array
|
public function toTelegram(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
"message" => "Coolify: Your server '{$this->server->name}' is unreachable. All automations & integrations are turned off! Please check your server! IMPORTANT: We automatically try to revive your server. If your server is back online, we will automatically turn on all automations & integrations."
|
"message" => "Coolify: Your server '{$this->server->name}' is unreachable. All automations & integrations are turned off! Please check your server! IMPORTANT: We automatically try to revive your server and turn on all automations & integrations."
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user