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(railpack): create empty build-time env file
Andras Bacsai2dc34f61ffde
diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.phpindex 6b72fb3398..c94e290281 100644--- a/app/Jobs/ApplicationDeploymentJob.php+++ b/app/Jobs/ApplicationDeploymentJob.php@@ -1833,8 +1833,8 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue]);}- } elseif ($this->build_pack === 'dockercompose' || $this->build_pack === 'dockerfile') {- // For Docker Compose and Dockerfile, create an empty .env file even if there are no build-time variables+ } elseif (in_array($this->build_pack, ['dockercompose', 'dockerfile', 'railpack'], true)) {+ // For build packs that source the build-time .env file, create an empty file even if there are no build-time variables// This ensures the file exists when referenced in build commands$this->application_deployment_queue->addLogEntry('Creating empty build-time .env file in /artifacts (no build-time variables defined).', hidden: true);diff --git a/tests/Unit/ApplicationDeploymentRailpackConfigTest.php b/tests/Unit/ApplicationDeploymentRailpackConfigTest.phpindex 77815a5237..c67761faa9 100644--- a/tests/Unit/ApplicationDeploymentRailpackConfigTest.php+++ b/tests/Unit/ApplicationDeploymentRailpackConfigTest.php@@ -3,6 +3,8 @@use App\Exceptions\DeploymentException;use App\Jobs\ApplicationDeploymentJob;use App\Models\Application;+use App\Models\ApplicationSetting;+use App\Models\EnvironmentVariable;use Illuminate\Support\Collection;use Tests\TestCase;@@ -280,3 +282,41 @@ it('interpolates build-time variable references for railpack by sourcing the buiexpect($command)->toContain("--secret 'id=BETTER_AUTH_URL,env=BETTER_AUTH_URL'");expect($command)->toContain("--secret 'id=COOLIFY_URL,env=COOLIFY_URL'");});++it('creates an empty build-time env file for railpack when there are no generated build-time variables', function () {+ [$job, $reflection] = makeRailpackDeploymentJob([+ 'build_pack' => 'railpack',+ 'compose_parsing_version' => '3',+ ]);++ $applicationProperty = $reflection->getProperty('application');+ $applicationProperty->setAccessible(true);+ $application = $applicationProperty->getValue($job);+ $application->setRelation('settings', new ApplicationSetting([+ 'include_source_commit_in_build' => false,+ 'is_env_sorting_enabled' => false,+ ]));+ $application->setRelation('environment_variables', collect([+ new EnvironmentVariable(['key' => 'COOLIFY_FQDN']),+ new EnvironmentVariable(['key' => 'COOLIFY_URL']),+ new EnvironmentVariable(['key' => 'COOLIFY_BRANCH']),+ new EnvironmentVariable(['key' => 'COOLIFY_RESOURCE_UUID']),+ ]));++ foreach ([+ 'application_deployment_queue' => new class+ {+ public function addLogEntry(string $message, string $type = 'info', bool $hidden = false): void {}+ },+ 'build_pack' => 'railpack',+ 'pull_request_id' => 0,+ ] as $property => $value) {+ $reflectionProperty = $reflection->getProperty($property);+ $reflectionProperty->setAccessible(true);+ $reflectionProperty->setValue($job, $value);+ }++ invokeRailpackMethod($job, $reflection, 'save_buildtime_environment_variables');++ expect(collect($job->recordedCommands)->flatten()->implode(' '))->toContain('touch /artifacts/build-time.env');+});