diff --git a/app/Http/Controllers/V5/HomeController.php b/app/Http/Controllers/V5/HomeController.php index df53ff196..79a54c8ca 100644 --- a/app/Http/Controllers/V5/HomeController.php +++ b/app/Http/Controllers/V5/HomeController.php @@ -25,7 +25,6 @@ class HomeController extends Controller $currentTeam = $request->attributes->get('v5.currentTeam'); return Inertia::render('Home', [ - 'status' => 'v5-ready', 'flux' => $fluxHealth->check(), 'clusters' => $this->clusters($currentTeam), 'cooldServers' => $this->cooldServers($currentTeam), diff --git a/resources/js/v5/Pages/Home.jsx b/resources/js/v5/Pages/Home.jsx index 31aa042a6..350036599 100644 --- a/resources/js/v5/Pages/Home.jsx +++ b/resources/js/v5/Pages/Home.jsx @@ -1,10 +1,8 @@ import { Head } from '@inertiajs/react'; import { useState } from 'react'; -export default function Home({ status, currentTeam, teams, flux, clusters, cooldServers, privateKeys }) { +export default function Home({ currentTeam, teams, flux, clusters, cooldServers, privateKeys }) { const firstPrivateKey = privateKeys[0]?.uuid || ''; - const [coolify, setCoolify] = useState(null); - const [checkingCoolify, setCheckingCoolify] = useState(false); const [bootstrapResult, setBootstrapResult] = useState(null); const [bootstrapping, setBootstrapping] = useState(false); const [bootstrapForm, setBootstrapForm] = useState({ @@ -29,30 +27,6 @@ export default function Home({ status, currentTeam, teams, flux, clusters, coold })); } - async function checkCoolifyCliVersion() { - setCheckingCoolify(true); - - try { - const response = await fetch('/v5/coolify/version', { - headers: { - Accept: 'application/json', - }, - }); - - setCoolify(await response.json()); - } catch (error) { - setCoolify({ - available: false, - label: 'Unavailable', - version: null, - message: 'Could not check the installed coolify version.', - binary: null, - }); - } finally { - setCheckingCoolify(false); - } - } - async function bootstrapCoolifyMesh(event) { event.preventDefault(); setBootstrapping(true); @@ -101,25 +75,12 @@ export default function Home({ status, currentTeam, teams, flux, clusters, coold
-

{status}

-

Coolify v5

-

- This page is served from Laravel through Inertia and React, with routes, - assets, and future v5 tables isolated from the current v4 Livewire app. -

- -
-

Flux status

- +

- {flux.label} + Flux: {flux.label} — {flux.socket ? flux.socket : flux.message}

- -

{flux.message}

- - {flux.socket ?

Socket: {flux.socket}

: null}
@@ -173,21 +134,6 @@ export default function Home({ status, currentTeam, teams, flux, clusters, coold

coolify

- - - {coolify ? ( -
-

- {coolify.label} -

- {coolify.version ?

Version: {coolify.version}

: null} -

{coolify.message}

- {coolify.binary ?

Binary: {coolify.binary}

: null} -
- ) : null} -

Bootstrap server

diff --git a/scripts/dev.sh b/scripts/dev.sh index 1d9362828..e0f6014a4 100755 --- a/scripts/dev.sh +++ b/scripts/dev.sh @@ -816,14 +816,67 @@ sudo podman exec coolify-example-nginx nslookup coolify-example-nginx-2.default. SH } +example_nginx_require_pair() { + if [ "$(coold_vm_count)" = "1" ]; then + echo "ERROR: example-nginx ping/firewall commands require COOLIFY_COOLD_VM_COUNT=2." >&2 + exit 1 + fi +} + +example_nginx_container_ip() { + local index="$1" + local name + name="$(example_nginx_name "$index")" + + COOLIFY_COOLD_LIMA_INSTANCE="$(coold_vm_instance "$index")" scripts/coold-vm.sh shell </dev/null +echo 'ok: coolify-example-nginx can reach coolify-example-nginx-2 on tcp/80' +SH +} + +example_nginx_firewall_up() { + local src + local dst + example_nginx_require_pair + + src="$(example_nginx_container_ip 1)" + dst="$(example_nginx_container_ip 2)" + + scripts/dev.sh firewall allow "$src" "$dst" tcp 80 +} + +example_nginx_firewall_down() { + local src + local dst + example_nginx_require_pair + + src="$(example_nginx_container_ip 1)" + dst="$(example_nginx_container_ip 2)" + + scripts/dev.sh firewall revoke "$src" "$dst" tcp 80 +} + example_nginx_help() { cat <<'USAGE' Usage: scripts/dev.sh example-nginx Commands: - up Start one nginx container on each coold VM with coold DNS configured - down Remove the example nginx containers - check-dns Verify host 1 nginx can resolve host 2 nginx through coold DNS + up Start one nginx container on each coold VM with coold DNS configured + down Remove the example nginx containers + check-dns Verify host 1 nginx can resolve host 2 nginx through coold DNS + ping Verify host 1 nginx can reach host 2 nginx on tcp/80 + firewall up Allow host 1 nginx to reach host 2 nginx through the coolify CLI + firewall down Revoke the example nginx tcp/80 allow rule through the coolify CLI USAGE } @@ -843,6 +896,24 @@ example_nginx() { check-dns) example_nginx_check_dns ;; + ping) + example_nginx_ping + ;; + firewall) + case "${1:-help}" in + up) + example_nginx_firewall_up + ;; + down) + example_nginx_firewall_down + ;; + *) + echo "unknown example-nginx firewall command: ${1:-help}" >&2 + echo "Run: scripts/dev.sh example-nginx help" >&2 + exit 1 + ;; + esac + ;; -h|--help|help) example_nginx_help ;; diff --git a/tests/Feature/DevScriptExampleNginxTest.php b/tests/Feature/DevScriptExampleNginxTest.php new file mode 100644 index 000000000..ef7762f5d --- /dev/null +++ b/tests/Feature/DevScriptExampleNginxTest.php @@ -0,0 +1,23 @@ +run(); + + expect($process->isSuccessful())->toBeTrue() + ->and($process->getOutput())->toContain('ping') + ->and($process->getOutput())->toContain('firewall up') + ->and($process->getOutput())->toContain('firewall down') + ->and($process->getOutput())->not->toContain('firewall-up') + ->and($process->getOutput())->not->toContain('firewall-down'); +}); + +it('uses the coolify firewall wrapper for example nginx firewall changes', function () { + $script = file_get_contents(base_path('scripts/dev.sh')); + + expect($script)->toContain('scripts/dev.sh firewall allow "$src" "$dst" tcp 80') + ->and($script)->toContain('scripts/dev.sh firewall revoke "$src" "$dst" tcp 80'); +}); diff --git a/tests/Feature/V5/HomeTest.php b/tests/Feature/V5/HomeTest.php index 50bdb3b5c..e05b06564 100644 --- a/tests/Feature/V5/HomeTest.php +++ b/tests/Feature/V5/HomeTest.php @@ -184,7 +184,8 @@ it('serves the v5 inertia shell', function () { ->assertSuccessful() ->assertSee('v5-app', false) ->assertSee('Home', false) - ->assertSee('v5-ready', false) + ->assertDontSee('v5-ready', false) + ->assertDontSee('This page is served from Laravel through Inertia and React') ->assertSee('Running') ->assertSee('Flux is running.') ->assertSee('"clusters":[]', false) @@ -294,6 +295,27 @@ it('shows when flux is unavailable', function () { ->assertSee('Flux socket was not found.'); }); +it('does not include coolify version controls on the v5 home page', function () { + $homePage = file_get_contents(resource_path('js/v5/Pages/Home.jsx')); + + expect($homePage) + ->not->toContain('Check coolify version') + ->not->toContain('/v5/coolify/version') + ->not->toContain('Installed version:'); +}); + +it('renders flux status as a compact summary', function () { + $homePage = file_get_contents(resource_path('js/v5/Pages/Home.jsx')); + + expect($homePage) + ->toContain('Flux:') + ->toContain('{flux.label}') + ->toContain('{flux.socket ? flux.socket : flux.message}') + ->not->toContain('

Flux status

') + ->not->toContain('

{flux.message}

') + ->not->toContain('Socket: {flux.socket}'); +}); + it('checks the installed coolify version', function () { createSharedUserAndTeamTables(); [$user, $team] = createV5UserWithTeam();