|
|
@@ -23,7 +23,11 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.test.context.ActiveProfiles;
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author reghao
|
|
|
@@ -126,4 +130,43 @@ public class AppConfigTest {
|
|
|
compilerConfigRepository.save(compilerConfig);
|
|
|
System.out.println();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取 Dockerfile 中使用的 image
|
|
|
+ *
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ * @date 2025-07-04 15:49:51
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void dockerfileTest() {
|
|
|
+ List<String> dockerfiles = configRepository.findAll().stream()
|
|
|
+ .map(AppConfig::getDockerfile)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ for (String dockerfile : dockerfiles) {
|
|
|
+ for (String line : dockerfile.split("\n")) {
|
|
|
+ if (line.startsWith("FROM")) {
|
|
|
+ list.add(line);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<String> set = list.stream()
|
|
|
+ .map(line -> line.replace("\r", ""))
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+
|
|
|
+ configRepository.findAll().forEach(appConfig -> {
|
|
|
+ String appId = appConfig.getAppId();
|
|
|
+ String dockerfile = appConfig.getDockerfile();
|
|
|
+ if (dockerfile.contains("aspnet/file1")) {
|
|
|
+ System.out.printf("appId -> %s\n", appId);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ System.out.println("---------------------------");
|
|
|
+ set.forEach(System.out::println);
|
|
|
+ }
|
|
|
}
|