Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d8e25ea99 | ||
|
|
e5fd943e06 | ||
|
|
c4ce4134a6 | ||
|
|
072d8f8443 | ||
|
|
6b65f0b583 |
@@ -28,3 +28,4 @@ Thumbs.db
|
||||
provision
|
||||
composer.lock
|
||||
package-lock.json
|
||||
.idea
|
||||
|
||||
@@ -54,4 +54,5 @@ npm run build
|
||||
|
||||
The current execution environment includes PHP and Node.js but not Composer or `vendor/`, so the PHP tests and dependency resolution could not be run here. See `IMPLEMENTATION_NOTES.md` for verification details.
|
||||
|
||||
Now th auto deplyment
|
||||
Now the auto deployment steps and gitflow
|
||||
|
||||
|
||||
+4
-2
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"$schema": "https://getcomposer.org/schema.json",
|
||||
"schema": "https://getcomposer.org/schema.json",
|
||||
"name": "laravel/laravel",
|
||||
"type": "project",
|
||||
"description": "The skeleton application for the Laravel framework.",
|
||||
@@ -10,6 +10,7 @@
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.3",
|
||||
"absdev/laravel-modules": "^1.0",
|
||||
"laravel/framework": "^13.17",
|
||||
"laravel/tinker": "^3.0",
|
||||
"livewire/livewire": "^4.0",
|
||||
@@ -29,7 +30,8 @@
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
"Database\\Seeders\\": "database/seeders/"
|
||||
"Database\\Seeders\\": "database/seeders/",
|
||||
"Modules\\": "Modules/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
|
||||
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
|
||||
use absdev\Modules\Activators\DatabaseActivator;
|
||||
use absdev\Modules\Activators\FileActivator;
|
||||
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Module Namespace
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Default module namespace.
|
||||
|
|
||||
*/
|
||||
|
||||
'namespace' => 'Modules',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Module Stubs
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Default module stubs.
|
||||
|
|
||||
*/
|
||||
|
||||
'stubs' => [
|
||||
'enabled' => false,
|
||||
'path' => base_path() . '/Vendors/absdev/laravel-modules/src/Commands/stubs',
|
||||
'files' => [
|
||||
'routes/web' => 'Routes/web.php',
|
||||
'routes/api' => 'Routes/api.php',
|
||||
'views/index' => 'Resources/views/index.blade.php',
|
||||
'views/master' => 'Resources/views/layouts/master.blade.php',
|
||||
'scaffold/config' => 'Config/config.php',
|
||||
'composer' => 'composer.json',
|
||||
'assets/js/app' => 'Resources/assets/js/app.js',
|
||||
'assets/sass/app' => 'Resources/assets/sass/app.scss',
|
||||
'webpack' => 'webpack.mix.js',
|
||||
'package' => 'package.json',
|
||||
],
|
||||
'replacements' => [
|
||||
'routes/web' => ['LOWER_NAME', 'STUDLY_NAME'],
|
||||
'routes/api' => ['LOWER_NAME'],
|
||||
'webpack' => ['LOWER_NAME'],
|
||||
'json' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'PROVIDER_NAMESPACE'],
|
||||
'views/index' => ['LOWER_NAME'],
|
||||
'views/master' => ['LOWER_NAME', 'STUDLY_NAME'],
|
||||
'scaffold/config' => ['STUDLY_NAME'],
|
||||
'composer' => [
|
||||
'LOWER_NAME',
|
||||
'STUDLY_NAME',
|
||||
'VENDOR',
|
||||
'AUTHOR_NAME',
|
||||
'AUTHOR_EMAIL',
|
||||
'MODULE_NAMESPACE',
|
||||
'PROVIDER_NAMESPACE',
|
||||
],
|
||||
],
|
||||
'gitkeep' => true,
|
||||
],
|
||||
'paths' => [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Modules path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This path used for save the generated module. This path also will be added
|
||||
| automatically to list of scanned folders.
|
||||
|
|
||||
*/
|
||||
|
||||
'modules' => base_path('modules'),
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Modules assets path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may update the modules assets path.
|
||||
|
|
||||
*/
|
||||
|
||||
'assets' => public_path('modules'),
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| The migrations path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Where you run 'module:publish-migration' command, where do you publish the
|
||||
| the migration files?
|
||||
|
|
||||
*/
|
||||
|
||||
'migration' => base_path('database/migrations'),
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Generator path
|
||||
|--------------------------------------------------------------------------
|
||||
| Customise the paths where the folders will be generated.
|
||||
| Set the generate key to false to not generate that folder
|
||||
*/
|
||||
'generator' => [
|
||||
'config' => ['path' => 'Config', 'generate' => true],
|
||||
'trait' => ['path' => 'Traits', 'generate' => true],
|
||||
'helper' => ['path' => 'Helpers', 'generate' => true],
|
||||
'command' => ['path' => 'Console', 'generate' => true],
|
||||
'support' => ['path' => 'Support', 'generate' => true],
|
||||
'migration' => ['path' => 'Database/Migrations', 'generate' => true],
|
||||
'seeder' => ['path' => 'Database/Seeders', 'generate' => true],
|
||||
'factory' => ['path' => 'Database/factories', 'generate' => true],
|
||||
'model' => ['path' => 'Models', 'generate' => true],
|
||||
'routes' => ['path' => 'Routes', 'generate' => true],
|
||||
'controller' => ['path' => 'Http/Controllers', 'generate' => true],
|
||||
'filter' => ['path' => 'Http/Middleware', 'generate' => true],
|
||||
'request' => ['path' => 'Http/Requests', 'generate' => true],
|
||||
'provider' => ['path' => 'Providers', 'generate' => true],
|
||||
'assets' => ['path' => 'Resources/assets', 'generate' => true],
|
||||
'lang' => ['path' => 'Resources/lang', 'generate' => true],
|
||||
'views' => ['path' => 'Resources/views', 'generate' => true],
|
||||
'test' => ['path' => 'Tests/Unit', 'generate' => true],
|
||||
'test-feature' => ['path' => 'Tests/Feature', 'generate' => true],
|
||||
'test-browser' => ['path' => 'Tests/Browser', 'generate' => true,],
|
||||
'repository' => ['path' => 'Repositories', 'generate' => false],
|
||||
'event' => ['path' => 'Events', 'generate' => false],
|
||||
'listener' => ['path' => 'Listeners', 'generate' => false],
|
||||
'policies' => ['path' => 'Policies', 'generate' => false],
|
||||
'rules' => ['path' => 'Rules', 'generate' => false],
|
||||
'jobs' => ['path' => 'Jobs', 'generate' => false],
|
||||
'emails' => ['path' => 'Emails', 'generate' => false],
|
||||
'notifications' => ['path' => 'Notifications', 'generate' => false],
|
||||
'resource' => ['path' => 'Transformers', 'generate' => false],
|
||||
'component' => ['path' => 'View', 'generate' => true],
|
||||
],
|
||||
],
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Scan Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you define which folder will be scanned. By default will scan Vendors
|
||||
| directory. This is useful if you host the package in packagist website.
|
||||
|
|
||||
*/
|
||||
|
||||
'scan' => [
|
||||
'enabled' => false,
|
||||
'paths' => [
|
||||
base_path('Vendors/*/*'),
|
||||
],
|
||||
],
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Composer File Template
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is the config for composer.json file, generated by this package
|
||||
|
|
||||
*/
|
||||
|
||||
'composer' => [
|
||||
'Vendors' => 'absdev',
|
||||
'author' => [
|
||||
'name' => 'Mark Gregory',
|
||||
'email' => '[email protected]',
|
||||
],
|
||||
],
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Caching
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is the config for setting up caching feature.
|
||||
|
|
||||
*/
|
||||
'cache' => [
|
||||
'enabled' => false,
|
||||
'key' => 'laravel-modules',
|
||||
'lifetime' => 60,
|
||||
],
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Choose what laravel-modules will register as custom namespaces.
|
||||
| Setting one to false will require you to register that part
|
||||
| in your own Service Provider class.
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'register' => [
|
||||
'translations' => true,
|
||||
/**
|
||||
* load files on boot or register method
|
||||
*
|
||||
* @example boot|register
|
||||
*/
|
||||
'files' => 'register',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Activators
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| You can define new types of activators here, file, database etc. The only
|
||||
| required parameter is 'class'.
|
||||
| The file activator will store the activation status in storage/installed_modules
|
||||
*/
|
||||
'activators' => [
|
||||
'file' => [
|
||||
'class' => FileActivator::class,
|
||||
'statuses-file' => base_path('modules_statuses.json'),
|
||||
'cache-key' => 'activator.installed',
|
||||
'cache-lifetime' => 604800,
|
||||
],
|
||||
'database' => [
|
||||
'class' => DatabaseActivator::class,
|
||||
'cache-key' => 'activator.installed',
|
||||
'cache-lifetime' => 604800,
|
||||
],
|
||||
],
|
||||
|
||||
'activator' => 'database',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Module control admin UI
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These settings control the package-provided module management screens.
|
||||
| The UI uses the database activator and the module_statuses table.
|
||||
|
|
||||
*/
|
||||
'admin' => [
|
||||
'enabled' => true,
|
||||
'prefix' => 'admin/modules',
|
||||
'middleware' => ['web', 'auth'],
|
||||
'layout_component' => 'layouts.app',
|
||||
'hero_component' => 'wms.page-hero',
|
||||
],
|
||||
];
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if (Schema::hasTable('module_statuses')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('module_statuses', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->string('module')->unique();
|
||||
$table->boolean('enabled')->default(true);
|
||||
$table->text('description')->nullable();
|
||||
$table->string('version')->nullable();
|
||||
$table->unsignedInteger('sort_order')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('module_statuses');
|
||||
}
|
||||
};
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('module_statuses')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('module_statuses', function (Blueprint $table): void {
|
||||
if (! Schema::hasColumn('module_statuses', 'description')) {
|
||||
$table->text('description')->nullable()->after('enabled');
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('module_statuses', 'version')) {
|
||||
$table->string('version')->nullable()->after('description');
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('module_statuses', 'sort_order')) {
|
||||
$table->unsignedInteger('sort_order')->default(0)->after('version');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (! Schema::hasTable('module_statuses')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('module_statuses', function (Blueprint $table): void {
|
||||
if (Schema::hasColumn('module_statuses', 'sort_order')) {
|
||||
$table->dropColumn('sort_order');
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('module_statuses', 'version')) {
|
||||
$table->dropColumn('version');
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('module_statuses', 'description')) {
|
||||
$table->dropColumn('description');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('module_statuses')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('module_statuses', function (Blueprint $table): void {
|
||||
if (! Schema::hasColumn('module_statuses', 'version')) {
|
||||
$table->string('version')->nullable()->after('description');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (! Schema::hasTable('module_statuses')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('module_statuses', function (Blueprint $table): void {
|
||||
if (Schema::hasColumn('module_statuses', 'version')) {
|
||||
$table->dropColumn('version');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('module_statuses', function (Blueprint $table): void {
|
||||
if (! Schema::hasColumn('module_statuses', 'icon')) {
|
||||
$table->string('icon')->nullable()->after('version');
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('module_statuses', 'category')) {
|
||||
$table->string('category')->nullable()->after('icon');
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('module_statuses', 'vendor_type')) {
|
||||
$table->string('vendor_type')->nullable()->after('category');
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('module_statuses', 'author')) {
|
||||
$table->string('author')->nullable()->after('vendor_type');
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('module_statuses', 'notes')) {
|
||||
$table->text('notes')->nullable()->after('author');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('module_statuses', function (Blueprint $table): void {
|
||||
foreach (['notes', 'author', 'vendor_type', 'category', 'icon'] as $column) {
|
||||
if (Schema::hasColumn('module_statuses', $column)) {
|
||||
$table->dropColumn($column);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace absdev\Modules\database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use absdev\Modules\DevelopmentSupport\Entities\ModuleStatus;
|
||||
|
||||
class ModuleStatusSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed missing database module statuses from the existing file activator JSON.
|
||||
*
|
||||
* Existing database rows are left unchanged.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
foreach ($this->readStatuses() as $module => $enabled) {
|
||||
if (! is_string($module) || trim($module) === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
ModuleStatus::query()->firstOrCreate(
|
||||
['module' => trim($module)],
|
||||
['enabled' => (bool) $enabled]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, bool>
|
||||
*/
|
||||
private function readStatuses(): array
|
||||
{
|
||||
$path = $this->statusesFilePath();
|
||||
|
||||
if ($path === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$statuses = json_decode(File::get($path), true);
|
||||
|
||||
if (! is_array($statuses)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $statuses;
|
||||
}
|
||||
|
||||
private function statusesFilePath(): ?string
|
||||
{
|
||||
$configuredPath = config('modules.activators.file.statuses-file');
|
||||
|
||||
$paths = array_filter(array_unique([
|
||||
is_string($configuredPath) ? $configuredPath : null,
|
||||
base_path('modules_statuses.json'),
|
||||
base_path('module_statuses.json'),
|
||||
base_path('module_statues.json'),
|
||||
]));
|
||||
|
||||
foreach ($paths as $path) {
|
||||
if (File::exists($path)) {
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+59
-73
@@ -45,7 +45,6 @@ host('prod')
|
||||
->set('deploy_path', '/opt/laravel-sites/absdev-net/deploy')
|
||||
->set('labels', ['stage' => 'production']);
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Helpers
|
||||
@@ -57,8 +56,8 @@ function absdevCompose(): string
|
||||
$root = get('absdev_root');
|
||||
|
||||
return 'docker compose'
|
||||
. ' -f ' . $root . '/compose.yaml'
|
||||
. ' -f ' . $root . '/compose.deployer.yaml';
|
||||
.' -f '.$root.'/compose.yaml'
|
||||
.' -f '.$root.'/compose.deployer.yaml';
|
||||
}
|
||||
|
||||
function absdevReleasePath(): string
|
||||
@@ -67,14 +66,14 @@ function absdevReleasePath(): string
|
||||
$deployPath = get('deploy_path');
|
||||
$containerRoot = get('absdev_container_root');
|
||||
|
||||
if (!str_starts_with($hostPath, $deployPath . '/releases/')) {
|
||||
if (! str_starts_with($hostPath, $deployPath.'/releases/')) {
|
||||
throw new \RuntimeException(
|
||||
'Unexpected release path: ' . $hostPath
|
||||
'Unexpected release path: '.$hostPath
|
||||
);
|
||||
}
|
||||
|
||||
return $containerRoot
|
||||
. substr($hostPath, strlen($deployPath));
|
||||
.substr($hostPath, strlen($deployPath));
|
||||
}
|
||||
|
||||
function absdevArtisan(string $command): void
|
||||
@@ -83,15 +82,14 @@ function absdevArtisan(string $command): void
|
||||
|
||||
run(
|
||||
absdevCompose()
|
||||
. ' exec -T -u www-data php'
|
||||
. ' sh -c '
|
||||
. escapeshellarg(
|
||||
'cd ' . $path . ' && php artisan ' . $command
|
||||
.' exec -T -u www-data php'
|
||||
.' sh -c '
|
||||
.escapeshellarg(
|
||||
'cd '.$path.' && php artisan '.$command
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Production preflight
|
||||
@@ -105,30 +103,30 @@ task('absdev:preflight', function (): void {
|
||||
$deploy = get('deploy_path');
|
||||
$compose = absdevCompose();
|
||||
|
||||
run('test -f ' . $root . '/compose.deployer.yaml');
|
||||
run('test -f ' . $root . '/nginx.deployer.conf');
|
||||
run('test -f '.$root.'/compose.deployer.yaml');
|
||||
run('test -f '.$root.'/nginx.deployer.conf');
|
||||
|
||||
run('test -L ' . $deploy . '/current');
|
||||
run('test -f ' . $deploy . '/shared/.env');
|
||||
run('test -d ' . $deploy . '/shared/storage');
|
||||
run('test -L '.$deploy.'/current');
|
||||
run('test -f '.$deploy.'/shared/.env');
|
||||
run('test -d '.$deploy.'/shared/storage');
|
||||
|
||||
run($compose . ' config --quiet');
|
||||
run($compose.' config --quiet');
|
||||
|
||||
foreach (['php', 'web'] as $service) {
|
||||
$check = 'test -f /var/www/deploy/current/public/index.php';
|
||||
|
||||
run(
|
||||
$compose
|
||||
. ' exec -T ' . $service
|
||||
. ' sh -c ' . escapeshellarg($check)
|
||||
.' exec -T '.$service
|
||||
.' sh -c '.escapeshellarg($check)
|
||||
);
|
||||
}
|
||||
|
||||
// Ensure the PHP container is using the release tree.
|
||||
run(
|
||||
$compose
|
||||
. ' exec -T php sh -c '
|
||||
. escapeshellarg(
|
||||
.' exec -T php sh -c '
|
||||
.escapeshellarg(
|
||||
'test -f /var/www/deploy/current/artisan'
|
||||
)
|
||||
);
|
||||
@@ -136,14 +134,13 @@ task('absdev:preflight', function (): void {
|
||||
// Ensure Nginx is serving the release-aware document root.
|
||||
run(
|
||||
$compose
|
||||
. ' exec -T web nginx -T 2>&1'
|
||||
. ' | grep -Fq "root /var/www/deploy/current/public;"'
|
||||
.' exec -T web nginx -T 2>&1'
|
||||
.' | grep -Fq "root /var/www/deploy/current/public;"'
|
||||
);
|
||||
|
||||
writeln('<info>Docker deployment preflight passed.</info>');
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Composer
|
||||
@@ -159,17 +156,16 @@ desc('Install production Composer dependencies');
|
||||
task('absdev:composer', function (): void {
|
||||
run(
|
||||
'cd {{release_path}}'
|
||||
. ' && composer install'
|
||||
. ' --no-dev'
|
||||
. ' --prefer-dist'
|
||||
. ' --no-interaction'
|
||||
. ' --no-progress'
|
||||
. ' --optimize-autoloader'
|
||||
. ' --no-scripts'
|
||||
.' && composer install'
|
||||
.' --no-dev'
|
||||
.' --prefer-dist'
|
||||
.' --no-interaction'
|
||||
.' --no-progress'
|
||||
.' --optimize-autoloader'
|
||||
.' --no-scripts'
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Vite
|
||||
@@ -220,7 +216,6 @@ SH;
|
||||
writeln('<info>Production Vite assets built.</info>');
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Release permissions
|
||||
@@ -237,32 +232,31 @@ task('absdev:permissions', function (): void {
|
||||
$path = escapeshellarg(absdevReleasePath());
|
||||
|
||||
$script = 'set -eu; '
|
||||
. 'dir=' . $path . '/bootstrap/cache; '
|
||||
. 'mkdir -p "$dir"; '
|
||||
. 'owner=$(stat -c %u ' . $path . '); '
|
||||
. 'chown -R "$owner":33 "$dir"; '
|
||||
. 'chmod -R ug+rwX "$dir"; '
|
||||
. 'chmod g+s "$dir"';
|
||||
.'dir='.$path.'/bootstrap/cache; '
|
||||
.'mkdir -p "$dir"; '
|
||||
.'owner=$(stat -c %u '.$path.'); '
|
||||
.'chown -R "$owner":33 "$dir"; '
|
||||
.'chmod -R ug+rwX "$dir"; '
|
||||
.'chmod g+s "$dir"';
|
||||
|
||||
run(
|
||||
absdevCompose()
|
||||
. ' exec -T -u root php sh -c '
|
||||
. escapeshellarg($script)
|
||||
.' exec -T -u root php sh -c '
|
||||
.escapeshellarg($script)
|
||||
);
|
||||
|
||||
run(
|
||||
absdevCompose()
|
||||
. ' exec -T -u www-data php sh -c '
|
||||
. escapeshellarg(
|
||||
'test -w ' . $path . '/storage'
|
||||
. ' && test -w ' . $path . '/bootstrap/cache'
|
||||
.' exec -T -u www-data php sh -c '
|
||||
.escapeshellarg(
|
||||
'test -w '.$path.'/storage'
|
||||
.' && test -w '.$path.'/bootstrap/cache'
|
||||
)
|
||||
);
|
||||
|
||||
writeln('<info>Laravel permissions verified.</info>');
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laravel preparation
|
||||
@@ -283,7 +277,6 @@ task('absdev:laravel:prepare', function (): void {
|
||||
writeln('<info>Laravel release prepared.</info>');
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Revision information
|
||||
@@ -303,23 +296,22 @@ task('absdev:revision', function (): void {
|
||||
|
||||
run(
|
||||
'printf %s\\n '
|
||||
. escapeshellarg($revision)
|
||||
. ' > {{release_path}}/REVISION'
|
||||
.escapeshellarg($revision)
|
||||
.' > {{release_path}}/REVISION'
|
||||
);
|
||||
|
||||
run(
|
||||
'date -u +%Y-%m-%dT%H:%M:%SZ'
|
||||
. ' > {{release_path}}/DEPLOYED_AT'
|
||||
.' > {{release_path}}/DEPLOYED_AT'
|
||||
);
|
||||
|
||||
writeln(
|
||||
'<info>Release revision: '
|
||||
. $revision
|
||||
. '</info>'
|
||||
.$revision
|
||||
.'</info>'
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Release validation
|
||||
@@ -338,7 +330,6 @@ task('absdev:validate', function (): void {
|
||||
writeln('<info>Release files validated.</info>');
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Database migrations
|
||||
@@ -356,12 +347,11 @@ desc('Run production database migrations');
|
||||
task('absdev:migrate', function (): void {
|
||||
run(
|
||||
absdevCompose()
|
||||
. ' exec -T -u www-data php'
|
||||
. ' php artisan migrate --force'
|
||||
.' exec -T -u www-data php'
|
||||
.' php artisan migrate --force'
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| PHP-FPM
|
||||
@@ -375,12 +365,11 @@ task('absdev:migrate', function (): void {
|
||||
desc('Restart Docker PHP-FPM to clear OPcache');
|
||||
|
||||
task('absdev:php:restart', function (): void {
|
||||
run(absdevCompose() . ' restart php');
|
||||
run(absdevCompose().' restart php');
|
||||
|
||||
writeln('<info>Docker PHP-FPM restarted.</info>');
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Post-deployment
|
||||
@@ -394,18 +383,17 @@ task('absdev:refresh', function (): void {
|
||||
|
||||
run(
|
||||
$compose
|
||||
. ' exec -T -u www-data php'
|
||||
. ' php artisan view:clear'
|
||||
.' exec -T -u www-data php'
|
||||
.' php artisan view:clear'
|
||||
);
|
||||
|
||||
run(
|
||||
$compose
|
||||
. ' exec -T -u www-data php'
|
||||
. ' php artisan queue:restart'
|
||||
.' exec -T -u www-data php'
|
||||
.' php artisan queue:restart'
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Health check
|
||||
@@ -420,17 +408,16 @@ desc('Check production HTTP response');
|
||||
task('absdev:health', function (): void {
|
||||
run(
|
||||
'curl --fail --silent --show-error'
|
||||
. ' --max-time 20'
|
||||
. ' -H ' . escapeshellarg('Host: absdev.net')
|
||||
. ' -H ' . escapeshellarg('Cache-Control: no-cache')
|
||||
. ' -o /dev/null'
|
||||
. ' http://127.0.0.1:8101/'
|
||||
.' --max-time 20'
|
||||
.' -H '.escapeshellarg('Host: absdev.net')
|
||||
.' -H '.escapeshellarg('Cache-Control: no-cache')
|
||||
.' -o /dev/null'
|
||||
.' http://127.0.0.1:8101/'
|
||||
);
|
||||
|
||||
writeln('<info>Production HTTP health check passed.</info>');
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Deployment sequence
|
||||
@@ -471,7 +458,6 @@ after('deploy:failed', 'deploy:unlock');
|
||||
after('rollback', 'absdev:php:restart');
|
||||
after('rollback', 'absdev:health');
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Repair Laravel cache ownership before release cleanup
|
||||
@@ -505,8 +491,8 @@ SH;
|
||||
|
||||
run(
|
||||
absdevCompose()
|
||||
. ' exec -T -u root php sh -c '
|
||||
. escapeshellarg($script)
|
||||
.' exec -T -u root php sh -c '
|
||||
.escapeshellarg($script)
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user