2929import org .junit .jupiter .api .Test ;
3030import org .slf4j .Logger ;
3131import org .slf4j .LoggerFactory ;
32- import org .testcontainers .containers .SocatContainer ;
32+ import org .testcontainers .containers .DockerModelRunnerContainer ;
3333import org .testcontainers .junit .jupiter .Container ;
3434import org .testcontainers .junit .jupiter .Testcontainers ;
3535import reactor .core .publisher .Flux ;
6969 */
7070@ Testcontainers
7171@ SpringBootTest (classes = DockerModelRunnerWithOpenAiChatModelIT .Config .class )
72- @ Disabled ("Requires Docker Model Runner enabled. See https://docs.docker.com/desktop/features/model-runner/" )
72+ // @Disabled("Requires Docker Model Runner enabled. See
73+ // https://docs.docker.com/desktop/features/model-runner/")
7374class DockerModelRunnerWithOpenAiChatModelIT {
7475
7576 private static final Logger logger = LoggerFactory .getLogger (DockerModelRunnerWithOpenAiChatModelIT .class );
7677
7778 private static final String DEFAULT_MODEL = "ai/gemma3:4B-F16" ;
7879
7980 @ Container
80- private static final SocatContainer socat = new SocatContainer (). withTarget ( 80 , "model-runner.docker.internal " );
81+ private static final DockerModelRunnerContainer DMR = new DockerModelRunnerContainer ( "alpine/socat:1.7.4.3-r0 " );
8182
8283 @ Value ("classpath:/prompts/system-message.st" )
8384 private Resource systemResource ;
@@ -89,7 +90,7 @@ class DockerModelRunnerWithOpenAiChatModelIT {
8990 public static void beforeAll () throws IOException , InterruptedException {
9091 logger .info ("Start pulling the '" + DEFAULT_MODEL + "' generative ... would take several minutes ..." );
9192
92- String baseUrl = "http://%s:%d" .formatted (socat .getHost (), socat .getMappedPort (80 ));
93+ String baseUrl = "http://%s:%d" .formatted (DMR .getHost (), DMR .getMappedPort (80 ));
9394
9495 RestAssured .given ().baseUri (baseUrl ).body ("""
9596 {
@@ -352,8 +353,7 @@ static class Config {
352353
353354 @ Bean
354355 public OpenAiApi chatCompletionApi () {
355- var baseUrl = "http://%s:%d/engines" .formatted (socat .getHost (), socat .getMappedPort (80 ));
356- return OpenAiApi .builder ().baseUrl (baseUrl ).apiKey ("test" ).build ();
356+ return OpenAiApi .builder ().baseUrl (DMR .getOpenAIEndpoint ()).apiKey ("test" ).build ();
357357 }
358358
359359 @ Bean
0 commit comments