From 9c1fb1d7e7c08d82ed3ac0b58a83091b6413efca Mon Sep 17 00:00:00 2001 From: Daniel Radeau Date: Fri, 18 Sep 2026 11:53:23 +0200 Subject: [PATCH] Story #16471: Fix cas-server container build and Consul service registration Build the cas-server container image with jib, like every api/* module: - Bind jib:build to the package phase in cas/cas-server/pom.xml. Because cas/pom.xml has no , cas-server inherits nothing from the root pluginManagement, where that binding lives for the other modules. The module keeps jib.skip=true so a local mvn install never pushes; Jenkinsfile.containers overrides it with -Djib.skip=false. - Add gcr.io/distroless/java21 so cas-server ships on the same base image as the other services instead of falling back to jib's Jetty default for war packaging. - Add true, required by the HTTP registry push performed by Jenkinsfile.containers (-DsendCredentialsOverHttp=true). - Restrict the extraDirectories path to cas-server.war, instead of copying the whole target/ tree into /app/ (classes, the exploded war, maven-status, generated sources), which embedded the payload several times in the image. Prefix SPRING_APPLICATION_NAME with vitamui- in the container systemd unit template. Every application.yml.j2 declares spring.application.name: vitamui- and derives spring.cloud.consul.discovery.serviceName from it, and vitamui_vars.yml resolves peers as vitamui-.service.. The environment variable was overriding the yml with the short name, so services started in container mode registered in Consul under the wrong name. Keep backup: true on the /etc/resolv.conf blockinfile in the consul role. It is the only rollback copy of the resolver configuration; without it a bad edit leaves the host with no DNS to recover from. The sibling Debian task uses backup: true as well. Co-Authored-By: Mohamed Achoubie --- cas/cas-server/pom.xml | 13 +++++++++++++ .../vitamui-container-componentid.service.j2 | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cas/cas-server/pom.xml b/cas/cas-server/pom.xml index a4aed26faa0..7f720a3a2be 100644 --- a/cas/cas-server/pom.xml +++ b/cas/cas-server/pom.xml @@ -919,6 +919,10 @@ jib-maven-plugin ${jib-maven-plugin.version} + + gcr.io/distroless/java21 + + true ${env.SERVICE_DOCKER_PUSH_URL}/vitamui/cas-server ${project.version} @@ -928,6 +932,7 @@ target/ /app/ + cas-server.war @@ -935,6 +940,14 @@ java,-jar,/app/cas-server.war + + + package + + build + + + diff --git a/deployment/roles/vitamui/templates/vitamui-container-componentid.service.j2 b/deployment/roles/vitamui/templates/vitamui-container-componentid.service.j2 index c9ce473cfa1..aaf96fef6e6 100644 --- a/deployment/roles/vitamui/templates/vitamui-container-componentid.service.j2 +++ b/deployment/roles/vitamui/templates/vitamui-container-componentid.service.j2 @@ -8,7 +8,7 @@ ExecStartPre=-/usr/bin/docker pull {{ container_repository.registry_url }}/vitam ExecStart=/usr/bin/docker run --rm --network host --name {{ vitamui_struct.vitamui_component }} --user {{ getent_passwd[vitamui_defaults.users.vitamui | default('vitamui')].1 }}:{{ getent_passwd[vitamui_defaults.users.vitamui | default('vitamui')].2 }} \ -e "JAVA_TOOL_OPTIONS={{ vitamui_struct.jvm_opts.gc | default(jvm_opts.gc) }} -XX:MaxRAMPercentage=75.0 -XX:MinRAMPercentage=50.0 -XX:+ExitOnOutOfMemoryError -Dlogback.configurationFile={{ vitamui_folder_conf }}/logback.xml -Dvitam.config.folder={{ vitamui_folder_conf }} -Dvitam.data.folder={{ vitamui_folder_data }} -Dvitam.tmp.folder={{ vitamui_folder_tmp }} -Dvitam.log.folder={{ vitamui_folder_log }} -Djava.security.properties={{ vitamui_folder_conf }}/java.security -XX:+HeapDumpOnOutOfMemoryError -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses=true -XX:HeapDumpPath={{ vitamui_folder_log }}" \ -e "SPRING_CONFIG_ADDITIONAL_LOCATION={{ vitamui_folder_conf }}/application.yml" \ - -e "SPRING_APPLICATION_NAME={{ vitamui_struct.vitamui_component }}" \ + -e "SPRING_APPLICATION_NAME=vitamui-{{ vitamui_struct.vitamui_component }}" \ -v "{{ vitamui_folder_conf }}:{{ vitamui_folder_conf }}:rw" \ -v "{{ vitamui_folder_log }}:{{ vitamui_folder_log }}:rw" \ -v "{{ vitamui_folder_data }}:{{ vitamui_folder_data }}:rw" \