mirror of
https://github.com/cupcakearmy/coolify.git
synced 2024-10-23 00:24:15 +02:00
Refactor Docker image name generation and push to
registry
This commit is contained in:
parent
d0366c4054
commit
608f0b7840
@ -275,7 +275,7 @@ private function push_to_docker_registry()
|
|||||||
],
|
],
|
||||||
["echo -n 'Pushing image to docker registry ({$this->production_image_name}).'"],
|
["echo -n 'Pushing image to docker registry ({$this->production_image_name}).'"],
|
||||||
[
|
[
|
||||||
executeInDocker($this->deployment_uuid, "docker push {$this->production_image_name}"), 'ignore_errors' => true, '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) {
|
||||||
@ -294,6 +294,9 @@ private function push_to_docker_registry()
|
|||||||
"echo -n 'Image pushed to docker registry.'"
|
"echo -n 'Image pushed to docker registry.'"
|
||||||
]);
|
]);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
$this->execute_remote_command(
|
||||||
|
["echo -n 'Failed to push image to docker registry. Please check debug logs for more information.'"],
|
||||||
|
);
|
||||||
ray($e);
|
ray($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -336,13 +339,23 @@ private function push_to_docker_registry()
|
|||||||
private function generate_image_names()
|
private function generate_image_names()
|
||||||
{
|
{
|
||||||
if ($this->application->dockerfile) {
|
if ($this->application->dockerfile) {
|
||||||
$this->build_image_name = Str::lower("{$this->application->uuid}:build");
|
if ($this->application->docker_registry_image_name) {
|
||||||
$this->production_image_name = Str::lower("{$this->application->uuid}:latest");
|
$this->build_image_name = Str::lower("{$this->application->docker_registry_image_name}:build");
|
||||||
|
$this->production_image_name = Str::lower("{$this->application->docker_registry_image_name}:latest");
|
||||||
|
} else {
|
||||||
|
$this->build_image_name = Str::lower("{$this->application->uuid}:build");
|
||||||
|
$this->production_image_name = Str::lower("{$this->application->uuid}:latest");
|
||||||
|
}
|
||||||
} else if ($this->application->build_pack === 'dockerimage') {
|
} else if ($this->application->build_pack === 'dockerimage') {
|
||||||
$this->production_image_name = Str::lower("{$this->dockerImage}:{$this->dockerImageTag}");
|
$this->production_image_name = Str::lower("{$this->dockerImage}:{$this->dockerImageTag}");
|
||||||
} else if ($this->pull_request_id !== 0) {
|
} else if ($this->pull_request_id !== 0) {
|
||||||
$this->build_image_name = Str::lower("{$this->application->uuid}:pr-{$this->pull_request_id}-build");
|
if ($this->application->docker_registry_image_name) {
|
||||||
$this->production_image_name = Str::lower("{$this->application->uuid}:pr-{$this->pull_request_id}");
|
$this->build_image_name = Str::lower("{$this->application->docker_registry_image_name}:pr-{$this->pull_request_id}-build");
|
||||||
|
$this->production_image_name = Str::lower("{$this->application->docker_registry_image_name}:pr-{$this->pull_request_id}");
|
||||||
|
} else {
|
||||||
|
$this->build_image_name = Str::lower("{$this->application->uuid}:pr-{$this->pull_request_id}-build");
|
||||||
|
$this->production_image_name = Str::lower("{$this->application->uuid}:pr-{$this->pull_request_id}");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->dockerImageTag = str($this->commit)->substr(0, 128);
|
$this->dockerImageTag = str($this->commit)->substr(0, 128);
|
||||||
if ($this->application->docker_registry_image_name) {
|
if ($this->application->docker_registry_image_name) {
|
||||||
@ -380,8 +393,6 @@ private function check_image_locally_or_remotely()
|
|||||||
]);
|
]);
|
||||||
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([
|
||||||
"echo 'Cannot find image locally. Pulling from docker registry.'", 'type' => 'err'
|
|
||||||
], [
|
|
||||||
"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([
|
||||||
@ -644,7 +655,6 @@ private function set_base_dir()
|
|||||||
[
|
[
|
||||||
"echo -n 'Setting base directory to {$this->workdir}.'"
|
"echo -n 'Setting base directory to {$this->workdir}.'"
|
||||||
],
|
],
|
||||||
["echo '\n----------------------------------------'"]
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
private function check_git_if_build_needed()
|
private function check_git_if_build_needed()
|
||||||
|
Loading…
Reference in New Issue
Block a user