An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat(dev): support KVM-backed localhost development servers
Andras Bacsaif35de6b3b22e
diff --git a/.ai/lessons.md b/.ai/lessons.mdindex e0f315ae8e..ee068cb71d 100644--- a/.ai/lessons.md+++ b/.ai/lessons.md@@ -42,6 +42,7 @@- For container image changes, inspect Compose services and every relevant Dockerfile build stage.- Pin a stable release tag instead of using a floating `latest` tag.- A successful image pull does not prove that the complete application build no longer uses the old image.+- Do not use `docker compose up --wait` for a stack with one-shot services; wait for the required long-running service's health instead.## Make distributed schedules durable- Use the database as the correctness source for dynamic cron occurrences shared by multiple scheduler and Horizon nodes; Redis locks are load controls, not a durable execution ledger.diff --git a/app/Actions/Development/ManageDevelopmentQemuVm.php b/app/Actions/Development/ManageDevelopmentQemuVm.phpindex a1257cbda1..2101906299 100644--- a/app/Actions/Development/ManageDevelopmentQemuVm.php+++ b/app/Actions/Development/ManageDevelopmentQemuVm.php@@ -11,7 +11,7 @@ class ManageDevelopmentQemuVmuse AsAction;/** @param string|array<int, string> $profileNames */- public function handle(string|array $profileNames): void+ public function handle(string|array $profileNames, bool $asLocalhost = false): void{$profileNames = is_array($profileNames) ? array_values(array_unique($profileNames)) : [$profileNames];@@ -19,10 +19,11 @@ class ManageDevelopmentQemuVmStartDevelopmentQemuVm::run($profileName, $index === 0);try {- SeedDevelopmentQemuServer::run($profileName, $index === 0);+ SeedDevelopmentQemuServer::run($profileName, $index === 0, $asLocalhost);} catch (QueryException $exception) {$keepOthers = $index === 0 ? '' : ' --keep-others';- $result = Process::run('docker exec coolify php artisan dev:qemu:seed '.escapeshellarg($profileName).$keepOthers);+ $localhostOption = $asLocalhost ? ' --as-localhost' : '';+ $result = Process::run('docker exec coolify php artisan dev:qemu:seed '.escapeshellarg($profileName).$keepOthers.$localhostOption);if ($result->failed()) {throw $exception;diff --git a/app/Actions/Development/SeedDevelopmentQemuServer.php b/app/Actions/Development/SeedDevelopmentQemuServer.phpindex 10cb0b3c7d..191d045360 100644--- a/app/Actions/Development/SeedDevelopmentQemuServer.php+++ b/app/Actions/Development/SeedDevelopmentQemuServer.php@@ -12,7 +12,7 @@ class SeedDevelopmentQemuServer{use AsAction;- public function handle(string $profileName, bool $removeOtherServers = true): Server+ public function handle(string $profileName, bool $removeOtherServers = true, bool $asLocalhost = false): Server{$this->ensureDevelopmentEnvironment();$profile = config("development-qemu.profiles.{$profileName}");@@ -34,11 +34,13 @@ class SeedDevelopmentQemuServer->delete();}- $server = Server::withTrashed()->where('uuid', $profile['uuid'])->first() ?? new Server;- $server->forceFill(['uuid' => $profile['uuid']]);+ $server = $asLocalhost+ ? (Server::withTrashed()->find(0) ?? new Server)+ : (Server::withTrashed()->where('uuid', $profile['uuid'])->first() ?? new Server);+ $server->forceFill($asLocalhost ? ['id' => 0, 'uuid' => 'localhost'] : ['uuid' => $profile['uuid']]);$server->fill([- 'name' => $profile['name'],- 'description' => 'Development-only QEMU virtual machine managed by dev:qemu.',+ 'name' => $asLocalhost ? 'localhost' : $profile['name'],+ 'description' => 'Development QEMU virtual machine','ip' => $profile['ip'],'port' => 22,'user' => $profile['user'],diff --git a/app/Console/Commands/ManageDevelopmentQemuVmCommand.php b/app/Console/Commands/ManageDevelopmentQemuVmCommand.phpindex a93e1779b9..91c2f855e9 100644--- a/app/Console/Commands/ManageDevelopmentQemuVmCommand.php+++ b/app/Console/Commands/ManageDevelopmentQemuVmCommand.php@@ -9,7 +9,7 @@ use function Laravel\Prompts\multiselect;class ManageDevelopmentQemuVmCommand extends Command{- protected $signature = 'dev:qemu {profiles?* : Profile keys from config/development-qemu.php}';+ protected $signature = 'dev:qemu {profiles?* : Profile keys from config/development-qemu.php} {--as-localhost : Use the VM for the localhost server (id 0)}';protected $description = 'Recreate selected development QEMU VMs and seed their Coolify servers';@@ -28,7 +28,13 @@ class ManageDevelopmentQemuVmCommand extends Commandrequired: true,);- ManageDevelopmentQemuVm::run($profileNames);+ if ($this->option('as-localhost') && count($profileNames) !== 1) {+ $this->error('Select exactly one QEMU profile for localhost.');++ return self::FAILURE;+ }++ ManageDevelopmentQemuVm::run($profileNames, (bool) $this->option('as-localhost'));foreach ($profileNames as $profileName) {$profile = $profiles[$profileName];diff --git a/app/Console/Commands/SeedDevelopmentQemuServerCommand.php b/app/Console/Commands/SeedDevelopmentQemuServerCommand.phpindex 4772317c39..ce68b904f9 100644--- a/app/Console/Commands/SeedDevelopmentQemuServerCommand.php+++ b/app/Console/Commands/SeedDevelopmentQemuServerCommand.php@@ -7,7 +7,7 @@ use Illuminate\Console\Command;class SeedDevelopmentQemuServerCommand extends Command{- protected $signature = 'dev:qemu:seed {profile : Profile key from config/development-qemu.php} {--keep-others}';+ protected $signature = 'dev:qemu:seed {profile : Profile key from config/development-qemu.php} {--keep-others} {--as-localhost : Use the VM for the localhost server (id 0)}';protected $description = 'Seed one development QEMU server in the Coolify database';@@ -19,7 +19,7 @@ class SeedDevelopmentQemuServerCommand extends Commandreturn self::FAILURE;}- $server = SeedDevelopmentQemuServer::run($this->argument('profile'), ! $this->option('keep-others'));+ $server = SeedDevelopmentQemuServer::run($this->argument('profile'), ! $this->option('keep-others'), (bool) $this->option('as-localhost'));$this->info("Seeded {$server->name} at {$server->ip}.");return self::SUCCESS;diff --git a/database/seeders/ServerSeeder.php b/database/seeders/ServerSeeder.phpindex 2d87466915..89a2b3f54c 100644--- a/database/seeders/ServerSeeder.php+++ b/database/seeders/ServerSeeder.php@@ -11,18 +11,27 @@ class ServerSeeder extends Seeder{public function run(): void{- Server::create([+ $server = Server::withTrashed()->find(0) ?? new Server;+ $attributes = ['id' => 0,'uuid' => 'localhost','name' => 'localhost','description' => 'This is a test docker container in development mode','ip' => 'coolify-testing-host',+ 'port' => 22,+ 'user' => 'root','team_id' => 0,'private_key_id' => 1,- 'proxy' => [+ 'deleted_at' => null,+ ];+ if (! $server->exists) {+ $attributes['proxy'] = ['type' => ProxyTypes::TRAEFIK->value,'status' => ProxyStatus::EXITED->value,- ],- ]);+ ];+ }++ $server->forceFill($attributes);+ $server->save();}}diff --git a/docker-compose.dev-kvm.yml b/docker-compose.dev-kvm.ymlnew file mode 100644index 0000000000..32cf1c0db1--- /dev/null+++ b/docker-compose.dev-kvm.yml@@ -0,0 +1,4 @@+# Opt-in KVM development mode. The default Compose setup still starts testing-host.+services:+ testing-host:+ profiles: ["testing-host"]diff --git a/jean.json b/jean.jsonindex 77cf921f7a..ac29e92ebc 100644--- a/jean.json+++ b/jean.json@@ -2,7 +2,7 @@"scripts": {"setup": "cp $JEAN_ROOT_PATH/.env .","teardown": null,- "run": "docker rm -f coolify coolify-minio-init coolify-minio coolify-testing-host coolify-redis coolify-db coolify-mail coolify-vite; docker compose -f docker-compose.yml -f docker-compose.dev.yml up; docker compose -f docker-compose.yml -f docker-compose.dev.yml down"+ "run": "./scripts/dev run"},"ports": [{diff --git a/scripts/dev b/scripts/devnew file mode 100755index 0000000000..fa4d7cd8d6--- /dev/null+++ b/scripts/dev@@ -0,0 +1,119 @@+#!/usr/bin/env bash+# Manage the development stack with KVM when available, or testing-host otherwise.+# Jean uses `run` to keep logs attached and clean up when the run ends.+set -euo pipefail++cd "$(dirname "$0")/.."++usage() {+ echo 'Usage: ./scripts/dev start [qemu-profile]'+ echo ' ./scripts/dev stop [qemu-profile]'+ echo ' ./scripts/dev run [qemu-profile]'+}++if [[ "${1:-}" == "--help" ]]; then+ usage+ exit 0+fi++if [[ $# -gt 2 || ( "${1:-start}" != "start" && "${1:-start}" != "stop" && "${1:-start}" != "run" ) ]]; then+ usage >&2+ exit 2+fi++command="${1:-start}"+profile="${2:-${COOLIFY_DEV_KVM_PROFILE:-ubuntu-root}}"+backend="${COOLIFY_DEV_SERVER_BACKEND:-auto}"+if [[ "$backend" != "auto" && "$backend" != "testing-host" ]]; then+ echo 'COOLIFY_DEV_SERVER_BACKEND must be auto or testing-host.' >&2+ exit 2+fi++privileged=()+if [[ $EUID -ne 0 ]]; then+ privileged=(sudo -n -E)+fi++if [[ "$backend" == "auto" && -c /dev/kvm && -r /dev/kvm && -w /dev/kvm ]] &&+ { [[ $EUID -eq 0 ]] || { command -v sudo >/dev/null && sudo -n -E true; }; }; then+ backend=kvm+else+ backend=testing-host+fi++compose=(docker compose -f docker-compose.yml -f docker-compose.dev.yml)+if [[ "$backend" == "kvm" ]]; then+ compose+=(-f docker-compose.dev-kvm.yml)+fi++wait_for_coolify() {+ local attempt status+ for ((attempt = 0; attempt < 150; attempt++)); do+ status="$(docker inspect --format '{{.State.Status}} {{if .State.Health}}{{.State.Health.Status}}{{end}}' coolify 2>/dev/null || true)"+ if [[ "$status" == 'running healthy' ]]; then+ return 0+ fi+ if [[ "$status" == exited* || "$status" == dead* ]]; then+ break+ fi+ sleep 2+ done++ echo 'Coolify did not become healthy within 5 minutes.' >&2+ return 1+}++start_backend() {+ if [[ "$backend" == "kvm" ]]; then+ echo "Using KVM profile: $profile"+ "${compose[@]}" --profile testing-host stop testing-host+ "${compose[@]}" up -d+ wait_for_coolify+ "${privileged[@]}" php artisan dev:qemu "$profile" --as-localhost+ else+ echo 'KVM is unavailable or disabled; using coolify-testing-host.'+ "${compose[@]}" up -d+ wait_for_coolify+ "${compose[@]}" exec -T coolify php artisan db:seed --class=ServerSeeder --force+ fi+}++stop_backend() {+ if [[ "$backend" == "kvm" ]] && command -v virsh >/dev/null; then+ local domain domains state+ domain="coolify-dev-${profile}"+ domains="$("${privileged[@]}" virsh --connect qemu:///system list --all --name)"+ if grep -Fxq "$domain" <<< "$domains"; then+ state="$("${privileged[@]}" virsh --connect qemu:///system domstate "$domain")"+ if [[ "$state" != 'shut off' ]]; then+ "${privileged[@]}" virsh --connect qemu:///system shutdown "$domain"+ fi+ fi+ fi+ "${compose[@]}" stop+}++cleanup() {+ status=$?+ trap - EXIT INT TERM+ stop_backend || true+ "${compose[@]}" down || true+ exit "$status"+}++case "$command" in+ start)+ start_backend+ ;;+ stop)+ stop_backend+ ;;+ run)+ trap cleanup EXIT+ trap 'exit 130' INT+ trap 'exit 143' TERM+ docker rm -f coolify coolify-minio-init coolify-minio coolify-testing-host coolify-redis coolify-db coolify-mail coolify-vite >/dev/null 2>&1 || true+ start_backend+ "${compose[@]}" logs -f --tail=100+ ;;+esacdiff --git a/tests/Feature/DevKvmScriptTest.php b/tests/Feature/DevKvmScriptTest.phpnew file mode 100644index 0000000000..0d89186c2c--- /dev/null+++ b/tests/Feature/DevKvmScriptTest.php@@ -0,0 +1,100 @@+<?php++use Symfony\Component\Process\Process;++it('shows start and stop usage and rejects extra arguments', function () {+ $script = base_path('scripts/dev');++ $help = new Process(['bash', $script, '--help'], base_path());+ $help->run();++ $invalid = new Process(['bash', $script, 'start', 'ubuntu-root', 'extra'], base_path());+ $invalid->run();+ $unknown = new Process(['bash', $script, 'restart'], base_path());+ $unknown->run();++ expect($help->isSuccessful())->toBeTrue()+ ->and($help->getOutput())->toContain('start [qemu-profile]', 'stop [qemu-profile]', 'run [qemu-profile]')+ ->and($invalid->isSuccessful())->toBeFalse()+ ->and($unknown->isSuccessful())->toBeFalse();+});++it('stops only the container stack when testing-host is selected', function () {+ $directory = sys_get_temp_dir().'/coolify-dev-container-test-'.bin2hex(random_bytes(4));+ mkdir($directory.'/bin', 0777, true);+ $log = $directory.'/commands.log';+ $fake = <<<'BASH'+#!/usr/bin/env bash+printf '%s %s\n' "$(basename "$0")" "$*" >> "$DEV_KVM_LOG"+BASH;+ foreach (['docker', 'virsh'] as $binary) {+ file_put_contents($directory.'/bin/'.$binary, $fake);+ chmod($directory.'/bin/'.$binary, 0755);+ }++ try {+ $process = new Process(['bash', base_path('scripts/dev'), 'stop'], base_path(), [+ 'PATH' => $directory.'/bin:'.getenv('PATH'),+ 'DEV_KVM_LOG' => $log,+ 'COOLIFY_DEV_SERVER_BACKEND' => 'testing-host',+ ]);+ $process->run();++ expect($process->isSuccessful())->toBeTrue($process->getErrorOutput())+ ->and(file_get_contents($log))->toContain('docker compose -f docker-compose.yml -f docker-compose.dev.yml stop')+ ->not->toContain('virsh')+ ->not->toContain('docker-compose.dev-kvm.yml');+ } finally {+ foreach (['docker', 'virsh'] as $binary) {+ unlink($directory.'/bin/'.$binary);+ }+ if (file_exists($log)) {+ unlink($log);+ }+ rmdir($directory.'/bin');+ rmdir($directory);+ }+});++it('shuts down the selected vm and stops the compose services', function () {+ $directory = sys_get_temp_dir().'/coolify-dev-kvm-test-'.bin2hex(random_bytes(4));+ mkdir($directory.'/bin', 0777, true);+ $log = $directory.'/commands.log';+ $fake = <<<'BASH'+#!/usr/bin/env bash+printf '%s %s\n' "$(basename "$0")" "$*" >> "$DEV_KVM_LOG"+if [[ "$(basename "$0") $3" == 'virsh domstate' ]]; then+ echo running+fi+if [[ "$(basename "$0") $3" == 'virsh list' ]]; then+ echo coolify-dev-debian-root+fi+BASH;+ file_put_contents($directory.'/bin/docker', $fake);+ file_put_contents($directory.'/bin/virsh', $fake);+ chmod($directory.'/bin/docker', 0755);+ chmod($directory.'/bin/virsh', 0755);++ try {+ $process = new Process(['bash', base_path('scripts/dev'), 'stop', 'debian-root'], base_path(), [+ 'PATH' => $directory.'/bin:'.getenv('PATH'),+ 'DEV_KVM_LOG' => $log,+ ]);+ $process->run();++ expect($process->isSuccessful())->toBeTrue($process->getErrorOutput())+ ->and(file_get_contents($log))->toContain('virsh --connect qemu:///system list --all --name')+ ->toContain('virsh --connect qemu:///system domstate coolify-dev-debian-root')+ ->toContain('virsh --connect qemu:///system shutdown coolify-dev-debian-root')+ ->toContain('docker compose -f docker-compose.yml -f docker-compose.dev.yml -f docker-compose.dev-kvm.yml stop')+ ->not->toContain('dev-kvm.yml down');+ } finally {+ unlink($directory.'/bin/docker');+ unlink($directory.'/bin/virsh');+ if (file_exists($log)) {+ unlink($log);+ }+ rmdir($directory.'/bin');+ rmdir($directory);+ }+});diff --git a/tests/Feature/DevelopmentQemuVmTest.php b/tests/Feature/DevelopmentQemuVmTest.phpindex 18e5ff9952..c0b0fe6fb0 100644--- a/tests/Feature/DevelopmentQemuVmTest.php+++ b/tests/Feature/DevelopmentQemuVmTest.php@@ -7,7 +7,9 @@ use App\Actions\Development\StartDevelopmentQemuVm;use App\Console\Commands\ManageDevelopmentQemuVmCommand;use App\Console\Commands\SeedDevelopmentQemuServerCommand;use App\Models\Server;+use App\Support\ValidationPatterns;use Database\Seeders\PrivateKeySeeder;+use Database\Seeders\ServerSeeder;use Database\Seeders\TeamSeeder;use Database\Seeders\UserSeeder;use Illuminate\Console\Command;@@ -17,6 +19,7 @@ use Illuminate\Support\Facades\Artisan;use Illuminate\Support\Facades\DB;use Illuminate\Support\Facades\File;use Illuminate\Support\Facades\Process;+use Illuminate\Support\Facades\Validator;uses(RefreshDatabase::class);@@ -34,6 +37,17 @@ it('registers the interactive qemu command', function () {->and(Artisan::all()['dev:qemu:seed'])->toBeInstanceOf(SeedDevelopmentQemuServerCommand::class);});+it('requires one profile when a qemu vm is selected as localhost', function () {+ Process::fake();++ expect(Artisan::call('dev:qemu', [+ 'profiles' => ['ubuntu-root', 'debian-root'],+ '--as-localhost' => true,+ ]))->toBe(Command::FAILURE);++ Process::assertNothingRan();+});+it('prevents qemu commands from running outside development', function () {config(['app.env' => 'production']);Process::fake();@@ -121,12 +135,50 @@ it('seeds one predefined root qemu server', function () {$server = SeedDevelopmentQemuServer::run('ubuntu-root');expect($server->uuid)->toBe('development-qemu-ubuntu-root')+ ->and($server->description)->toBe('Development QEMU virtual machine')+ ->and(Validator::make(['description' => $server->description], ['description' => ValidationPatterns::descriptionRules()])->passes())->toBeTrue()->and($server->ip)->toBe('192.168.122.10')->and($server->user)->toBe('root')->and($server->team_id)->toBe(0)->and(Server::query()->where('uuid', 'like', 'development-qemu-%')->count())->toBe(1);});+it('uses a qemu vm as the localhost sentinel without changing its identity', function () {+ $this->seed(ServerSeeder::class);++ $server = SeedDevelopmentQemuServer::run('ubuntu-root', true, true);++ expect($server->id)->toBe(0)+ ->and($server->uuid)->toBe('localhost')+ ->and($server->name)->toBe('localhost')+ ->and($server->description)->toBe('Development QEMU virtual machine')+ ->and($server->ip)->toBe('192.168.122.10')+ ->and($server->user)->toBe('root')+ ->and($server->private_key_id)->toBe(1)+ ->and(Server::query()->count())->toBe(1);+});++it('can change the localhost qemu profile without adding a server', function () {+ $this->seed(ServerSeeder::class);+ SeedDevelopmentQemuServer::run('ubuntu-root', true, true);++ SeedDevelopmentQemuServer::run('ubuntu-non-root', true, true);++ expect(Server::query()->findOrFail(0)->ip)->toBe('192.168.122.11')+ ->and(Server::query()->findOrFail(0)->user)->toBe('coolify')+ ->and(Server::query()->count())->toBe(1);+});++it('seeds localhost through the container command', function () {+ $this->seed(ServerSeeder::class);++ expect(Artisan::call('dev:qemu:seed', [+ 'profile' => 'ubuntu-root',+ '--as-localhost' => true,+ ]))->toBe(Command::SUCCESS)+ ->and(Server::query()->findOrFail(0)->ip)->toBe('192.168.122.10');+});+it('replaces the seeded qemu server with the selected non-root equivalent', function () {SeedDevelopmentQemuServer::run('ubuntu-root');$server = SeedDevelopmentQemuServer::run('ubuntu-non-root');@@ -223,6 +275,23 @@ it('seeds through the coolify container when the host database is unavailable',Process::assertRan(fn ($process) => str_contains($process->command, 'docker exec coolify php artisan dev:qemu:seed') && str_contains($process->command, 'ubuntu-root'));});+it('passes localhost mode to the container when the host database is unavailable', function () {+ config(['development-qemu.storage_path' => sys_get_temp_dir().'/coolify-qemu-localhost-fallback-test-'.uniqid()]);+ SeedDevelopmentQemuServer::mock()+ ->shouldReceive('handle')+ ->once()+ ->andThrow(new QueryException('pgsql', 'select 1', [], new Exception('unavailable')));+ Process::fake([+ '* net-dumpxml *' => Process::result(output: '<network></network>'),+ '* network inspect *' => Process::result(output: "172.18.0.0/16\n"),+ '*' => Process::result(),+ ]);++ ManageDevelopmentQemuVm::run('ubuntu-root', true);++ Process::assertRan(fn ($process) => str_contains($process->command, 'dev:qemu:seed') && str_contains($process->command, '--as-localhost'));+});+it('starts and seeds root and non-root profiles together', function () {config(['development-qemu.storage_path' => sys_get_temp_dir().'/coolify-qemu-multi-test-'.uniqid()]);Process::fake([diff --git a/tests/Feature/JeanRunScriptTest.php b/tests/Feature/JeanRunScriptTest.phpnew file mode 100644index 0000000000..d317d9fe1d--- /dev/null+++ b/tests/Feature/JeanRunScriptTest.php@@ -0,0 +1,119 @@+<?php++use Symfony\Component\Process\Process;++it('uses the jean launcher in the run configuration', function () {+ $config = json_decode(file_get_contents(base_path('jean.json')), true, flags: JSON_THROW_ON_ERROR);++ expect($config['scripts']['run'])->toBe('./scripts/dev run')+ ->and($config['ports'][0]['port'])->toBe(8000);+});++it('starts the testing host and restores localhost when kvm is not selected', function () {+ $directory = sys_get_temp_dir().'/coolify-jean-run-test-'.bin2hex(random_bytes(4));+ mkdir($directory.'/bin', 0777, true);+ $log = $directory.'/commands.log';+ file_put_contents($directory.'/bin/docker', <<<'BASH'+#!/usr/bin/env bash+printf '%s\n' "$*" >> "$JEAN_TEST_LOG"+if [[ "$1" == inspect ]]; then+ echo 'running healthy'+fi+BASH);+ chmod($directory.'/bin/docker', 0755);++ try {+ $process = new Process(['bash', base_path('scripts/dev'), 'run'], base_path(), [+ 'PATH' => $directory.'/bin:'.getenv('PATH'),+ 'JEAN_TEST_LOG' => $log,+ 'COOLIFY_DEV_SERVER_BACKEND' => 'testing-host',+ ]);+ $process->run();++ expect($process->isSuccessful())->toBeTrue($process->getErrorOutput())+ ->and(file_get_contents($log))->toContain('compose -f docker-compose.yml -f docker-compose.dev.yml up -d')+ ->toContain('inspect --format {{.State.Status}} {{if .State.Health}}{{.State.Health.Status}}{{end}} coolify')+ ->toContain('compose -f docker-compose.yml -f docker-compose.dev.yml exec -T coolify php artisan db:seed --class=ServerSeeder --force')+ ->toContain('compose -f docker-compose.yml -f docker-compose.dev.yml logs -f')+ ->toContain('compose -f docker-compose.yml -f docker-compose.dev.yml down')+ ->not->toContain('docker-compose.dev-kvm.yml');+ } finally {+ unlink($directory.'/bin/docker');+ if (file_exists($log)) {+ unlink($log);+ }+ rmdir($directory.'/bin');+ rmdir($directory);+ }+});++it('starts the kvm vm and uses the kvm compose override when available', function () {+ if (! function_exists('posix_geteuid') || posix_geteuid() !== 0 || ! file_exists('/dev/kvm') || filetype('/dev/kvm') !== 'char' || ! is_readable('/dev/kvm') || ! is_writable('/dev/kvm')) {+ $this->markTestSkipped('KVM and root access are required for this launcher branch.');+ }++ $directory = sys_get_temp_dir().'/coolify-jean-kvm-test-'.bin2hex(random_bytes(4));+ mkdir($directory.'/bin', 0777, true);+ $log = $directory.'/commands.log';+ $fake = <<<'BASH'+#!/usr/bin/env bash+printf '%s %s\n' "$(basename "$0")" "$*" >> "$JEAN_TEST_LOG"+if [[ "$1" == inspect ]]; then+ echo 'running healthy'+fi+BASH;++ foreach (['docker', 'php', 'virsh'] as $binary) {+ file_put_contents($directory.'/bin/'.$binary, $fake);+ chmod($directory.'/bin/'.$binary, 0755);+ }++ try {+ $process = new Process(['bash', base_path('scripts/dev'), 'run'], base_path(), [+ 'PATH' => $directory.'/bin:'.getenv('PATH'),+ 'JEAN_TEST_LOG' => $log,+ 'COOLIFY_DEV_KVM_PROFILE' => 'debian-root',+ ]);+ $process->run();++ expect($process->isSuccessful())->toBeTrue($process->getErrorOutput())+ ->and(file_get_contents($log))->toContain('docker compose -f docker-compose.yml -f docker-compose.dev.yml -f docker-compose.dev-kvm.yml up -d')+ ->toContain('docker inspect --format {{.State.Status}} {{if .State.Health}}{{.State.Health.Status}}{{end}} coolify')+ ->toContain('php artisan dev:qemu debian-root --as-localhost')+ ->toContain('docker compose -f docker-compose.yml -f docker-compose.dev.yml -f docker-compose.dev-kvm.yml down')+ ->not->toContain('db:seed --class=ServerSeeder');+ } finally {+ foreach (['docker', 'php', 'virsh'] as $binary) {+ unlink($directory.'/bin/'.$binary);+ }+ if (file_exists($log)) {+ unlink($log);+ }+ rmdir($directory.'/bin');+ rmdir($directory);+ }+});++it('stops waiting when the coolify container exits', function () {+ $directory = sys_get_temp_dir().'/coolify-health-test-'.bin2hex(random_bytes(4));+ mkdir($directory);+ file_put_contents($directory.'/docker', <<<'BASH'+#!/usr/bin/env bash+echo 'exited unhealthy'+BASH);+ chmod($directory.'/docker', 0755);++ try {+ $process = new Process(['bash', base_path('scripts/dev'), 'start'], base_path(), [+ 'PATH' => $directory.':'.getenv('PATH'),+ 'COOLIFY_DEV_SERVER_BACKEND' => 'testing-host',+ ]);+ $process->run();++ expect($process->isSuccessful())->toBeFalse()+ ->and($process->getErrorOutput())->toContain('did not become healthy');+ } finally {+ unlink($directory.'/docker');+ rmdir($directory);+ }+});diff --git a/tests/Feature/ServerSeederTest.php b/tests/Feature/ServerSeederTest.phpindex dcb9d53f3b..75206d1d3a 100644--- a/tests/Feature/ServerSeederTest.php+++ b/tests/Feature/ServerSeederTest.php@@ -1,5 +1,6 @@<?php+use App\Actions\Development\SeedDevelopmentQemuServer;use App\Models\Server;use Database\Seeders\PrivateKeySeeder;use Database\Seeders\ServerSeeder;@@ -24,3 +25,36 @@ it('seeds only the development testing host', function () {->and($testingHost->ip)->toBe('coolify-testing-host')->and(Server::query()->count())->toBe(1);});++it('restores localhost to the testing host after a qemu run', function () {+ config(['app.env' => 'local']);++ $this->seed([+ UserSeeder::class,+ TeamSeeder::class,+ PrivateKeySeeder::class,+ ServerSeeder::class,+ ]);++ $localhost = Server::query()->findOrFail(0);+ $localhost->proxy->set('last_saved_proxy_configuration', 'saved proxy config');+ $localhost->save();+ $localhost->update([+ 'ip' => '192.168.122.10',+ 'user' => 'coolify',+ 'description' => 'Development QEMU virtual machine',+ ]);+ SeedDevelopmentQemuServer::run('debian-root', false);++ $this->seed(ServerSeeder::class);++ $server = Server::query()->findOrFail(0);++ expect($server->uuid)->toBe('localhost')+ ->and($server->ip)->toBe('coolify-testing-host')+ ->and($server->user)->toBe('root')+ ->and($server->description)->toBe('This is a test docker container in development mode')+ ->and($server->proxy->last_saved_proxy_configuration)->toBe('saved proxy config')+ ->and(Server::query()->where('uuid', 'development-qemu-debian-root')->count())->toBe(1)+ ->and(Server::query()->count())->toBe(2);+});