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 https://docs.docker.com/desktop/features/model-runner/")
7373class DockerModelRunnerWithOpenAiChatModelIT {
7474
7575 private static final Logger logger = LoggerFactory .getLogger (DockerModelRunnerWithOpenAiChatModelIT .class );
7676
7777 private static final String DEFAULT_MODEL = "ai/gemma3:4B-F16" ;
7878
7979 @ Container
80- private static final SocatContainer socat = new SocatContainer (). withTarget ( 80 , "model-runner.docker.internal " );
80+ private static final DockerModelRunnerContainer DMR = new DockerModelRunnerContainer ( "alpine/socat:1.7.4.3-r0 " );
8181
8282 @ Value ("classpath:/prompts/system-message.st" )
8383 private Resource systemResource ;
@@ -89,7 +89,7 @@ class DockerModelRunnerWithOpenAiChatModelIT {
8989 public static void beforeAll () throws IOException , InterruptedException {
9090 logger .info ("Start pulling the '" + DEFAULT_MODEL + "' generative ... would take several minutes ..." );
9191
92- String baseUrl = "http://%s:%d" .formatted (socat .getHost (), socat .getMappedPort (80 ));
92+ String baseUrl = "http://%s:%d" .formatted (DMR .getHost (), DMR .getMappedPort (80 ));
9393
9494 RestAssured .given ().baseUri (baseUrl ).body ("""
9595 {
@@ -352,8 +352,7 @@ static class Config {
352352
353353 @ Bean
354354 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 ();
355+ return OpenAiApi .builder ().baseUrl (DMR .getOpenAIEndpoint ()).apiKey ("test" ).build ();
357356 }
358357
359358 @ Bean
0 commit comments