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
fix(api): save is_auto_deploy_enabled when creating Docker image and Dockerfile applications
Andras Bacsai4559d21b4ca1
diff --git a/app/Http/Controllers/Api/ApplicationsController.php b/app/Http/Controllers/Api/ApplicationsController.phpindex 61bd2bd6f2..5915724f1e 100644--- a/app/Http/Controllers/Api/ApplicationsController.php+++ b/app/Http/Controllers/Api/ApplicationsController.php@@ -2327,6 +2327,10 @@ class ApplicationsController extends Controller$application->fqdn = generateUrl(server: $server, random: $application->uuid);$application->save();}+ if (isset($isAutoDeployEnabled)) {+ $application->settings->is_auto_deploy_enabled = $isAutoDeployEnabled;+ $application->settings->save();+ }if (isset($isForceHttpsEnabled)) {$application->settings->is_force_https_enabled = $isForceHttpsEnabled;$application->settings->save();@@ -2458,6 +2462,10 @@ class ApplicationsController extends Controller$application->fqdn = generateUrl(server: $server, random: $application->uuid);$application->save();}+ if (isset($isAutoDeployEnabled)) {+ $application->settings->is_auto_deploy_enabled = $isAutoDeployEnabled;+ $application->settings->save();+ }if (isset($isForceHttpsEnabled)) {$application->settings->is_force_https_enabled = $isForceHttpsEnabled;$application->settings->save();diff --git a/tests/Feature/Api/ApplicationAutoDeploySettingApiTest.php b/tests/Feature/Api/ApplicationAutoDeploySettingApiTest.phpnew file mode 100644index 0000000000..30a7a133b2--- /dev/null+++ b/tests/Feature/Api/ApplicationAutoDeploySettingApiTest.php@@ -0,0 +1,66 @@+<?php++use App\Models\Application;+use App\Models\Environment;+use App\Models\InstanceSettings;+use App\Models\Project;+use App\Models\Server;+use App\Models\Team;+use App\Models\User;+use Illuminate\Foundation\Testing\RefreshDatabase;+use Illuminate\Support\Facades\Storage;++uses(RefreshDatabase::class);++beforeEach(function () {+ Storage::fake('ssh-keys');+ 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']);+ session(['currentTeam' => $this->team]);++ $this->bearerToken = $this->user->createToken('auto-deploy-api-test', ['*'])->plainTextToken;+ $this->server = Server::factory()->create(['team_id' => $this->team->id]);+ $this->project = Project::factory()->create(['team_id' => $this->team->id]);+ $this->environment = Environment::factory()->create(['project_id' => $this->project->id]);+});++describe('application creation endpoints is_auto_deploy_enabled', function () {+ test('stores the requested auto deploy setting', function (string $endpoint, array $payload, bool $isAutoDeployEnabled) {+ $response = $this->withHeaders(['Authorization' => 'Bearer '.$this->bearerToken])+ ->postJson("/api/v1/applications/{$endpoint}", [+ 'project_uuid' => $this->project->uuid,+ 'environment_uuid' => $this->environment->uuid,+ 'server_uuid' => $this->server->uuid,+ 'is_auto_deploy_enabled' => $isAutoDeployEnabled,+ 'instant_deploy' => false,+ 'autogenerate_domain' => false,+ ...$payload,+ ])+ ->assertCreated();++ $application = Application::where('uuid', $response->json('uuid'))->firstOrFail();++ expect($application->settings->is_auto_deploy_enabled)->toBe($isAutoDeployEnabled);+ })->with([+ 'Docker image' => ['dockerimage', [+ 'docker_registry_image_name' => 'nginx',+ 'docker_registry_image_tag' => 'alpine',+ 'ports_exposes' => '80',+ ]],+ 'Dockerfile' => ['dockerfile', [+ 'dockerfile' => base64_encode("FROM nginx:alpine\nEXPOSE 80"),+ ]],+ 'public repository' => ['public', [+ 'git_repository' => 'https://gitlab.com/coolify/auto-deploy-test',+ 'git_branch' => 'main',+ 'build_pack' => 'dockerfile',+ 'ports_exposes' => '3000',+ ]],+ ])->with([+ 'disabled' => false,+ 'enabled' => true,+ ]);+});