Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Ability to run AMD64 images on AMR64 servers and a few dependency fixes for remote servers #4421

Draft
wants to merge 22 commits into
base: next
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
743e234
feat: qemu for running AMD images on ARM
peaklabs-dev Nov 27, 2024
614c8ea
feat: Install the correct dependecies and configure Docker correctly.
peaklabs-dev Nov 27, 2024
bb384a2
Merge branch 'next' into fix-amd-on-arm-and-dep
peaklabs-dev Nov 27, 2024
87cde8b
remove unused code
peaklabs-dev Nov 27, 2024
e6019e0
new ValidateServer file with all validation logic in one place
peaklabs-dev Nov 27, 2024
9eda2ee
use the new functions in validate and install
peaklabs-dev Nov 27, 2024
7a8e627
new validate and install UI
peaklabs-dev Nov 27, 2024
9acc26d
install dep like in install script
peaklabs-dev Nov 27, 2024
1039ea0
return clean OS name
peaklabs-dev Nov 27, 2024
a6287fa
use listeners to go through the install
peaklabs-dev Nov 27, 2024
bb203d0
set docker version to install
peaklabs-dev Nov 27, 2024
d4e09bc
Add some error messages to translation
peaklabs-dev Nov 27, 2024
0983947
feat: new validation UI
peaklabs-dev Nov 27, 2024
c8663bb
Merge branch 'next' into fix-amd-on-arm-and-dep
peaklabs-dev Nov 28, 2024
e4a781a
Merge branch 'next' into fix-amd-on-arm-and-dep
peaklabs-dev Dec 2, 2024
a7e3f2b
Merge branch 'coollabsio:main' into fix-amd-on-arm-and-dep
peaklabs-dev Dec 4, 2024
b370864
Merge branch 'next' into fix-amd-on-arm-and-dep
peaklabs-dev Dec 4, 2024
c7114df
Merge branch 'next' into fix-amd-on-arm-and-dep
peaklabs-dev Dec 4, 2024
d9daf5a
Merge branch 'next' into fix-amd-on-arm-and-dep
peaklabs-dev Dec 4, 2024
29918ab
Merge branch 'coollabsio:main' into fix-amd-on-arm-and-dep
peaklabs-dev Dec 5, 2024
a13f952
Merge branch 'next' into fix-amd-on-arm-and-dep
peaklabs-dev Dec 9, 2024
25f5989
Merge branch 'next' into fix-amd-on-arm-and-dep
peaklabs-dev Dec 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 157 additions & 0 deletions app/Actions/Server/InstallCoolifyDependencies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<?php

namespace App\Actions\Server;

use App\Models\Server;
use App\Models\StandaloneDocker;
use Lorisleiva\Actions\Concerns\AsAction;

class InstallCoolifyDependencies
{
use AsAction;

public function handle(Server $server, string $supported_os_type)
{
$supported_os_type = trim(strtolower($supported_os_type));

switch ($supported_os_type) {
case 'manjaro':
case 'manjaro-arm':
$supported_os_type = 'arch';
break;
case 'fedora-asahi-remix':
$supported_os_type = 'fedora';
break;
case 'pop':
case 'linuxmint':
case 'zorin':
$supported_os_type = 'ubuntu';
break;
}

$dockerVersion = config('constants.docker.version');

$config = base64_encode('{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
},
"default-address-pools": [
{"base":"10.0.0.0/8","size":24}
]
}');

$found = StandaloneDocker::where('server_id', $server->id);
if ($found->count() == 0 && $server->id) {
StandaloneDocker::create([
'name' => 'coolify',
'network' => 'coolify',
'server_id' => $server->id,
]);
}

$command = collect([]);

switch ($supported_os_type) {
case 'ubuntu':
case 'debian':
case 'raspbian':
$command = $command->merge([
"echo 'Installing Prerequisites...'",
'apt-get update -y',
'command -v curl >/dev/null || apt install -y curl',
'command -v wget >/dev/null || apt install -y wget',
'command -v git >/dev/null || apt install -y git',
'command -v jq >/dev/null || apt install -y jq',
'command -v qemu-user-static >/dev/null || apt install -y qemu-user-static binfmt-support',
]);
break;

case 'centos':
case 'fedora':
case 'rhel':
case 'ol':
case 'rocky':
case 'almalinux':
case 'amzn':
if ($supported_os_type === 'amzn') {
$command = $command->merge([
'dnf install -y wget git jq openssl qemu-user-static',
]);
} else {
$command = $command->merge([
"echo 'Installing Prerequisites...'",
'command -v dnf >/dev/null || yum install -y dnf',
'command -v curl >/dev/null || dnf install -y curl',
'dnf install -y wget git jq openssl qemu-user-static',
]);
}
break;

case 'arch':
case 'archarm':
$command = $command->merge([
"echo 'Installing Prerequisites...'",
'pacman -Sy --noconfirm --needed curl wget git jq openssl qemu-user-static',
]);
break;

case 'alpine':
$command = $command->merge([
"echo 'Installing Prerequisites...'",
'sed -i \'/^#.*\/community/s/^#//\' /etc/apk/repositories',
'apk update',
'apk add curl wget git jq openssl qemu-user',
]);
break;

case 'sles':
case 'opensuse-leap':
case 'opensuse-tumbleweed':
$command = $command->merge([
"echo 'Installing Prerequisites...'",
'zypper refresh',
'zypper install -y curl wget git jq openssl qemu-linux-user',
]);
break;

default:
throw new \Exception('This script only supports Debian, Redhat, Arch Linux, Alpine Linux, or SLES based operating systems.');
}

$command = $command->merge([
"echo 'Installing Docker Engine...'",
"curl https://releases.rancher.com/install-docker/{$dockerVersion}.sh | sh || curl https://get.docker.com | sh -s -- --version {$dockerVersion}",
"echo 'Configuring Docker Engine (merging existing configuration with the required)...'",
'mkdir -p /etc/docker',
'test -s /etc/docker/daemon.json && cp /etc/docker/daemon.json "/etc/docker/daemon.json.original-$(date +"%Y%m%d-%H%M%S")"',
"test ! -s /etc/docker/daemon.json && echo '{$config}' | base64 -d | tee /etc/docker/daemon.json > /dev/null",
"echo '{$config}' | base64 -d | tee /etc/docker/daemon.json.coolify > /dev/null",
'jq . /etc/docker/daemon.json.coolify | tee /etc/docker/daemon.json.coolify.pretty > /dev/null',
'mv /etc/docker/daemon.json.coolify.pretty /etc/docker/daemon.json.coolify',
"jq -s '.[0] * .[1]' /etc/docker/daemon.json.coolify /etc/docker/daemon.json | tee /etc/docker/daemon.json.appended > /dev/null",
'mv /etc/docker/daemon.json.appended /etc/docker/daemon.json',

"echo 'Restarting Docker Engine...'",
'systemctl enable docker >/dev/null 2>&1 || true',
'systemctl restart docker',

"echo 'Installing multi-architecture support...'",
'docker run --privileged --rm tonistiigi/binfmt --install all >/dev/null 2>&1 || echo "Warning: Failed to install multi-architecture support."',
]);

if ($server->isSwarm()) {
$command = $command->merge([
'docker network create --attachable --driver overlay coolify-overlay >/dev/null 2>&1 || true',
]);
} else {
$command = $command->merge([
'docker network create --attachable coolify >/dev/null 2>&1 || true',
"echo 'Done!'",
]);
}

return remote_process($command, $server);
}
}
109 changes: 0 additions & 109 deletions app/Actions/Server/InstallDocker.php

This file was deleted.

Loading