Phase 26: Isolated Laravel deployment
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
"""Source for a minimal Laravel acceptance fixture with a real queue and schedule."""
|
||||
|
||||
BOOTSTRAP = """<?php
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
|
||||
use Illuminate\\Foundation\\Application;
|
||||
use Illuminate\\Support\\Facades\\DB;
|
||||
use Illuminate\\Support\\Facades\\Route;
|
||||
use Illuminate\\Support\\Facades\\Schedule;
|
||||
|
||||
class FixtureJob {
|
||||
public function fire($job, $data) {
|
||||
$job->delete();
|
||||
file_put_contents(getenv('FIXTURE_STATE').'/queue', $data['release']);
|
||||
}
|
||||
}
|
||||
|
||||
$app = Application::configure(basePath: __DIR__)
|
||||
->withRouting(using: function () {
|
||||
Route::get('/up', function () {
|
||||
if (DB::table('fixture')->count() !== 1) {
|
||||
abort(503);
|
||||
}
|
||||
return trim(file_get_contents(__DIR__.'/RELEASE'));
|
||||
});
|
||||
})
|
||||
->withSchedule(function ($schedule) {
|
||||
$schedule->call(function () {
|
||||
file_put_contents(getenv('FIXTURE_STATE').'/scheduler',
|
||||
trim(file_get_contents(__DIR__.'/RELEASE')));
|
||||
})->everySecond();
|
||||
})
|
||||
->withExceptions()
|
||||
->create();
|
||||
$app->useStoragePath(getenv('FIXTURE_STATE').'/storage');
|
||||
return $app;
|
||||
"""
|
||||
|
||||
PUBLIC = """<?php
|
||||
$app = require dirname(__DIR__).'/app.php';
|
||||
$app->handleRequest(Illuminate\\Http\\Request::capture());
|
||||
"""
|
||||
|
||||
ARTISAN = """<?php
|
||||
$app = require __DIR__.'/app.php';
|
||||
exit($app->handleCommand(new Symfony\\Component\\Console\\Input\\ArgvInput));
|
||||
"""
|
||||
|
||||
DATABASE = """<?php
|
||||
return [
|
||||
'default' => 'sqlite',
|
||||
'connections' => [
|
||||
'sqlite' => [
|
||||
'driver' => 'sqlite',
|
||||
'database' => getenv('FIXTURE_DATABASE'),
|
||||
'prefix' => '',
|
||||
'foreign_key_constraints' => true,
|
||||
],
|
||||
],
|
||||
'migrations' => ['table' => 'migrations'],
|
||||
];
|
||||
"""
|
||||
|
||||
QUEUE = """<?php
|
||||
return [
|
||||
'default' => 'database',
|
||||
'connections' => [
|
||||
'database' => [
|
||||
'driver' => 'database', 'table' => 'jobs',
|
||||
'queue' => 'default', 'retry_after' => 10,
|
||||
],
|
||||
],
|
||||
'failed' => ['driver' => 'null'],
|
||||
];
|
||||
"""
|
||||
|
||||
MIGRATION = """<?php
|
||||
use Illuminate\\Database\\Migrations\\Migration;
|
||||
use Illuminate\\Support\\Facades\\DB;
|
||||
use Illuminate\\Support\\Facades\\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('fixture', function ($table) { $table->id(); });
|
||||
DB::table('fixture')->insert(['id' => 1]);
|
||||
Schema::create('jobs', function ($table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
}
|
||||
};
|
||||
"""
|
||||
|
||||
SOURCES = {
|
||||
"app.php": BOOTSTRAP,
|
||||
"artisan": ARTISAN,
|
||||
"public/index.php": PUBLIC,
|
||||
"config/database.php": DATABASE,
|
||||
"config/queue.php": QUEUE,
|
||||
"database/migrations/2026_01_01_000000_fixture.php": MIGRATION,
|
||||
"package.json": "{}\n",
|
||||
"package-lock.json": "{}\n",
|
||||
"public/build/manifest.json": "{}\n",
|
||||
}
|
||||
Reference in New Issue
Block a user