An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat(api): allow preview deployments on app create
Andras Bacsaicf12e1d7ef4f
diff --git a/bootstrap/helpers/api.php b/bootstrap/helpers/api.phpindex 6a288a0642..757343f4d8 100644--- a/bootstrap/helpers/api.php+++ b/bootstrap/helpers/api.php@@ -97,6 +97,7 @@ function sharedDataApplications()'is_spa' => 'boolean','is_auto_deploy_enabled' => 'boolean','is_force_https_enabled' => 'boolean',+ 'is_preview_deployments_enabled' => 'boolean','static_image' => Rule::enum(StaticImageTypes::class),'domains' => 'string|nullable','redirect' => Rule::enum(RedirectTypes::class),@@ -198,6 +199,7 @@ function removeUnnecessaryFieldsFromRequest(Request $request)$request->offsetUnset('is_spa');$request->offsetUnset('is_auto_deploy_enabled');$request->offsetUnset('is_force_https_enabled');+ $request->offsetUnset('is_preview_deployments_enabled');$request->offsetUnset('connect_to_docker_network');$request->offsetUnset('force_domain_override');$request->offsetUnset('autogenerate_domain');diff --git a/database/migrations/2026_05_29_000000_encrypt_application_deployment_configuration_columns.php b/database/migrations/2026_05_29_000000_encrypt_application_deployment_configuration_columns.phpindex 123fd226dd..95500cfef5 100644--- a/database/migrations/2026_05_29_000000_encrypt_application_deployment_configuration_columns.php+++ b/database/migrations/2026_05_29_000000_encrypt_application_deployment_configuration_columns.php@@ -11,12 +11,20 @@ return new class extends Migration*/public function up(): void{+ if (DB::getDriverName() === 'sqlite') {+ return;+ }+DB::statement('ALTER TABLE application_deployment_queues ALTER COLUMN configuration_snapshot TYPE text USING configuration_snapshot::text');DB::statement('ALTER TABLE application_deployment_queues ALTER COLUMN configuration_diff TYPE text USING configuration_diff::text');}public function down(): void{+ if (DB::getDriverName() === 'sqlite') {+ return;+ }+DB::statement('ALTER TABLE application_deployment_queues ALTER COLUMN configuration_snapshot TYPE json USING configuration_snapshot::json');DB::statement('ALTER TABLE application_deployment_queues ALTER COLUMN configuration_diff TYPE json USING configuration_diff::json');}diff --git a/openapi.json b/openapi.jsonindex ca445ade00..71a7f9c1ff 100644--- a/openapi.json+++ b/openapi.json@@ -165,6 +165,10 @@"type": "boolean","description": "The flag to indicate if HTTPS is forced. Defaults to true."},+ "is_preview_deployments_enabled": {+ "type": "boolean",+ "description": "Enable preview deployments for pull requests."+ },"static_image": {"type": "string","enum": [@@ -615,6 +619,10 @@"type": "boolean","description": "The flag to indicate if HTTPS is forced. Defaults to true."},+ "is_preview_deployments_enabled": {+ "type": "boolean",+ "description": "Enable preview deployments for pull requests."+ },"static_image": {"type": "string","enum": [@@ -1065,6 +1073,10 @@"type": "boolean","description": "The flag to indicate if HTTPS is forced. Defaults to true."},+ "is_preview_deployments_enabled": {+ "type": "boolean",+ "description": "Enable preview deployments for pull requests."+ },"static_image": {"type": "string","enum": [@@ -1626,6 +1638,10 @@"type": "boolean","description": "The flag to indicate if HTTPS is forced. Defaults to true."},+ "is_preview_deployments_enabled": {+ "type": "boolean",+ "description": "Enable preview deployments for pull requests."+ },"use_build_server": {"type": "boolean","nullable": true,@@ -1961,6 +1977,10 @@"type": "boolean","description": "The flag to indicate if HTTPS is forced. Defaults to true."},+ "is_preview_deployments_enabled": {+ "type": "boolean",+ "description": "Enable preview deployments for pull requests."+ },"use_build_server": {"type": "boolean","nullable": true,@@ -2333,6 +2353,10 @@"type": "boolean","description": "The flag to indicate if HTTPS is forced. Defaults to true."},+ "is_preview_deployments_enabled": {+ "type": "boolean",+ "description": "Enable preview deployments for pull requests."+ },"install_command": {"type": "string","description": "The install command."diff --git a/openapi.yaml b/openapi.yamlindex 6182cacd37..e8dba0a541 100644--- a/openapi.yaml+++ b/openapi.yaml@@ -118,6 +118,9 @@ paths:is_force_https_enabled:type: booleandescription: 'The flag to indicate if HTTPS is forced. Defaults to true.'+ is_preview_deployments_enabled:+ type: boolean+ description: 'Enable preview deployments for pull requests.'static_image:type: stringenum: ['nginx:alpine']@@ -405,6 +408,9 @@ paths:is_force_https_enabled:type: booleandescription: 'The flag to indicate if HTTPS is forced. Defaults to true.'+ is_preview_deployments_enabled:+ type: boolean+ description: 'Enable preview deployments for pull requests.'static_image:type: stringenum: ['nginx:alpine']@@ -692,6 +698,9 @@ paths:is_force_https_enabled:type: booleandescription: 'The flag to indicate if HTTPS is forced. Defaults to true.'+ is_preview_deployments_enabled:+ type: boolean+ description: 'Enable preview deployments for pull requests.'static_image:type: stringenum: ['nginx:alpine']@@ -1063,6 +1072,9 @@ paths:is_force_https_enabled:type: booleandescription: 'The flag to indicate if HTTPS is forced. Defaults to true.'+ is_preview_deployments_enabled:+ type: boolean+ description: 'Enable preview deployments for pull requests.'use_build_server:type: booleannullable: true@@ -1277,6 +1289,9 @@ paths:is_force_https_enabled:type: booleandescription: 'The flag to indicate if HTTPS is forced. Defaults to true.'+ is_preview_deployments_enabled:+ type: boolean+ description: 'Enable preview deployments for pull requests.'use_build_server:type: booleannullable: true@@ -1507,6 +1522,9 @@ paths:is_force_https_enabled:type: booleandescription: 'The flag to indicate if HTTPS is forced. Defaults to true.'+ is_preview_deployments_enabled:+ type: boolean+ description: 'Enable preview deployments for pull requests.'install_command:type: stringdescription: 'The install command.'diff --git a/tests/Feature/ApplicationPreviewDeploymentsApiTest.php b/tests/Feature/ApplicationPreviewDeploymentsApiTest.phpindex 8752d81ef4..34b6706902 100644--- a/tests/Feature/ApplicationPreviewDeploymentsApiTest.php+++ b/tests/Feature/ApplicationPreviewDeploymentsApiTest.php@@ -1,7 +1,7 @@<?phpuse App\Models\Application;-use App\Models\Environment;+use App\Models\InstanceSettings;use App\Models\Project;use App\Models\Server;use App\Models\StandaloneDocker;@@ -13,6 +13,10 @@ use Visus\Cuid2\Cuid2;uses(RefreshDatabase::class);beforeEach(function () {+ config(['app.maintenance.driver' => 'file']);++ InstanceSettings::unguarded(fn () => InstanceSettings::firstOrCreate(['id' => 0]));+$this->team = Team::factory()->create();$this->user = User::factory()->create();$this->team->members()->attach($this->user->id, ['role' => 'owner']);@@ -106,3 +110,42 @@ describe('PATCH /api/v1/applications/{uuid} is_preview_deployments_enabled', fun$response->assertStatus(422);});});++describe('POST /api/v1/applications/public is_preview_deployments_enabled', function () {+ test('can enable preview deployments on create', function () {+ $response = $this->withHeaders(previewDeploymentsAuthHeaders($this->bearerToken))+ ->postJson('/api/v1/applications/public', [+ 'project_uuid' => $this->project->uuid,+ 'environment_uuid' => $this->environment->uuid,+ 'server_uuid' => $this->server->uuid,+ 'git_repository' => 'https://gitlab.com/coolify/test-preview-app',+ 'git_branch' => 'main',+ 'build_pack' => 'nixpacks',+ 'ports_exposes' => '3000',+ 'is_preview_deployments_enabled' => true,+ 'autogenerate_domain' => false,+ ]);++ $response->assertCreated();++ $application = Application::where('uuid', $response->json('uuid'))->firstOrFail();+ expect($application->settings->is_preview_deployments_enabled)->toBeTrue();+ });++ test('rejects non-boolean value on create', function () {+ $response = $this->withHeaders(previewDeploymentsAuthHeaders($this->bearerToken))+ ->postJson('/api/v1/applications/public', [+ 'project_uuid' => $this->project->uuid,+ 'environment_uuid' => $this->environment->uuid,+ 'server_uuid' => $this->server->uuid,+ 'git_repository' => 'https://gitlab.com/coolify/test-preview-app',+ 'git_branch' => 'main',+ 'build_pack' => 'nixpacks',+ 'ports_exposes' => '3000',+ 'is_preview_deployments_enabled' => 'yes',+ 'autogenerate_domain' => false,+ ]);++ $response->assertUnprocessable();+ });+});