Skip to content

Commit

Permalink
fix: use nixpacks predefined build variables, but still could update …
Browse files Browse the repository at this point in the history
…the default values from Coolify
  • Loading branch information
andrasbacsai committed Dec 18, 2024
1 parent c7a01eb commit f2c7fbf
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions app/Jobs/ApplicationDeploymentJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue

private ?string $nixpacks_plan = null;

private Collection $nixpacks_plan_json;

private ?string $nixpacks_type = null;

private string $dockerfile_location = '/Dockerfile';
Expand Down Expand Up @@ -1545,7 +1547,7 @@ private function generate_nixpacks_confs()

// Do any modifications here
$this->generate_env_variables();
$merged_envs = $this->env_args->merge(collect(data_get($parsed, 'variables', [])));
$merged_envs = collect(data_get($parsed, 'variables', []))->merge($this->env_args);
$aptPkgs = data_get($parsed, 'phases.setup.aptPkgs', []);
if (count($aptPkgs) === 0) {
$aptPkgs = ['curl', 'wget'];
Expand All @@ -1570,6 +1572,7 @@ private function generate_nixpacks_confs()
$this->elixir_finetunes();
}
$this->nixpacks_plan = json_encode($parsed, JSON_PRETTY_PRINT);
$this->nixpacks_plan_json = collect($parsed);
$this->application_deployment_queue->addLogEntry("Final Nixpacks plan: {$this->nixpacks_plan}", hidden: true);
if ($this->nixpacks_type === 'rust') {
// temporary: disable healthcheck for rust because the start phase does not have curl/wget
Expand Down Expand Up @@ -2278,18 +2281,10 @@ private function start_by_compose_file()

private function generate_build_env_variables()
{
$this->build_args = collect(["--build-arg SOURCE_COMMIT=\"{$this->commit}\""]);
if ($this->pull_request_id === 0) {
foreach ($this->application->build_environment_variables as $env) {
$value = escapeshellarg($env->real_value);
$this->build_args->push("--build-arg {$env->key}={$value}");
}
} else {
foreach ($this->application->build_environment_variables_preview as $env) {
$value = escapeshellarg($env->real_value);
$this->build_args->push("--build-arg {$env->key}={$value}");
}
}
$variables = collect($this->nixpacks_plan_json->get('variables'));
$this->build_args = $variables->map(function ($value, $key) {
return "--build-arg {$key}={$value}";
});
}

private function add_build_env_variables_to_dockerfile()
Expand Down

0 comments on commit f2c7fbf

Please sign in to comment.