From 4ffea311e84348aee0509e0d0571126b4c50dc6c Mon Sep 17 00:00:00 2001 From: Megumiso Date: Sat, 13 Jul 2024 13:15:17 +0900 Subject: [PATCH] placement constraints is now working --- app/Jobs/ApplicationDeploymentJob.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 7f479d79b..a5f451523 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -1624,12 +1624,15 @@ private function generate_compose_file() ], ], ]; + if (data_get($this->application, 'swarm_placement_constraints')) { + $yaml_parsed_data = Yaml::parse(base64_decode(data_get($this->application, 'swarm_placement_constraints'))); + $docker_compose['services'][$this->container_name]['deploy'] = array_merge( + $docker_compose['services'][$this->container_name]['deploy'], + $yaml_parsed_data + ); + } if (data_get($this->application, 'settings.is_swarm_only_worker_nodes')) { - $docker_compose['services'][$this->container_name]['deploy']['placement'] = [ - 'constraints' => [ - 'node.role == worker', - ], - ]; + $docker_compose['services'][$this->container_name]['deploy']['placement']['constraints'][] = 'node.role == worker'; } if ($this->pull_request_id !== 0) { $docker_compose['services'][$this->container_name]['deploy']['replicas'] = 1;