improve more

This commit is contained in:
Andras Bacsai 2023-12-13 11:35:53 +01:00
parent 00d708610d
commit 3c54e01d87
8 changed files with 79 additions and 151 deletions

View File

@ -22,11 +22,6 @@ ## 3) Start & setup Coolify
- Run `spin up` - You can notice that errors will be thrown. Don't worry.
- If you see weird permission errors, especially on Mac, run `sudo spin up` instead.
If you are running Coolify for the first time:
- Run `./scripts/run dev:init` - This will delete any existing database layouts, migrate database to the new layout, and seed your database.
> If you see the login page with a 404 error, you forgot to run `./scripts/run dev:init`.
### 4) Start development
You can login your Coolify instance at `localhost:8000` with `test@example.com` and `password`.

View File

@ -0,0 +1,33 @@
<?php
namespace App\Console\Commands;
use App\Models\InstanceSettings;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Process;
class Dev extends Command
{
protected $signature = 'dev:init';
protected $description = 'Init the app in dev mode';
public function handle()
{
// Generate APP_KEY if not exists
if (empty(env('APP_KEY'))) {
echo "Generating APP_KEY.\n";
Artisan::call('key:generate');
}
// Seed database if it's empty
$settings = InstanceSettings::find(0);
if (!$settings) {
echo "Initializing instance, seeding database.\n";
Artisan::call('migrate --seed');
} else {
echo "Instance already initialized.\n";
}
// Set permissions
Process::run(['chmod', '-R', 'o+rwx', '.']);
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Support\Str;
class IsBoardingFlow
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
// ray()->showQueries()->color('orange');
if (showBoarding() && !in_array($request->path(), allowedPathsForBoardingAccounts())) {
if (Str::startsWith($request->path(), 'invitations')) {
return $next($request);
}
return redirect('boarding');
}
return $next($request);
}
}

View File

@ -1,45 +0,0 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Support\Str;
class IsSubscriptionValid
{
public function handle(Request $request, Closure $next): Response
{
if (isInstanceAdmin()) {
return $next($request);
}
if (!auth()->user() || !isCloud()) {
if ($request->path() === 'subscription') {
return redirect('/');
} else {
return $next($request);
}
}
if (isSubscriptionActive() && $request->path() === 'subscription') {
// ray('active subscription Middleware');
return redirect('/');
}
if (isSubscriptionOnGracePeriod()) {
// ray('is_subscription_in_grace_period Middleware');
return $next($request);
}
if (!isSubscriptionActive() && !isSubscriptionOnGracePeriod()) {
// ray('SubscriptionValid Middleware');
if (!in_array($request->path(), allowedPathsForUnsubscribedAccounts())) {
if (Str::startsWith($request->path(), 'invitations')) {
return $next($request);
}
return redirect('subscription');
} else {
return $next($request);
}
}
return $next($request);
}
}

View File

@ -1,23 +0,0 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\StandaloneMongodb>
*/
class StandaloneMongodbFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}

View File

@ -70,6 +70,8 @@ services:
volumes:
- .:/var/www/html:cached
command: sh -c "npm install && npm run dev"
networks:
- coolify
testing-host:
<<: *testing-host-base
container_name: coolify-testing-host
@ -77,15 +79,8 @@ services:
- /:/host
- /var/run/docker.sock:/var/run/docker.sock
- /data/coolify/:/data/coolify
# - coolify-data-dev:/data/coolify
# remote-host:
# <<: *testing-host-base
# container_name: coolify-remote-host
# volumes:
# - /:/host
# - /var/run/docker.sock:/var/run/docker.sock
# - /data/coolify/:/data/coolify
# # - coolify-data-dev:/data/coolify
networks:
- coolify
mailpit:
image: "axllent/mailpit:latest"
container_name: coolify-mail
@ -116,8 +111,8 @@ volumes:
coolify-redis-data-dev:
coolify-minio-data-dev:
networks:
coolify:
name: coolify
driver: bridge
external: false
coolify:
name: coolify
external: false

View File

@ -1,4 +1,5 @@
#!/command/execlineb -P
foreground { composer -d /var/www/html/ install }
foreground { php /var/www/html/artisan key:generate }
foreground { php /var/www/html/artisan migrate --step }
foreground { php /var/www/html/artisan dev:init }

View File

@ -20,50 +20,50 @@ function help {
compgen -A function | cat -n
}
function dev:init {
docker exec coolify bash -c "php artisan migrate --seed"
echo "Need to update privileges on a few files. I need your password for that."
sudo chmod -R o+rwx .
}
# function dev:init {
# docker exec coolify bash -c "php artisan migrate --seed"
# echo "Need to update privileges on a few files. I need your password for that."
# sudo chmod -R o+rwx .
# }
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 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 sync:bunny {
php artisan sync:bunny --env=secrets
}
function queue {
bash spin exec -u webuser coolify php artisan queue:listen
}
# 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 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 {
# bash spin exec -u webuser coolify php artisan schedule:work
# }
function schedule:run {
bash spin exec -u webuser coolify php artisan schedule:run
}
# 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 {
# 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: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
@ -101,9 +101,9 @@ function tinker {
}
function build:helper {
act -W .github/workflows/coolify-helper.yml --secret-file .env.secrets
}
# function build:helper {
# act -W .github/workflows/coolify-helper.yml --secret-file .env.secrets
# }
function default {
help
}