mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-16 06:14:21 +00:00
Fix: Docker build args injection regex to support service names (#7433)
This commit is contained in:
4 files changed
+141
-4
No files matched your search
@@ -670,13 +670,20 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
|
||||
$build_command = "DOCKER_BUILDKIT=1 {$build_command}";
|
||||
}
|
||||
|
||||
// Append build arguments if not using build secrets (matching default behavior)
|
||||
// Inject build arguments after build subcommand if not using build secrets
|
||||
if (! $this->application->settings->use_build_secrets && $this->build_args instanceof \Illuminate\Support\Collection && $this->build_args->isNotEmpty()) {
|
||||
$build_args_string = $this->build_args->implode(' ');
|
||||
// Escape single quotes for bash -c context used by executeInDocker
|
||||
$build_args_string = str_replace("'", "'\\''", $build_args_string);
|
||||
$build_command .= " {$build_args_string}";
|
||||
$this->application_deployment_queue->addLogEntry('Adding build arguments to custom Docker Compose build command.');
|
||||
|
||||
// Inject build args right after 'build' subcommand (not at the end)
|
||||
$original_command = $build_command;
|
||||
$build_command = injectDockerComposeBuildArgs($build_command, $build_args_string);
|
||||
|
||||
// Only log if build args were actually injected (command was modified)
|
||||
if ($build_command !== $original_command) {
|
||||
$this->application_deployment_queue->addLogEntry('Adding build arguments to custom Docker Compose build command.');
|
||||
}
|
||||
}
|
||||
|
||||
$this->execute_remote_command(
|
||||
|
||||
@@ -1018,11 +1018,27 @@ class General extends Component
|
||||
// Use relative path for clarity in preview (e.g., ./backend/docker-compose.yaml)
|
||||
// Actual deployment uses absolute path: /artifacts/{deployment_uuid}{base_directory}{docker_compose_location}
|
||||
// Build-time env path references ApplicationDeploymentJob::BUILD_TIME_ENV_PATH as source of truth
|
||||
return injectDockerComposeFlags(
|
||||
$command = injectDockerComposeFlags(
|
||||
$this->dockerComposeCustomBuildCommand,
|
||||
".{$normalizedBase}{$this->dockerComposeLocation}",
|
||||
\App\Jobs\ApplicationDeploymentJob::BUILD_TIME_ENV_PATH
|
||||
);
|
||||
|
||||
// Inject build args if not using build secrets
|
||||
if (! $this->application->settings->use_build_secrets) {
|
||||
$buildTimeEnvs = $this->application->environment_variables()
|
||||
->where('is_buildtime', true)
|
||||
->get();
|
||||
|
||||
if ($buildTimeEnvs->isNotEmpty()) {
|
||||
$buildArgs = generateDockerBuildArgs($buildTimeEnvs);
|
||||
$buildArgsString = $buildArgs->implode(' ');
|
||||
|
||||
$command = injectDockerComposeBuildArgs($command, $buildArgsString);
|
||||
}
|
||||
}
|
||||
|
||||
return $command;
|
||||
}
|
||||
|
||||
public function getDockerComposeStartCommandPreviewProperty(): string
|
||||
|
||||
Reference in new issue
Block a user