Merge remote-tracking branch 'origin/v4-next' into patricio-deploy-proxy
This commit is contained in:
commit
7c13a92d9a
@ -37,6 +37,7 @@ public function handle()
|
|||||||
$compose_file = "docker-compose.yml";
|
$compose_file = "docker-compose.yml";
|
||||||
$compose_file_prod = "docker-compose.prod.yml";
|
$compose_file_prod = "docker-compose.prod.yml";
|
||||||
$upgrade_script = "upgrade.sh";
|
$upgrade_script = "upgrade.sh";
|
||||||
|
$docker_install_script = "install-docker.sh";
|
||||||
$production_env = ".env.production";
|
$production_env = ".env.production";
|
||||||
|
|
||||||
PendingRequest::macro('storage', function ($file) {
|
PendingRequest::macro('storage', function ($file) {
|
||||||
@ -53,8 +54,9 @@ public function handle()
|
|||||||
Http::pool(fn (Pool $pool) => [
|
Http::pool(fn (Pool $pool) => [
|
||||||
$pool->storage(file: "$parent_dir/$compose_file")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$compose_file"),
|
$pool->storage(file: "$parent_dir/$compose_file")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$compose_file"),
|
||||||
$pool->storage(file: "$parent_dir/$compose_file_prod")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$compose_file_prod"),
|
$pool->storage(file: "$parent_dir/$compose_file_prod")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$compose_file_prod"),
|
||||||
$pool->storage(file: "$parent_dir/scripts/$upgrade_script")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$upgrade_script"),
|
|
||||||
$pool->storage(file: "$parent_dir/$production_env")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$production_env"),
|
$pool->storage(file: "$parent_dir/$production_env")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$production_env"),
|
||||||
|
$pool->storage(file: "$parent_dir/scripts/$upgrade_script")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$upgrade_script"),
|
||||||
|
$pool->storage(file: "$parent_dir/scripts/$docker_install_script")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$docker_install_script"),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$res = Http::withHeaders([
|
$res = Http::withHeaders([
|
||||||
@ -64,13 +66,15 @@ public function handle()
|
|||||||
"url" => "$bunny_cdn/$bunny_cdn_path/$compose_file",
|
"url" => "$bunny_cdn/$bunny_cdn_path/$compose_file",
|
||||||
"url" => "$bunny_cdn/$bunny_cdn_path/$compose_file_prod",
|
"url" => "$bunny_cdn/$bunny_cdn_path/$compose_file_prod",
|
||||||
"url" => "$bunny_cdn/$bunny_cdn_path/$upgrade_script",
|
"url" => "$bunny_cdn/$bunny_cdn_path/$upgrade_script",
|
||||||
"url" => "$bunny_cdn/$bunny_cdn_path/$production_env"
|
"url" => "$bunny_cdn/$bunny_cdn_path/$production_env",
|
||||||
|
"url" => "$bunny_cdn/$bunny_cdn_path/$docker_install_script"
|
||||||
]);
|
]);
|
||||||
if ($res->ok()) {
|
if ($res->ok()) {
|
||||||
echo "All files uploaded & purged...\n";
|
echo "All files uploaded & purged...\n";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
throw new \Exception("Something went wrong.");
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
echo "Something went wrong.\n";
|
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public function submit()
|
|||||||
|
|
||||||
$server = Server::find($this->server_id);
|
$server = Server::find($this->server_id);
|
||||||
|
|
||||||
instantRemoteProcess($server, ['docker network create --attachable ' . $this->network], throwError: false);
|
instantRemoteProcess(['docker network create --attachable ' . $this->network], $server, throwError: false);
|
||||||
return redirect()->route('destination.show', $docker->uuid);
|
return redirect()->route('destination.show', $docker->uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,15 +10,14 @@ class ForceUpgrade extends Component
|
|||||||
{
|
{
|
||||||
public function upgrade()
|
public function upgrade()
|
||||||
{
|
{
|
||||||
//if (env('APP_ENV') === 'local') {
|
|
||||||
if (config('app.env') === 'local') {
|
if (config('app.env') === 'local') {
|
||||||
$server = Server::where('ip', 'coolify-testing-host')->first();
|
$server = Server::where('ip', 'coolify-testing-host')->first();
|
||||||
if (!$server) {
|
if (!$server) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
instantRemoteProcess($server, [
|
instantRemoteProcess([
|
||||||
"sleep 2"
|
"sleep 2"
|
||||||
]);
|
], $server);
|
||||||
remoteProcess([
|
remoteProcess([
|
||||||
"sleep 10"
|
"sleep 10"
|
||||||
], $server, ActivityTypes::INLINE->value);
|
], $server, ActivityTypes::INLINE->value);
|
||||||
@ -32,15 +31,16 @@ public function upgrade()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
instantRemoteProcess($server, [
|
instantRemoteProcess([
|
||||||
"curl -fsSL $cdn/docker-compose.yml -o /data/coolify/source/docker-compose.yml",
|
"curl -fsSL $cdn/docker-compose.yml -o /data/coolify/source/docker-compose.yml",
|
||||||
"curl -fsSL $cdn/docker-compose.prod.yml -o /data/coolify/source/docker-compose.prod.yml",
|
"curl -fsSL $cdn/docker-compose.prod.yml -o /data/coolify/source/docker-compose.prod.yml",
|
||||||
"curl -fsSL $cdn/.env.production -o /data/coolify/source/.env.production",
|
"curl -fsSL $cdn/.env.production -o /data/coolify/source/.env.production",
|
||||||
"curl -fsSL $cdn/upgrade.sh -o /data/coolify/source/upgrade.sh",
|
"curl -fsSL $cdn/upgrade.sh -o /data/coolify/source/upgrade.sh",
|
||||||
]);
|
], $server);
|
||||||
instantRemoteProcess($server, [
|
|
||||||
|
instantRemoteProcess([
|
||||||
"docker compose -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml pull",
|
"docker compose -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml pull",
|
||||||
]);
|
], $server);
|
||||||
|
|
||||||
remoteProcess([
|
remoteProcess([
|
||||||
"bash /data/coolify/source/upgrade.sh $latestVersion"
|
"bash /data/coolify/source/upgrade.sh $latestVersion"
|
||||||
|
@ -73,7 +73,7 @@ public function delete()
|
|||||||
}
|
}
|
||||||
public function stop()
|
public function stop()
|
||||||
{
|
{
|
||||||
instantRemoteProcess($this->destination->server, ["docker rm -f {$this->application->uuid}"]);
|
instantRemoteProcess(["docker rm -f {$this->application->uuid}"], $this->destination->server);
|
||||||
if ($this->application->status != 'exited') {
|
if ($this->application->status != 'exited') {
|
||||||
$this->application->status = 'exited';
|
$this->application->status = 'exited';
|
||||||
$this->application->save();
|
$this->application->save();
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Livewire\Server;
|
namespace App\Http\Livewire\Server;
|
||||||
|
|
||||||
|
use App\Enums\ActivityTypes;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
@ -28,15 +29,30 @@ public function mount()
|
|||||||
public function installDocker()
|
public function installDocker()
|
||||||
{
|
{
|
||||||
$config = base64_encode('{ "live-restore": true }');
|
$config = base64_encode('{ "live-restore": true }');
|
||||||
instantRemoteProcess($this->server, [
|
remoteProcess([
|
||||||
"curl https://releases.rancher.com/install-docker/23.0.sh | sh"
|
"curl https://releases.rancher.com/install-docker/23.0.sh | sh",
|
||||||
]);
|
"echo '{$config}' | base64 -d > /etc/docker/daemon.json",
|
||||||
|
"systemctl restart docker"
|
||||||
|
], $this->server, ActivityTypes::INLINE->value);
|
||||||
}
|
}
|
||||||
public function checkServer()
|
public function checkServer()
|
||||||
{
|
{
|
||||||
$this->uptime = instantRemoteProcess($this->server, ['uptime']);
|
try {
|
||||||
$this->dockerVersion = instantRemoteProcess($this->server, ['docker version|head -2|grep -i version'], false);
|
$this->uptime = instantRemoteProcess(['uptime'], $this->server, false);
|
||||||
$this->dockerComposeVersion = instantRemoteProcess($this->server, ['docker compose version|head -2|grep -i version'], false);
|
if (!$this->uptime) {
|
||||||
|
$this->uptime = 'Server not reachable.';
|
||||||
|
throw new \Exception('Server not reachable.');
|
||||||
|
}
|
||||||
|
$this->dockerVersion = instantRemoteProcess(['docker version|head -2|grep -i version'], $this->server, false);
|
||||||
|
if (!$this->dockerVersion) {
|
||||||
|
$this->dockerVersion = 'Not installed.';
|
||||||
|
}
|
||||||
|
$this->dockerComposeVersion = instantRemoteProcess(['docker compose version|head -2|grep -i version'], $this->server, false);
|
||||||
|
if (!$this->dockerComposeVersion) {
|
||||||
|
$this->dockerComposeVersion = 'Not installed.';
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public function submit()
|
public function submit()
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ protected function checkAllServers()
|
|||||||
$not_found_applications = $applications;
|
$not_found_applications = $applications;
|
||||||
$containers = collect();
|
$containers = collect();
|
||||||
foreach ($servers as $server) {
|
foreach ($servers as $server) {
|
||||||
$output = instantRemoteProcess($server, ['docker ps -a -q --format \'{{json .}}\'']);
|
$output = instantRemoteProcess(['docker ps -a -q --format \'{{json .}}\''], $server);
|
||||||
$containers = $containers->concat(formatDockerCmdOutputToJson($output));
|
$containers = $containers->concat(formatDockerCmdOutputToJson($output));
|
||||||
}
|
}
|
||||||
foreach ($containers as $container) {
|
foreach ($containers as $container) {
|
||||||
@ -67,7 +67,7 @@ protected function checkContainerStatus()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($application->destination->server) {
|
if ($application->destination->server) {
|
||||||
$container = instantRemoteProcess($application->destination->server, ["docker inspect --format '{{json .State}}' {$this->container_id}"]);
|
$container = instantRemoteProcess(["docker inspect --format '{{json .State}}' {$this->container_id}"], $application->destination->server);
|
||||||
$container = formatDockerCmdOutputToJson($container);
|
$container = formatDockerCmdOutputToJson($container);
|
||||||
$application->status = $container[0]['Status'];
|
$application->status = $container[0]['Status'];
|
||||||
$application->save();
|
$application->save();
|
||||||
|
@ -31,7 +31,7 @@ public function handle(): void
|
|||||||
try {
|
try {
|
||||||
$servers = Server::all();
|
$servers = Server::all();
|
||||||
foreach ($servers as $server) {
|
foreach ($servers as $server) {
|
||||||
instantRemoteProcess($server, ['docker image prune -f']);
|
instantRemoteProcess(['docker image prune -f'], $server);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Log::error($e->getMessage());
|
Log::error($e->getMessage());
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
use Illuminate\Support\Facades\Process;
|
use Illuminate\Support\Facades\Process;
|
||||||
use Illuminate\Support\Facades\Queue;
|
use Illuminate\Support\Facades\Queue;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
@ -15,14 +16,9 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function register(): void
|
public function register(): void
|
||||||
{
|
{
|
||||||
// @TODO: Is this the best place to run the seeder?
|
if (config('app.env') === 'production' && Str::contains(config('coolify.version'), ['nightly'])) {
|
||||||
// if (env('APP_ENV') === 'production') {
|
Process::run('php artisan migrate:fresh --force --seed --seeder=ProductionSeeder');
|
||||||
// dump('Seed default data.');
|
}
|
||||||
// Process::run('php artisan db:seed --class=ProductionSeeder --force');
|
|
||||||
// } else {
|
|
||||||
// dump('Not in production environment.');
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,9 +27,8 @@ public function register(): void
|
|||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
Queue::after(function (JobProcessed $event) {
|
Queue::after(function (JobProcessed $event) {
|
||||||
// @TODO: Remove `coolify-builder` container after the remoteProcess job is finishged and remoteProcess->type == `deployment`.
|
// @TODO: Remove `coolify-builder` container after the remoteProcess job is finishged and remoteProcess->type == `deployment`.
|
||||||
if ($event->job->resolveName() === CoolifyTask::class) {
|
if ($event->job->resolveName() === CoolifyTask::class) {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ function formatDockerLabelsToJson($rawOutput): Collection
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!function_exists('instantRemoteProcess')) {
|
if (!function_exists('instantRemoteProcess')) {
|
||||||
function instantRemoteProcess(Server $server, array $command, $throwError = true)
|
function instantRemoteProcess(array $command, Server $server, $throwError = true)
|
||||||
{
|
{
|
||||||
$command_string = implode("\n", $command);
|
$command_string = implode("\n", $command);
|
||||||
$private_key_location = savePrivateKeyForServer($server);
|
$private_key_location = savePrivateKeyForServer($server);
|
||||||
|
@ -22,14 +22,17 @@
|
|||||||
Submit
|
Submit
|
||||||
</button>
|
</button>
|
||||||
<button wire:click.prevent='checkServer'>Check Server</button>
|
<button wire:click.prevent='checkServer'>Check Server</button>
|
||||||
<button wire:click.prevent='installDocker'>Install Docker</button>
|
{{-- <button wire:click.prevent='installDocker'>Install Docker</button> --}}
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@isset($uptime)
|
@isset($uptime)
|
||||||
<p>Connection OK</p>
|
|
||||||
<p>Uptime: {{ $uptime }}</p>
|
<p>Uptime: {{ $uptime }}</p>
|
||||||
<p>{{ $dockerVersion }}</p>
|
@endisset
|
||||||
<p>{{ $dockerComposeVersion }}</p>
|
@isset($dockerVersion)
|
||||||
|
<p>Docker Engine: {{ $dockerVersion }}</p>
|
||||||
|
@endisset
|
||||||
|
@isset($dockerComposeVersion)
|
||||||
|
<p>Docker Compose: {{ $dockerComposeVersion }}</p>
|
||||||
@endisset
|
@endisset
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
5
scripts/install-docker.sh
Normal file
5
scripts/install-docker.sh
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
curl https://releases.rancher.com/install-docker/23.0.sh | sh
|
||||||
|
echo "Docker installed successfully"
|
||||||
|
echo '{ "live-restore": true }' >/etc/docker/daemon.json
|
||||||
|
systemctl restart docker
|
@ -2,10 +2,12 @@
|
|||||||
## Do not modify this file. You will lost the ability to installation and autoupdate!
|
## Do not modify this file. You will lost the ability to installation and autoupdate!
|
||||||
|
|
||||||
###########
|
###########
|
||||||
## Always run "php artisan app:sync-to-bunny-cdn --env=secrets" if you update this file.
|
## Always run "php artisan app:sync-to-bunny-cdn --env=secrets" or "scripts/run sync-bunny" if you update this file.
|
||||||
###########
|
###########
|
||||||
|
|
||||||
VERSION="1.0.0"
|
VERSION="1.0.0"
|
||||||
|
DOCKER_VERSION="23.0"
|
||||||
|
|
||||||
CDN="https://coolify-cdn.b-cdn.net/files"
|
CDN="https://coolify-cdn.b-cdn.net/files"
|
||||||
OS_TYPE=$(cat /etc/os-release | grep -w "ID" | cut -d "=" -f 2 | tr -d '"')
|
OS_TYPE=$(cat /etc/os-release | grep -w "ID" | cut -d "=" -f 2 | tr -d '"')
|
||||||
OS_VERSION=$(cat /etc/os-release | grep -w "VERSION_ID" | cut -d "=" -f 2 | tr -d '"')
|
OS_VERSION=$(cat /etc/os-release | grep -w "VERSION_ID" | cut -d "=" -f 2 | tr -d '"')
|
||||||
@ -18,9 +20,7 @@ fi
|
|||||||
|
|
||||||
if ! [ -x "$(command -v docker)" ]; then
|
if ! [ -x "$(command -v docker)" ]; then
|
||||||
echo "Docker is not installed. Installing Docker..."
|
echo "Docker is not installed. Installing Docker..."
|
||||||
curl -fsSL https://get.docker.com -o get-docker.sh
|
curl https://releases.rancher.com/install-docker/${DOCKER_VERSION}.sh | sh
|
||||||
sh get-docker.sh
|
|
||||||
rm get-docker.sh
|
|
||||||
echo "Docker installed successfully"
|
echo "Docker installed successfully"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -21,8 +21,7 @@ function help {
|
|||||||
compgen -A function | cat -n
|
compgen -A function | cat -n
|
||||||
}
|
}
|
||||||
function sync-bunny {
|
function sync-bunny {
|
||||||
bash vendor/bin/spin exec -u webuser coolify php artisan sync:bunny --env=secret ||
|
php artisan sync:bunny --env=secrets
|
||||||
php artisan sync:bunny --env=secrets
|
|
||||||
}
|
}
|
||||||
function queue {
|
function queue {
|
||||||
bash vendor/bin/spin exec -u webuser coolify php artisan queue:listen
|
bash vendor/bin/spin exec -u webuser coolify php artisan queue:listen
|
||||||
|
Loading…
Reference in New Issue
Block a user