mirror of
https://github.com/coollabsio/coolify.git
synced 2026-03-11 08:55:47 +00:00
Compare commits
10 commits
b2b09476cd
...
89717d1b52
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89717d1b52 | ||
|
|
a5367408d0 | ||
|
|
574f849778 | ||
|
|
19d1662fac | ||
|
|
e3daba0b1d | ||
|
|
5ea12ea07a | ||
|
|
380a34c7d6 | ||
|
|
c879456cff | ||
|
|
e1fd5fab1c | ||
|
|
8cc10ab10a |
5 changed files with 1327 additions and 1622 deletions
|
|
@ -805,9 +805,15 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
|
|||
);
|
||||
|
||||
$this->write_deployment_configurations();
|
||||
$this->execute_remote_command(
|
||||
[executeInDocker($this->deployment_uuid, "cd {$this->basedir} && {$start_command}"), 'hidden' => true],
|
||||
);
|
||||
if ($this->preserveRepository) {
|
||||
$this->execute_remote_command(
|
||||
['command' => "cd {$server_workdir} && {$start_command}", 'hidden' => true],
|
||||
);
|
||||
} else {
|
||||
$this->execute_remote_command(
|
||||
[executeInDocker($this->deployment_uuid, "cd {$this->basedir} && {$start_command}"), 'hidden' => true],
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$command = "{$this->coolify_variables} docker compose";
|
||||
if ($this->preserveRepository) {
|
||||
|
|
|
|||
|
|
@ -51,9 +51,7 @@ class Configuration extends Component
|
|||
$this->environment = $environment;
|
||||
$this->application = $application;
|
||||
|
||||
if ($this->application->deploymentType() === 'deploy_key' && $this->currentRoute === 'project.application.preview-deployments') {
|
||||
return redirect()->route('project.application.configuration', ['project_uuid' => $project->uuid, 'environment_uuid' => $environment->uuid, 'application_uuid' => $application->uuid]);
|
||||
}
|
||||
|
||||
|
||||
if ($this->application->build_pack === 'dockercompose' && $this->currentRoute === 'project.application.healthcheck') {
|
||||
return redirect()->route('project.application.configuration', ['project_uuid' => $project->uuid, 'environment_uuid' => $environment->uuid, 'application_uuid' => $application->uuid]);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
href="{{ route('project.application.scheduled-tasks.show', ['project_uuid' => $project->uuid, 'environment_uuid' => $environment->uuid, 'application_uuid' => $application->uuid]) }}"><span class="menu-item-label">Scheduled Tasks</span></a>
|
||||
<a class="sub-menu-item" {{ wireNavigate() }} wire:current.exact="menu-item-active"
|
||||
href="{{ route('project.application.webhooks', ['project_uuid' => $project->uuid, 'environment_uuid' => $environment->uuid, 'application_uuid' => $application->uuid]) }}"><span class="menu-item-label">Webhooks</span></a>
|
||||
@if ($application->deploymentType() !== 'deploy_key')
|
||||
@if ($application->git_based())
|
||||
<a class="sub-menu-item" {{ wireNavigate() }} wire:current.exact="menu-item-active"
|
||||
href="{{ route('project.application.preview-deployments', ['project_uuid' => $project->uuid, 'environment_uuid' => $environment->uuid, 'application_uuid' => $application->uuid]) }}"><span class="menu-item-label">Preview Deployments</span></a>
|
||||
@endif
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Test to verify that docker-compose custom start commands use the correct
|
||||
* execution context based on the preserveRepository setting.
|
||||
*
|
||||
* When preserveRepository is enabled, the compose file and .env file are
|
||||
* written to the host at /data/coolify/applications/{uuid}/. The start
|
||||
* command must run on the host (not inside the helper container) so it
|
||||
* can access these files.
|
||||
*
|
||||
* When preserveRepository is disabled, the files are inside the helper
|
||||
* container at /artifacts/{uuid}/, so the command must run inside the
|
||||
* container via executeInDocker().
|
||||
*
|
||||
* @see https://github.com/coollabsio/coolify/issues/8417
|
||||
*/
|
||||
it('generates host command (not executeInDocker) when preserveRepository is true', function () {
|
||||
$deploymentUuid = 'test-deployment-uuid';
|
||||
$serverWorkdir = '/data/coolify/applications/app-uuid';
|
||||
$basedir = '/artifacts/test-deployment-uuid';
|
||||
$preserveRepository = true;
|
||||
|
||||
$startCommand = 'docker compose -f /data/coolify/applications/app-uuid/compose.yml --env-file /data/coolify/applications/app-uuid/.env --profile all up -d';
|
||||
|
||||
// Simulate the logic from ApplicationDeploymentJob::deploy_docker_compose_buildpack()
|
||||
if ($preserveRepository) {
|
||||
$command = "cd {$serverWorkdir} && {$startCommand}";
|
||||
} else {
|
||||
$command = executeInDocker($deploymentUuid, "cd {$basedir} && {$startCommand}");
|
||||
}
|
||||
|
||||
// When preserveRepository is true, the command should NOT be wrapped in executeInDocker
|
||||
expect($command)->not->toContain('docker exec');
|
||||
expect($command)->toStartWith("cd {$serverWorkdir}");
|
||||
expect($command)->toContain($startCommand);
|
||||
});
|
||||
|
||||
it('generates executeInDocker command when preserveRepository is false', function () {
|
||||
$deploymentUuid = 'test-deployment-uuid';
|
||||
$serverWorkdir = '/data/coolify/applications/app-uuid';
|
||||
$basedir = '/artifacts/test-deployment-uuid';
|
||||
$workdir = '/artifacts/test-deployment-uuid/backend';
|
||||
$preserveRepository = false;
|
||||
|
||||
$startCommand = 'docker compose -f /artifacts/test-deployment-uuid/backend/compose.yml --env-file /artifacts/test-deployment-uuid/backend/.env --profile all up -d';
|
||||
|
||||
// Simulate the logic from ApplicationDeploymentJob::deploy_docker_compose_buildpack()
|
||||
if ($preserveRepository) {
|
||||
$command = "cd {$serverWorkdir} && {$startCommand}";
|
||||
} else {
|
||||
$command = executeInDocker($deploymentUuid, "cd {$basedir} && {$startCommand}");
|
||||
}
|
||||
|
||||
// When preserveRepository is false, the command SHOULD be wrapped in executeInDocker
|
||||
expect($command)->toContain('docker exec');
|
||||
expect($command)->toContain($deploymentUuid);
|
||||
expect($command)->toContain("cd {$basedir}");
|
||||
});
|
||||
|
||||
it('uses host paths for env-file when preserveRepository is true', function () {
|
||||
$serverWorkdir = '/data/coolify/applications/app-uuid';
|
||||
$composeLocation = '/compose.yml';
|
||||
$preserveRepository = true;
|
||||
|
||||
$workdirPath = $preserveRepository ? $serverWorkdir : '/artifacts/deployment-uuid/backend';
|
||||
$startCommand = injectDockerComposeFlags(
|
||||
'docker compose --profile all up -d',
|
||||
"{$workdirPath}{$composeLocation}",
|
||||
"{$workdirPath}/.env"
|
||||
);
|
||||
|
||||
// Verify the injected paths point to the host filesystem
|
||||
expect($startCommand)->toContain("--env-file {$serverWorkdir}/.env");
|
||||
expect($startCommand)->toContain("-f {$serverWorkdir}{$composeLocation}");
|
||||
});
|
||||
|
||||
it('uses container paths for env-file when preserveRepository is false', function () {
|
||||
$workdir = '/artifacts/deployment-uuid/backend';
|
||||
$composeLocation = '/compose.yml';
|
||||
$preserveRepository = false;
|
||||
$serverWorkdir = '/data/coolify/applications/app-uuid';
|
||||
|
||||
$workdirPath = $preserveRepository ? $serverWorkdir : $workdir;
|
||||
$startCommand = injectDockerComposeFlags(
|
||||
'docker compose --profile all up -d',
|
||||
"{$workdirPath}{$composeLocation}",
|
||||
"{$workdirPath}/.env"
|
||||
);
|
||||
|
||||
// Verify the injected paths point to the container filesystem
|
||||
expect($startCommand)->toContain("--env-file {$workdir}/.env");
|
||||
expect($startCommand)->toContain("-f {$workdir}{$composeLocation}");
|
||||
expect($startCommand)->not->toContain('/data/coolify/applications/');
|
||||
});
|
||||
Loading…
Reference in a new issue