diff mbox series

[yocto-autobuilder2,02/10] docker: compose: Fix docker role detection

Message ID 20251007-contrib-mathieu-bb-setup-links-v1-2-bb1d79289c3f@bootlin.com
State New
Headers show
Series Fix links with bitbake setup and general improvements | expand

Commit Message

Mathieu Dubois-Briand Oct. 7, 2025, 2:37 p.m. UTC
It looks like the name of docker containers created with docker-compose
is not always the same: is is generated from various values, sometimes
separated by underscores, sometimes by dashes, breaking role detection.
Try to use another method that should be a bit more reliable.

Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
---
 docker/compose.yaml | 4 ++++
 docker/entry.sh     | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/docker/compose.yaml b/docker/compose.yaml
index 50034d90d52b34f5d09c01a48b8f3e256fe8339a..334e13720b3b4b89128300fa623628d7ea219b5f 100644
--- a/docker/compose.yaml
+++ b/docker/compose.yaml
@@ -2,6 +2,7 @@ 
 
 ---
 
+name: ab2
 x-base-service: &base-service
   build:
     context: ..
@@ -17,15 +18,18 @@  x-base-service: &base-service
 services:
   controller:
     <<: *base-service
+    command: controller
     ports:
       - 8010:8010
     cpus: 4
   worker: &base-worker
     <<: *base-service
+    command: worker
     cpus: 8
     mem_limit: 16gb
   extraworker:
     <<: *base-worker
+    command: extraworker
     cpus: 1
     mem_limit: 2gb
     deploy:
diff --git a/docker/entry.sh b/docker/entry.sh
index 1aef2ba4025f9871e84189283fd791fab109862d..900e4b9b229ffab31fcd345b8eaec57bd2fef90a 100644
--- a/docker/entry.sh
+++ b/docker/entry.sh
@@ -6,9 +6,9 @@  chown pokybuild:nogroup /home/pokybuild/git/mirror
 chown pokybuild:nogroup /srv/autobuilder
 cd /home/pokybuild/ || exit 1
 
+role=${1}
 docker_name=$(host "$(host "$(hostname)" | awk '{print $NF}')" | awk '{print $NF}' | awk -F . '{print $1}')
-role=$(echo "${docker_name}" | cut -d_ -f 2)
-instance=$(echo "${docker_name}" | cut -d_ -f 3)
+instance=$(echo "${docker_name}" | sed -e 's/.*[^0-9]\([0-9]*\)$/\1/')
 
 if [ "${role}" = "controller" ]; then
   su pokybuild -c "yocto-autobuilder-helper/janitor/ab-janitor" &