Skip to content

Commit

Permalink
refactor: Update ServerSeeder and PopulateSshKeysDirectorySeeder
Browse files Browse the repository at this point in the history
  • Loading branch information
andrasbacsai committed Sep 20, 2024
1 parent fa375e2 commit be42f15
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 113 deletions.
10 changes: 8 additions & 2 deletions database/seeders/PopulateSshKeysDirectorySeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ public function run()
}
});

Process::run('chown -R 9999:9999 '.storage_path('app/ssh/keys'));
Process::run('chown -R 9999:9999 '.storage_path('app/ssh/mux'));
if (isDev()) {
$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'));
}
}
}
6 changes: 6 additions & 0 deletions database/seeders/ServerSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Database\Seeders;

use App\Enums\ProxyStatus;
use App\Enums\ProxyTypes;
use App\Models\Server;
use Illuminate\Database\Seeder;

Expand All @@ -16,6 +18,10 @@ public function run(): void
'ip' => 'coolify-testing-host',
'team_id' => 0,
'private_key_id' => 1,
'proxy' => [
'type' => ProxyTypes::TRAEFIK->value,
'status' => ProxyStatus::EXITED->value,
],
]);
}
}
143 changes: 69 additions & 74 deletions resources/views/livewire/project/database/heading.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,87 +23,82 @@ class="flex overflow-x-scroll flex-shrink-0 gap-6 items-center whitespace-nowrap
<button>Terminal</button>
</a>
@if (
$database->getMorphClass() === 'App\Models\StandalonePostgresql' ||
$database->getMorphClass() === 'App\Models\StandaloneMongodb' ||
$database->getMorphClass() === 'App\Models\StandaloneMysql' ||
$database->getMorphClass() === 'App\Models\StandaloneMariadb')
<a class="{{ request()->routeIs('project.database.backup.index') ? 'dark:text-white' : '' }}" href="{{ route('project.database.backup.index', $parameters) }}">
<button>Backups</button>
</a>
$database->getMorphClass() === 'App\Models\StandalonePostgresql' ||
$database->getMorphClass() === 'App\Models\StandaloneMongodb' ||
$database->getMorphClass() === 'App\Models\StandaloneMysql' ||
$database->getMorphClass() === 'App\Models\StandaloneMariadb')
<a class="{{ request()->routeIs('project.database.backup.index') ? 'dark:text-white' : '' }}"
href="{{ route('project.database.backup.index', $parameters) }}">
<button>Backups</button>
</a>
@endif
</nav>
<div class="flex flex-wrap gap-2 items-center">
@if (!str($database->status)->startsWith('exited'))
<x-modal-confirmation
title="Confirm Database Restart?"
buttonTitle="Restart"
submitAction="restart"
: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"
:dispatchEvent="true"
dispatchEventType="restartEvent"
>
<x-slot:button-title>
<svg class="w-5 h-5 dark:text-warning" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" 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" />
<path d="M20 4v5h-5" />
</g>
</svg>
Restart
</x-slot:button-title>
</x-modal-confirmation>
<x-modal-confirmation
title="Confirm Database Stopping?"
buttonTitle="Stop"
submitAction="stop"
:checkboxes="$checkboxes"
: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).']"
:confirmWithText="false"
:confirmWithPassword="false"
step1ButtonText="Continue Stopping Database"
step2ButtonText="Stop Database"
:dispatchEvent="true"
dispatchEventType="stopEvent"
>
<x-slot:button-title>
<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">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<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>
<x-modal-confirmation title="Confirm Database Restart?" buttonTitle="Restart" submitAction="restart"
: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"
:dispatchEvent="true" dispatchEventType="restartEvent">
<x-slot:button-title>
<svg class="w-5 h-5 dark:text-warning" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"
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" />
<path d="M20 4v5h-5" />
</g>
</svg>
Restart
</x-slot:button-title>
</x-modal-confirmation>
<x-modal-confirmation title="Confirm Database Stopping?" buttonTitle="Stop" submitAction="stop"
:checkboxes="$checkboxes" :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).',
]" :confirmWithText="false" :confirmWithPassword="false" step1ButtonText="Continue"
step2ButtonText="Stop Database" :dispatchEvent="true" dispatchEventType="stopEvent">
<x-slot:button-title>
<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">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<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
<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">
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M7 4v16l13 -8z" />
</svg>
Start
</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">
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M7 4v16l13 -8z" />
</svg>
Start
</button>
@endif
@script
<script>
$wire.$on('startEvent', () => {
window.dispatchEvent(new CustomEvent('startdatabase'));
$wire.$call('start');
});
$wire.$on('stopEvent', () => {
$wire.$dispatch('info', 'Stopping database.');
$wire.$call('stop');
});
$wire.$on('restartEvent', () => {
$wire.$dispatch('info', 'Restarting database.');
$wire.$call('restart');
});
</script>
<script>
$wire.$on('startEvent', () => {
window.dispatchEvent(new CustomEvent('startdatabase'));
$wire.$call('start');
});
$wire.$on('stopEvent', () => {
$wire.$dispatch('info', 'Stopping database.');
$wire.$call('stop');
});
$wire.$on('restartEvent', () => {
$wire.$dispatch('info', 'Restarting database.');
$wire.$call('restart');
});
</script>
@endscript
</div>
</div>
</nav>
</nav>
38 changes: 1 addition & 37 deletions scripts/run
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,14 @@ function help {
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 {
docker exec -t coolify php artisan test --testsuite=Feature
}

function sync:bunny {
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 {
bash spin exec -u webuser coolify php artisan migrate:fresh --seed
}
Expand Down Expand Up @@ -96,9 +63,6 @@ function 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 {
help
}
Expand Down

0 comments on commit be42f15

Please sign in to comment.