fix: parser
feat: new coolify envs for fqdn and urls
This commit is contained in:
@@ -443,7 +443,6 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
|
|||||||
$fileStorage->deleteStorageOnServer();
|
$fileStorage->deleteStorageOnServer();
|
||||||
$fileStorage->saveStorageOnServer();
|
$fileStorage->saveStorageOnServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -476,7 +475,8 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
|
|||||||
}
|
}
|
||||||
$this->docker_compose_base64 = base64_encode($yaml);
|
$this->docker_compose_base64 = base64_encode($yaml);
|
||||||
$this->execute_remote_command([
|
$this->execute_remote_command([
|
||||||
executeInDocker($this->deployment_uuid, "echo '{$this->docker_compose_base64}' | base64 -d | tee {$this->workdir}{$this->docker_compose_location} > /dev/null"), 'hidden' => true,
|
executeInDocker($this->deployment_uuid, "echo '{$this->docker_compose_base64}' | base64 -d | tee {$this->workdir}{$this->docker_compose_location} > /dev/null"),
|
||||||
|
'hidden' => true,
|
||||||
]);
|
]);
|
||||||
// Build new container to limit downtime.
|
// Build new container to limit downtime.
|
||||||
$this->application_deployment_queue->addLogEntry('Pulling & building required images.');
|
$this->application_deployment_queue->addLogEntry('Pulling & building required images.');
|
||||||
@@ -506,9 +506,13 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
|
|||||||
// TODO
|
// TODO
|
||||||
} else {
|
} else {
|
||||||
$this->execute_remote_command([
|
$this->execute_remote_command([
|
||||||
"docker network inspect '{$networkId}' >/dev/null 2>&1 || docker network create --attachable '{$networkId}' >/dev/null || true", 'hidden' => true, 'ignore_errors' => true,
|
"docker network inspect '{$networkId}' >/dev/null 2>&1 || docker network create --attachable '{$networkId}' >/dev/null || true",
|
||||||
|
'hidden' => true,
|
||||||
|
'ignore_errors' => true,
|
||||||
], [
|
], [
|
||||||
"docker network connect {$networkId} coolify-proxy || true", 'hidden' => true, 'ignore_errors' => true,
|
"docker network connect {$networkId} coolify-proxy || true",
|
||||||
|
'hidden' => true,
|
||||||
|
'ignore_errors' => true,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,7 +565,6 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
|
|||||||
);
|
);
|
||||||
$this->write_deployment_configurations();
|
$this->write_deployment_configurations();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -744,7 +747,8 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
|
|||||||
$this->application_deployment_queue->addLogEntry("Pushing image to docker registry ({$this->production_image_name}).");
|
$this->application_deployment_queue->addLogEntry("Pushing image to docker registry ({$this->production_image_name}).");
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, "docker push {$this->production_image_name}"), 'hidden' => true,
|
executeInDocker($this->deployment_uuid, "docker push {$this->production_image_name}"),
|
||||||
|
'hidden' => true,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
if ($this->application->docker_registry_image_tag) {
|
if ($this->application->docker_registry_image_tag) {
|
||||||
@@ -752,10 +756,14 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
|
|||||||
$this->application_deployment_queue->addLogEntry("Tagging and pushing image with {$this->application->docker_registry_image_tag} tag.");
|
$this->application_deployment_queue->addLogEntry("Tagging and pushing image with {$this->application->docker_registry_image_tag} tag.");
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, "docker tag {$this->production_image_name} {$this->application->docker_registry_image_name}:{$this->application->docker_registry_image_tag}"), 'ignore_errors' => true, 'hidden' => true,
|
executeInDocker($this->deployment_uuid, "docker tag {$this->production_image_name} {$this->application->docker_registry_image_name}:{$this->application->docker_registry_image_tag}"),
|
||||||
|
'ignore_errors' => true,
|
||||||
|
'hidden' => true,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, "docker push {$this->application->docker_registry_image_name}:{$this->application->docker_registry_image_tag}"), 'ignore_errors' => true, 'hidden' => true,
|
executeInDocker($this->deployment_uuid, "docker push {$this->application->docker_registry_image_name}:{$this->application->docker_registry_image_tag}"),
|
||||||
|
'ignore_errors' => true,
|
||||||
|
'hidden' => true,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -852,14 +860,20 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
|
|||||||
private function check_image_locally_or_remotely()
|
private function check_image_locally_or_remotely()
|
||||||
{
|
{
|
||||||
$this->execute_remote_command([
|
$this->execute_remote_command([
|
||||||
"docker images -q {$this->production_image_name} 2>/dev/null", 'hidden' => true, 'save' => 'local_image_found',
|
"docker images -q {$this->production_image_name} 2>/dev/null",
|
||||||
|
'hidden' => true,
|
||||||
|
'save' => 'local_image_found',
|
||||||
]);
|
]);
|
||||||
if (str($this->saved_outputs->get('local_image_found'))->isEmpty() && $this->application->docker_registry_image_name) {
|
if (str($this->saved_outputs->get('local_image_found'))->isEmpty() && $this->application->docker_registry_image_name) {
|
||||||
$this->execute_remote_command([
|
$this->execute_remote_command([
|
||||||
"docker pull {$this->production_image_name} 2>/dev/null", 'ignore_errors' => true, 'hidden' => true,
|
"docker pull {$this->production_image_name} 2>/dev/null",
|
||||||
|
'ignore_errors' => true,
|
||||||
|
'hidden' => true,
|
||||||
]);
|
]);
|
||||||
$this->execute_remote_command([
|
$this->execute_remote_command([
|
||||||
"docker images -q {$this->production_image_name} 2>/dev/null", 'hidden' => true, 'save' => 'local_image_found',
|
"docker images -q {$this->production_image_name} 2>/dev/null",
|
||||||
|
'hidden' => true,
|
||||||
|
'save' => 'local_image_found',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -892,12 +906,14 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
|
|||||||
}
|
}
|
||||||
if ($this->application->environment_variables_preview->where('key', 'COOLIFY_FQDN')->isEmpty()) {
|
if ($this->application->environment_variables_preview->where('key', 'COOLIFY_FQDN')->isEmpty()) {
|
||||||
$envs->push("COOLIFY_FQDN={$this->preview->fqdn}");
|
$envs->push("COOLIFY_FQDN={$this->preview->fqdn}");
|
||||||
|
$envs->push("COOLIFY_DOMAIN_URL={$this->preview->fqdn}");
|
||||||
}
|
}
|
||||||
if ($this->application->environment_variables_preview->where('key', 'COOLIFY_URL')->isEmpty()) {
|
if ($this->application->environment_variables_preview->where('key', 'COOLIFY_URL')->isEmpty()) {
|
||||||
$url = str($this->preview->fqdn)->replace('http://', '')->replace('https://', '');
|
$url = str($this->preview->fqdn)->replace('http://', '')->replace('https://', '');
|
||||||
$envs->push("COOLIFY_URL={$url}");
|
$envs->push("COOLIFY_URL={$url}");
|
||||||
|
$envs->push("COOLIFY_DOMAIN_FQDN={$url}");
|
||||||
}
|
}
|
||||||
if ($this->application->compose_parsing_version === '1' || $this->application->compose_parsing_version === '2') {
|
if ($this->application->build_pack !== 'dockercompose' || $this->application->compose_parsing_version === '1' || $this->application->compose_parsing_version === '2') {
|
||||||
if ($this->application->environment_variables_preview->where('key', 'COOLIFY_BRANCH')->isEmpty()) {
|
if ($this->application->environment_variables_preview->where('key', 'COOLIFY_BRANCH')->isEmpty()) {
|
||||||
$envs->push("COOLIFY_BRANCH={$local_branch}");
|
$envs->push("COOLIFY_BRANCH={$local_branch}");
|
||||||
}
|
}
|
||||||
@@ -940,12 +956,14 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
|
|||||||
}
|
}
|
||||||
if ($this->application->environment_variables->where('key', 'COOLIFY_FQDN')->isEmpty()) {
|
if ($this->application->environment_variables->where('key', 'COOLIFY_FQDN')->isEmpty()) {
|
||||||
$envs->push("COOLIFY_FQDN={$this->application->fqdn}");
|
$envs->push("COOLIFY_FQDN={$this->application->fqdn}");
|
||||||
|
$envs->push("COOLIFY_DOMAIN_URL={$this->application->fqdn}");
|
||||||
}
|
}
|
||||||
if ($this->application->environment_variables->where('key', 'COOLIFY_URL')->isEmpty()) {
|
if ($this->application->environment_variables->where('key', 'COOLIFY_URL')->isEmpty()) {
|
||||||
$url = str($this->application->fqdn)->replace('http://', '')->replace('https://', '');
|
$url = str($this->application->fqdn)->replace('http://', '')->replace('https://', '');
|
||||||
$envs->push("COOLIFY_URL={$url}");
|
$envs->push("COOLIFY_URL={$url}");
|
||||||
|
$envs->push("COOLIFY_DOMAIN_FQDN={$url}");
|
||||||
}
|
}
|
||||||
if ($this->application->compose_parsing_version === '1' || $this->application->compose_parsing_version === '2') {
|
if ($this->application->build_pack !== 'dockercompose' || $this->application->compose_parsing_version === '1' || $this->application->compose_parsing_version === '2') {
|
||||||
if ($this->application->environment_variables->where('key', 'COOLIFY_BRANCH')->isEmpty()) {
|
if ($this->application->environment_variables->where('key', 'COOLIFY_BRANCH')->isEmpty()) {
|
||||||
$envs->push("COOLIFY_BRANCH={$local_branch}");
|
$envs->push("COOLIFY_BRANCH={$local_branch}");
|
||||||
}
|
}
|
||||||
@@ -1411,7 +1429,8 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
|
|||||||
}
|
}
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
$importCommands, 'hidden' => true,
|
$importCommands,
|
||||||
|
'hidden' => true,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->create_workdir();
|
$this->create_workdir();
|
||||||
@@ -1621,7 +1640,10 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
|
|||||||
// Check for custom HEALTHCHECK
|
// Check for custom HEALTHCHECK
|
||||||
if ($this->application->build_pack === 'dockerfile' || $this->application->dockerfile) {
|
if ($this->application->build_pack === 'dockerfile' || $this->application->dockerfile) {
|
||||||
$this->execute_remote_command([
|
$this->execute_remote_command([
|
||||||
executeInDocker($this->deployment_uuid, "cat {$this->workdir}{$this->dockerfile_location}"), 'hidden' => true, 'save' => 'dockerfile_from_repo', 'ignore_errors' => true,
|
executeInDocker($this->deployment_uuid, "cat {$this->workdir}{$this->dockerfile_location}"),
|
||||||
|
'hidden' => true,
|
||||||
|
'save' => 'dockerfile_from_repo',
|
||||||
|
'ignore_errors' => true,
|
||||||
]);
|
]);
|
||||||
$dockerfile = collect(str($this->saved_outputs->get('dockerfile_from_repo'))->trim()->explode("\n"));
|
$dockerfile = collect(str($this->saved_outputs->get('dockerfile_from_repo'))->trim()->explode("\n"));
|
||||||
$this->application->parseHealthcheckFromDockerfile($dockerfile);
|
$this->application->parseHealthcheckFromDockerfile($dockerfile);
|
||||||
@@ -1894,7 +1916,8 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
|
|||||||
$this->application_deployment_queue->addLogEntry("Pulling latest image ($image) from the registry.");
|
$this->application_deployment_queue->addLogEntry("Pulling latest image ($image) from the registry.");
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, "docker pull {$image}"), 'hidden' => true,
|
executeInDocker($this->deployment_uuid, "docker pull {$image}"),
|
||||||
|
'hidden' => true,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1944,12 +1967,14 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
$this->execute_remote_command([executeInDocker($this->deployment_uuid, "echo '{$this->nixpacks_plan}' | base64 -d | tee /artifacts/thegameplan.json > /dev/null"), 'hidden' => true]);
|
$this->execute_remote_command([executeInDocker($this->deployment_uuid, "echo '{$this->nixpacks_plan}' | base64 -d | tee /artifacts/thegameplan.json > /dev/null"), 'hidden' => true]);
|
||||||
if ($this->force_rebuild) {
|
if ($this->force_rebuild) {
|
||||||
$this->execute_remote_command([
|
$this->execute_remote_command([
|
||||||
executeInDocker($this->deployment_uuid, "nixpacks build -c /artifacts/thegameplan.json --no-cache --no-error-without-start -n {$this->build_image_name} {$this->workdir} -o {$this->workdir}"), 'hidden' => true,
|
executeInDocker($this->deployment_uuid, "nixpacks build -c /artifacts/thegameplan.json --no-cache --no-error-without-start -n {$this->build_image_name} {$this->workdir} -o {$this->workdir}"),
|
||||||
|
'hidden' => true,
|
||||||
]);
|
]);
|
||||||
$build_command = "docker build --no-cache {$this->addHosts} --network host -f {$this->workdir}/.nixpacks/Dockerfile {$this->build_args} --progress plain -t {$this->build_image_name} {$this->workdir}";
|
$build_command = "docker build --no-cache {$this->addHosts} --network host -f {$this->workdir}/.nixpacks/Dockerfile {$this->build_args} --progress plain -t {$this->build_image_name} {$this->workdir}";
|
||||||
} else {
|
} else {
|
||||||
$this->execute_remote_command([
|
$this->execute_remote_command([
|
||||||
executeInDocker($this->deployment_uuid, "nixpacks build -c /artifacts/thegameplan.json --cache-key '{$this->application->uuid}' --no-error-without-start -n {$this->build_image_name} {$this->workdir} -o {$this->workdir}"), 'hidden' => true,
|
executeInDocker($this->deployment_uuid, "nixpacks build -c /artifacts/thegameplan.json --cache-key '{$this->application->uuid}' --no-error-without-start -n {$this->build_image_name} {$this->workdir} -o {$this->workdir}"),
|
||||||
|
'hidden' => true,
|
||||||
]);
|
]);
|
||||||
$build_command = "docker build {$this->addHosts} --network host -f {$this->workdir}/.nixpacks/Dockerfile {$this->build_args} --progress plain -t {$this->build_image_name} {$this->workdir}";
|
$build_command = "docker build {$this->addHosts} --network host -f {$this->workdir}/.nixpacks/Dockerfile {$this->build_args} --progress plain -t {$this->build_image_name} {$this->workdir}";
|
||||||
}
|
}
|
||||||
@@ -1957,10 +1982,12 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
$base64_build_command = base64_encode($build_command);
|
$base64_build_command = base64_encode($build_command);
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"), 'hidden' => true,
|
executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"),
|
||||||
|
'hidden' => true,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, 'bash /artifacts/build.sh'), 'hidden' => true,
|
executeInDocker($this->deployment_uuid, 'bash /artifacts/build.sh'),
|
||||||
|
'hidden' => true,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->execute_remote_command([executeInDocker($this->deployment_uuid, 'rm /artifacts/thegameplan.json'), 'hidden' => true]);
|
$this->execute_remote_command([executeInDocker($this->deployment_uuid, 'rm /artifacts/thegameplan.json'), 'hidden' => true]);
|
||||||
@@ -1974,10 +2001,12 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
}
|
}
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"), 'hidden' => true,
|
executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"),
|
||||||
|
'hidden' => true,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, 'bash /artifacts/build.sh'), 'hidden' => true,
|
executeInDocker($this->deployment_uuid, 'bash /artifacts/build.sh'),
|
||||||
|
'hidden' => true,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -2014,10 +2043,12 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
executeInDocker($this->deployment_uuid, "echo '{$nginx_config}' | base64 -d | tee {$this->workdir}/nginx.conf > /dev/null"),
|
executeInDocker($this->deployment_uuid, "echo '{$nginx_config}' | base64 -d | tee {$this->workdir}/nginx.conf > /dev/null"),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"), 'hidden' => true,
|
executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"),
|
||||||
|
'hidden' => true,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, 'bash /artifacts/build.sh'), 'hidden' => true,
|
executeInDocker($this->deployment_uuid, 'bash /artifacts/build.sh'),
|
||||||
|
'hidden' => true,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -2031,10 +2062,12 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
$base64_build_command = base64_encode($build_command);
|
$base64_build_command = base64_encode($build_command);
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"), 'hidden' => true,
|
executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"),
|
||||||
|
'hidden' => true,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, 'bash /artifacts/build.sh'), 'hidden' => true,
|
executeInDocker($this->deployment_uuid, 'bash /artifacts/build.sh'),
|
||||||
|
'hidden' => true,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -2043,22 +2076,26 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
$this->execute_remote_command([executeInDocker($this->deployment_uuid, "echo '{$this->nixpacks_plan}' | base64 -d | tee /artifacts/thegameplan.json > /dev/null"), 'hidden' => true]);
|
$this->execute_remote_command([executeInDocker($this->deployment_uuid, "echo '{$this->nixpacks_plan}' | base64 -d | tee /artifacts/thegameplan.json > /dev/null"), 'hidden' => true]);
|
||||||
if ($this->force_rebuild) {
|
if ($this->force_rebuild) {
|
||||||
$this->execute_remote_command([
|
$this->execute_remote_command([
|
||||||
executeInDocker($this->deployment_uuid, "nixpacks build -c /artifacts/thegameplan.json --no-cache --no-error-without-start -n {$this->production_image_name} {$this->workdir} -o {$this->workdir}"), 'hidden' => true,
|
executeInDocker($this->deployment_uuid, "nixpacks build -c /artifacts/thegameplan.json --no-cache --no-error-without-start -n {$this->production_image_name} {$this->workdir} -o {$this->workdir}"),
|
||||||
|
'hidden' => true,
|
||||||
]);
|
]);
|
||||||
$build_command = "docker build --no-cache {$this->addHosts} --network host -f {$this->workdir}/.nixpacks/Dockerfile {$this->build_args} --progress plain -t {$this->production_image_name} {$this->workdir}";
|
$build_command = "docker build --no-cache {$this->addHosts} --network host -f {$this->workdir}/.nixpacks/Dockerfile {$this->build_args} --progress plain -t {$this->production_image_name} {$this->workdir}";
|
||||||
} else {
|
} else {
|
||||||
$this->execute_remote_command([
|
$this->execute_remote_command([
|
||||||
executeInDocker($this->deployment_uuid, "nixpacks build -c /artifacts/thegameplan.json --cache-key '{$this->application->uuid}' --no-error-without-start -n {$this->production_image_name} {$this->workdir} -o {$this->workdir}"), 'hidden' => true,
|
executeInDocker($this->deployment_uuid, "nixpacks build -c /artifacts/thegameplan.json --cache-key '{$this->application->uuid}' --no-error-without-start -n {$this->production_image_name} {$this->workdir} -o {$this->workdir}"),
|
||||||
|
'hidden' => true,
|
||||||
]);
|
]);
|
||||||
$build_command = "docker build {$this->addHosts} --network host -f {$this->workdir}/.nixpacks/Dockerfile {$this->build_args} --progress plain -t {$this->production_image_name} {$this->workdir}";
|
$build_command = "docker build {$this->addHosts} --network host -f {$this->workdir}/.nixpacks/Dockerfile {$this->build_args} --progress plain -t {$this->production_image_name} {$this->workdir}";
|
||||||
}
|
}
|
||||||
$base64_build_command = base64_encode($build_command);
|
$base64_build_command = base64_encode($build_command);
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"), 'hidden' => true,
|
executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"),
|
||||||
|
'hidden' => true,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, 'bash /artifacts/build.sh'), 'hidden' => true,
|
executeInDocker($this->deployment_uuid, 'bash /artifacts/build.sh'),
|
||||||
|
'hidden' => true,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->execute_remote_command([executeInDocker($this->deployment_uuid, 'rm /artifacts/thegameplan.json'), 'hidden' => true]);
|
$this->execute_remote_command([executeInDocker($this->deployment_uuid, 'rm /artifacts/thegameplan.json'), 'hidden' => true]);
|
||||||
@@ -2072,10 +2109,12 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
}
|
}
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"), 'hidden' => true,
|
executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"),
|
||||||
|
'hidden' => true,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, 'bash /artifacts/build.sh'), 'hidden' => true,
|
executeInDocker($this->deployment_uuid, 'bash /artifacts/build.sh'),
|
||||||
|
'hidden' => true,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -2101,7 +2140,6 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
["docker rm -f $containerName", 'hidden' => true, 'ignore_errors' => true]
|
["docker rm -f $containerName", 'hidden' => true, 'ignore_errors' => true]
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function stop_running_container(bool $force = false)
|
private function stop_running_container(bool $force = false)
|
||||||
@@ -2179,7 +2217,9 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
private function add_build_env_variables_to_dockerfile()
|
private function add_build_env_variables_to_dockerfile()
|
||||||
{
|
{
|
||||||
$this->execute_remote_command([
|
$this->execute_remote_command([
|
||||||
executeInDocker($this->deployment_uuid, "cat {$this->workdir}{$this->dockerfile_location}"), 'hidden' => true, 'save' => 'dockerfile',
|
executeInDocker($this->deployment_uuid, "cat {$this->workdir}{$this->dockerfile_location}"),
|
||||||
|
'hidden' => true,
|
||||||
|
'save' => 'dockerfile',
|
||||||
]);
|
]);
|
||||||
$dockerfile = collect(str($this->saved_outputs->get('dockerfile'))->trim()->explode("\n"));
|
$dockerfile = collect(str($this->saved_outputs->get('dockerfile'))->trim()->explode("\n"));
|
||||||
if ($this->pull_request_id === 0) {
|
if ($this->pull_request_id === 0) {
|
||||||
@@ -2224,7 +2264,8 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
$exec = "docker exec {$containerName} {$cmd}";
|
$exec = "docker exec {$containerName} {$cmd}";
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
'command' => $exec, 'hidden' => true,
|
'command' => $exec,
|
||||||
|
'hidden' => true,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -2251,7 +2292,9 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
|||||||
try {
|
try {
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[
|
[
|
||||||
'command' => $exec, 'hidden' => true, 'save' => 'post-deployment-command-output',
|
'command' => $exec,
|
||||||
|
'hidden' => true,
|
||||||
|
'save' => 'post-deployment-command-output',
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|||||||
@@ -1089,7 +1089,7 @@ class Application extends BaseModel
|
|||||||
|
|
||||||
public function newParser(int $pull_request_id = 0, ?int $preview_id = null)
|
public function newParser(int $pull_request_id = 0, ?int $preview_id = null)
|
||||||
{
|
{
|
||||||
return newParser($this, $pull_request_id, $preview_id);
|
// return newParser($this, $pull_request_id, $preview_id);
|
||||||
// $pullRequestId = $pull_request_id;
|
// $pullRequestId = $pull_request_id;
|
||||||
// $isPullRequest = $pullRequestId == 0 ? false : true;
|
// $isPullRequest = $pullRequestId == 0 ? false : true;
|
||||||
|
|
||||||
@@ -1630,7 +1630,7 @@ class Application extends BaseModel
|
|||||||
public function oldParser(int $pull_request_id = 0, ?int $preview_id = null)
|
public function oldParser(int $pull_request_id = 0, ?int $preview_id = null)
|
||||||
{
|
{
|
||||||
if ($this->compose_parsing_version === '3') {
|
if ($this->compose_parsing_version === '3') {
|
||||||
return $this->newParser($pull_request_id, $preview_id);
|
return newParser($this, $pull_request_id, $preview_id);
|
||||||
} elseif ($this->docker_compose_raw) {
|
} elseif ($this->docker_compose_raw) {
|
||||||
return parseDockerComposeFile(resource: $this, isNew: false, pull_request_id: $pull_request_id, preview_id: $preview_id);
|
return parseDockerComposeFile(resource: $this, isNew: false, pull_request_id: $pull_request_id, preview_id: $preview_id);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -995,10 +995,8 @@ class Service extends BaseModel
|
|||||||
instant_remote_process($commands, $this->server);
|
instant_remote_process($commands, $this->server);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newParser(): Collection
|
public function newParser()
|
||||||
{
|
{
|
||||||
return newParser($this);
|
|
||||||
|
|
||||||
// $uuid = data_get($this, 'uuid');
|
// $uuid = data_get($this, 'uuid');
|
||||||
// $server = data_get($this, 'destination.server');
|
// $server = data_get($this, 'destination.server');
|
||||||
// $compose = data_get($this, 'docker_compose_raw');
|
// $compose = data_get($this, 'docker_compose_raw');
|
||||||
@@ -1526,7 +1524,7 @@ class Service extends BaseModel
|
|||||||
public function parse(bool $isNew = false): Collection
|
public function parse(bool $isNew = false): Collection
|
||||||
{
|
{
|
||||||
if ($this->compose_parsing_version === '3') {
|
if ($this->compose_parsing_version === '3') {
|
||||||
return $this->newParser();
|
return newParser($this);
|
||||||
} elseif ($this->docker_compose_raw) {
|
} elseif ($this->docker_compose_raw) {
|
||||||
return parseDockerComposeFile($this, $isNew);
|
return parseDockerComposeFile($this, $isNew);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -3185,6 +3185,18 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
|
|||||||
}
|
}
|
||||||
// convert environment variables to one format
|
// convert environment variables to one format
|
||||||
$environment = convertComposeEnvironmentToArray($environment);
|
$environment = convertComposeEnvironmentToArray($environment);
|
||||||
|
|
||||||
|
// Add Coolify defined environments
|
||||||
|
$allEnvironments = $resource->environment_variables()->get(['key', 'value']);
|
||||||
|
|
||||||
|
$allEnvironments = $allEnvironments->mapWithKeys(function ($item) {
|
||||||
|
return [$item['key'] => $item['value']];
|
||||||
|
});
|
||||||
|
|
||||||
|
// remove $environment from $allEnvironments
|
||||||
|
$coolifyDefinedEnvironments = $allEnvironments->diffKeys($environment);
|
||||||
|
|
||||||
|
|
||||||
// filter magic environments
|
// filter magic environments
|
||||||
$magicEnvironments = $environment->filter(function ($value, $key) {
|
$magicEnvironments = $environment->filter(function ($value, $key) {
|
||||||
$value = str(replaceVariables(str($value)));
|
$value = str(replaceVariables(str($value)));
|
||||||
@@ -3258,7 +3270,7 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
|
|||||||
} else {
|
} else {
|
||||||
$value = $fqdn;
|
$value = $fqdn;
|
||||||
}
|
}
|
||||||
$value = str($fqdn)->replace('http://', '')->replace('https://', '')->replace('www.', '');
|
$value = str($fqdn)->replace('http://', '')->replace('https://', '');
|
||||||
} else {
|
} else {
|
||||||
$generatedValue = generateEnvValue($valueCommand, $resource);
|
$generatedValue = generateEnvValue($valueCommand, $resource);
|
||||||
if ($generatedValue) {
|
if ($generatedValue) {
|
||||||
@@ -3327,6 +3339,17 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($isApplication) {
|
||||||
|
$branch = $originalResource->git_branch;
|
||||||
|
if ($pullRequestId !== 0) {
|
||||||
|
$branch = "pull/{$pullRequestId}/head";
|
||||||
|
}
|
||||||
|
if ($originalResource->environment_variables->where('key', 'COOLIFY_BRANCH')->isEmpty()) {
|
||||||
|
ray($branch);
|
||||||
|
$environment->put('COOLIFY_BRANCH', $branch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add COOLIFY_CONTAINER_NAME to environment
|
// Add COOLIFY_CONTAINER_NAME to environment
|
||||||
if ($resource->environment_variables->where('key', 'COOLIFY_CONTAINER_NAME')->isEmpty()) {
|
if ($resource->environment_variables->where('key', 'COOLIFY_CONTAINER_NAME')->isEmpty()) {
|
||||||
$environment->put('COOLIFY_CONTAINER_NAME', $containerName);
|
$environment->put('COOLIFY_CONTAINER_NAME', $containerName);
|
||||||
@@ -3381,9 +3404,19 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
|
|||||||
}
|
}
|
||||||
$defaultLabels = defaultLabels($resource->id, $containerName, type: 'service', subType: $isDatabase ? 'database' : 'application', subId: $savedService->id);
|
$defaultLabels = defaultLabels($resource->id, $containerName, type: 'service', subType: $isDatabase ? 'database' : 'application', subId: $savedService->id);
|
||||||
}
|
}
|
||||||
|
// Add COOLIFY_FQDN & COOLIFY_URL to environment
|
||||||
|
if (! $isDatabase && $fqdns?->count() > 0) {
|
||||||
|
$environment->put('COOLIFY_FQDN', $fqdns->implode(','));
|
||||||
|
$environment->put('COOLIFY_DOMAIN_URL', $fqdns->implode(','));
|
||||||
|
|
||||||
|
$urls = $fqdns->map(function ($fqdn) {
|
||||||
|
return str($fqdn)->replace('http://', '')->replace('https://', '');
|
||||||
|
});
|
||||||
|
$environment->put('COOLIFY_URL', $urls->implode(','));
|
||||||
|
$environment->put('COOLIFY_DOMAIN_FQDN', $urls->implode(','));
|
||||||
|
}
|
||||||
|
|
||||||
$serviceLabels = $labels->merge($defaultLabels);
|
$serviceLabels = $labels->merge($defaultLabels);
|
||||||
|
|
||||||
if (! $isDatabase && $fqdns?->count() > 0) {
|
if (! $isDatabase && $fqdns?->count() > 0) {
|
||||||
if ($isApplication) {
|
if ($isApplication) {
|
||||||
$shouldGenerateLabelsExactly = $resource->destination->server->settings->generate_exact_labels;
|
$shouldGenerateLabelsExactly = $resource->destination->server->settings->generate_exact_labels;
|
||||||
@@ -3464,8 +3497,8 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
|
|||||||
if ($volumesParsed->count() > 0) {
|
if ($volumesParsed->count() > 0) {
|
||||||
$payload['volumes'] = $volumesParsed;
|
$payload['volumes'] = $volumesParsed;
|
||||||
}
|
}
|
||||||
if ($environment->count() > 0) {
|
if ($environment->count() > 0 || $coolifyDefinedEnvironments->count() > 0) {
|
||||||
$payload['environment'] = $environment;
|
$payload['environment'] = $environment->merge($coolifyDefinedEnvironments);
|
||||||
}
|
}
|
||||||
if ($logging) {
|
if ($logging) {
|
||||||
$payload['logging'] = $logging;
|
$payload['logging'] = $logging;
|
||||||
|
|||||||
Reference in New Issue
Block a user