refactor: Update ServerSeeder and PopulateSshKeysDirectorySeeder

This commit is contained in:
Andras Bacsai
2024-09-20 17:28:55 +02:00
parent fa375e2fd8
commit be42f15711
4 changed files with 84 additions and 113 deletions

View File

@@ -23,7 +23,13 @@ class PopulateSshKeysDirectorySeeder extends Seeder
} }
}); });
Process::run('chown -R 9999:9999 '.storage_path('app/ssh/keys')); if (isDev()) {
Process::run('chown -R 9999:9999 '.storage_path('app/ssh/mux')); $user = env('PUID').':'.env('PGID');
Process::run("chown -R $user ".storage_path('app/ssh/keys'));
Process::run("chown -R $user ".storage_path('app/ssh/mux'));
} else {
Process::run('chown -R 9999:9999 '.storage_path('app/ssh/keys'));
Process::run('chown -R 9999:9999 '.storage_path('app/ssh/mux'));
}
} }
} }

View File

@@ -2,6 +2,8 @@
namespace Database\Seeders; namespace Database\Seeders;
use App\Enums\ProxyStatus;
use App\Enums\ProxyTypes;
use App\Models\Server; use App\Models\Server;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
@@ -16,6 +18,10 @@ class ServerSeeder extends Seeder
'ip' => 'coolify-testing-host', 'ip' => 'coolify-testing-host',
'team_id' => 0, 'team_id' => 0,
'private_key_id' => 1, 'private_key_id' => 1,
'proxy' => [
'type' => ProxyTypes::TRAEFIK->value,
'status' => ProxyStatus::EXITED->value,
],
]); ]);
} }
} }

View File

@@ -23,87 +23,82 @@
<button>Terminal</button> <button>Terminal</button>
</a> </a>
@if ( @if (
$database->getMorphClass() === 'App\Models\StandalonePostgresql' || $database->getMorphClass() === 'App\Models\StandalonePostgresql' ||
$database->getMorphClass() === 'App\Models\StandaloneMongodb' || $database->getMorphClass() === 'App\Models\StandaloneMongodb' ||
$database->getMorphClass() === 'App\Models\StandaloneMysql' || $database->getMorphClass() === 'App\Models\StandaloneMysql' ||
$database->getMorphClass() === 'App\Models\StandaloneMariadb') $database->getMorphClass() === 'App\Models\StandaloneMariadb')
<a class="{{ request()->routeIs('project.database.backup.index') ? 'dark:text-white' : '' }}" href="{{ route('project.database.backup.index', $parameters) }}"> <a class="{{ request()->routeIs('project.database.backup.index') ? 'dark:text-white' : '' }}"
<button>Backups</button> href="{{ route('project.database.backup.index', $parameters) }}">
</a> <button>Backups</button>
</a>
@endif @endif
</nav> </nav>
<div class="flex flex-wrap gap-2 items-center"> <div class="flex flex-wrap gap-2 items-center">
@if (!str($database->status)->startsWith('exited')) @if (!str($database->status)->startsWith('exited'))
<x-modal-confirmation <x-modal-confirmation title="Confirm Database Restart?" buttonTitle="Restart" submitAction="restart"
title="Confirm Database Restart?" :actions="[
buttonTitle="Restart" 'This database will be unavailable during the restart.',
submitAction="restart" 'If the database is currently in use data could be lost.',
:actions="['This database will be unavailable during the restart.', 'If the database is currently in use data could be lost.']" ]" :confirmWithText="false" :confirmWithPassword="false" step2ButtonText="Restart Database"
:confirmWithText="false" :dispatchEvent="true" dispatchEventType="restartEvent">
:confirmWithPassword="false" <x-slot:button-title>
step2ButtonText="Restart Database" <svg class="w-5 h-5 dark:text-warning" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
:dispatchEvent="true" <g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"
dispatchEventType="restartEvent" stroke-width="2">
> <path d="M19.933 13.041a8 8 0 1 1-9.925-8.788c3.899-1 7.935 1.007 9.425 4.747" />
<x-slot:button-title> <path d="M20 4v5h-5" />
<svg class="w-5 h-5 dark:text-warning" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> </g>
<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"> </svg>
<path d="M19.933 13.041a8 8 0 1 1-9.925-8.788c3.899-1 7.935 1.007 9.425 4.747" /> Restart
<path d="M20 4v5h-5" /> </x-slot:button-title>
</g> </x-modal-confirmation>
</svg> <x-modal-confirmation title="Confirm Database Stopping?" buttonTitle="Stop" submitAction="stop"
Restart :checkboxes="$checkboxes" :actions="[
</x-slot:button-title> 'This database will be stopped.',
</x-modal-confirmation> 'If the database is currently in use data could be lost.',
<x-modal-confirmation 'All non-persistent data of this database (containers, networks, unused images) will be deleted (don\'t worry, no data is lost and you can start the database again).',
title="Confirm Database Stopping?" ]" :confirmWithText="false" :confirmWithPassword="false" step1ButtonText="Continue"
buttonTitle="Stop" step2ButtonText="Stop Database" :dispatchEvent="true" dispatchEventType="stopEvent">
submitAction="stop" <x-slot:button-title>
:checkboxes="$checkboxes" <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-error" viewBox="0 0 24 24"
:actions="['This database will be stopped.', 'If the database is currently in use data could be lost.', 'All non-persistent data of this database (containers, networks, unused images) will be deleted (don\'t worry, no data is lost and you can start the database again).']" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"
:confirmWithText="false" stroke-linejoin="round">
:confirmWithPassword="false" <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
step1ButtonText="Continue Stopping Database" <path d="M6 5m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v12a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z">
step2ButtonText="Stop Database" </path>
:dispatchEvent="true" <path d="M14 5m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v12a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z">
dispatchEventType="stopEvent" </path>
> </svg>
<x-slot:button-title> Stop
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-error" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> </x-slot:button-title>
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path> </x-modal-confirmation>
<path d="M6 5m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v12a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z">
</path>
<path d="M14 5m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v12a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z">
</path>
</svg>
Stop
</x-slot:button-title>
</x-modal-confirmation>
@else @else
<button @click="$wire.dispatch('startEvent')" class="gap-2 button"> <button @click="$wire.dispatch('startEvent')" class="gap-2 button">
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 dark:text-warning" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 dark:text-warning" viewBox="0 0 24 24"
<path stroke="none" d="M0 0h24v24H0z" fill="none" /> stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"
<path d="M7 4v16l13 -8z" /> stroke-linejoin="round">
</svg> <path stroke="none" d="M0 0h24v24H0z" fill="none" />
Start <path d="M7 4v16l13 -8z" />
</button> </svg>
Start
</button>
@endif @endif
@script @script
<script> <script>
$wire.$on('startEvent', () => { $wire.$on('startEvent', () => {
window.dispatchEvent(new CustomEvent('startdatabase')); window.dispatchEvent(new CustomEvent('startdatabase'));
$wire.$call('start'); $wire.$call('start');
}); });
$wire.$on('stopEvent', () => { $wire.$on('stopEvent', () => {
$wire.$dispatch('info', 'Stopping database.'); $wire.$dispatch('info', 'Stopping database.');
$wire.$call('stop'); $wire.$call('stop');
}); });
$wire.$on('restartEvent', () => { $wire.$on('restartEvent', () => {
$wire.$dispatch('info', 'Restarting database.'); $wire.$dispatch('info', 'Restarting database.');
$wire.$call('restart'); $wire.$call('restart');
}); });
</script> </script>
@endscript @endscript
</div> </div>
</div> </div>
</nav> </nav>

View File

@@ -20,47 +20,14 @@ function help {
compgen -A function | cat -n compgen -A function | cat -n
} }
# function sync:v3 {
# if [ -z "$1" ]; then
# echo -e "Please provide a version.\n\nExample: run sync:v3 3.12.32"
# exit 1
# fi
# skopeo copy --all docker://ghcr.io/coollabsio/coolify:$1 docker://coollabsio/coolify:$1
# }
function test { function test {
docker exec -t coolify php artisan test --testsuite=Feature docker exec -t coolify php artisan test --testsuite=Feature
} }
function sync:bunny { function sync:bunny {
php artisan sync:bunny --env=secrets php artisan sync:bunny --env=secrets
} }
# function queue {
# bash spin exec -u webuser coolify php artisan queue:listen
# }
# function horizon {
# bash spin exec -u webuser coolify php artisan horizon -vvv
# }
# function schedule {
# bash spin exec -u webuser coolify php artisan schedule:work
# }
# function schedule:run {
# bash spin exec -u webuser coolify php artisan schedule:run
# }
# function db {
# bash spin exec -u webuser coolify php artisan db
# }
# function db:seed {
# bash spin exec -u webuser coolify php artisan migrate --seed
# }
# function db:migrate {
# bash spin exec -u webuser coolify php artisan migrate --step
# }
function db:reset { function db:reset {
bash spin exec -u webuser coolify php artisan migrate:fresh --seed bash spin exec -u webuser coolify php artisan migrate:fresh --seed
} }
@@ -96,9 +63,6 @@ function tinker {
bash spin exec -u webuser coolify php artisan tinker bash spin exec -u webuser coolify php artisan tinker
} }
# function build:helper {
# act -W .github/workflows/coolify-helper.yml --secret-file .env.secrets
# }
function default { function default {
help help
} }