deploy: parameterize portainer image prefix

This commit is contained in:
lingniu
2026-07-01 12:40:25 +08:00
parent afed6cd4f3
commit 9fb77a1aa2
2 changed files with 37 additions and 5 deletions

View File

@@ -39,6 +39,27 @@ class PortainerComposeResourceLimitsTest {
assertServiceMemoryLimit(compose, "vehicle-analytics-app", "VEHICLE_ANALYTICS_MEM_LIMIT", "1024m");
}
@Test
void productionImagesShareOverridableRegistryAndNamespace() throws IOException {
String compose = Files.readString(repositoryRoot().resolve("deploy/portainer/docker-compose.yml"));
String registry = "${LINGNIU_IMAGE_REGISTRY:-crpi-85r4m0ackrm3qpje.cn-shanghai.personal.cr.aliyuncs.com}";
String namespace = "${LINGNIU_IMAGE_NAMESPACE:-oneos}";
for (String serviceName : List.of(
"gb32960-ingest-app",
"jt808-ingest-app",
"yutong-mqtt-app",
"vehicle-history-app",
"vehicle-analytics-app")) {
assertThat(serviceBlock(compose, serviceName))
.contains("image: " + registry + "/" + namespace + "/" + serviceName
+ ":${LINGNIU_IMAGE_VERSION:?set LINGNIU_IMAGE_VERSION}");
}
assertThat(countOccurrences(compose, "image: crpi-85r4m0ackrm3qpje"))
.isZero();
assertThat(countOccurrences(compose, "/oneos/")).isZero();
}
@Test
void portainerServicesUseContainerReadinessHealthchecks() throws IOException {
String compose = Files.readString(repositoryRoot().resolve("deploy/portainer/docker-compose.yml"));
@@ -490,6 +511,16 @@ class PortainerComposeResourceLimitsTest {
return compose.substring(start, end);
}
private static int countOccurrences(String text, String needle) {
int count = 0;
int index = 0;
while ((index = text.indexOf(needle, index)) >= 0) {
count++;
index += needle.length();
}
return count;
}
private static Properties yamlProperties(Path path) {
YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
factory.setResources(new FileSystemResource(path));