Merge pull request #1530 from stooit/feat/docker-compose-prebuild

feat: Build images prior to rollout in docker compose buildpack.
This commit is contained in:
Andras Bacsai 2023-12-11 13:03:59 +01:00 committed by GitHub
commit a8807b8d09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -451,6 +451,8 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
executeInDocker($this->deployment_uuid, "echo '{$this->docker_compose_base64}' | base64 -d > {$this->workdir}{$this->docker_compose_location}"), "hidden" => true
]);
$this->save_environment_variables();
// Build new container to limit downtime.
$this->build_by_compose_file();
$this->stop_running_container(force: true);
$networkId = $this->application->uuid;
@ -1243,6 +1245,27 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
}
}
private function build_by_compose_file() {
if ($this->application->build_pack === 'dockerimage') {
$this->application_deployment_queue->addLogEntry("Pulling latest images from the registry.");
$this->execute_remote_command(
[executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} pull"), "hidden" => true],
[executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} build"), "hidden" => true],
);
} else {
if ($this->docker_compose_location) {
$this->execute_remote_command(
[executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} -f {$this->workdir}{$this->docker_compose_location} build"), "hidden" => true],
);
} else {
$this->execute_remote_command(
[executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} build"), "hidden" => true],
);
}
}
$this->application_deployment_queue->addLogEntry("New images built.");
}
private function start_by_compose_file()
{
if ($this->application->build_pack === 'dockerimage') {