@@ -147,23 +147,29 @@ func ociRegistry(t *testing.T, ctx context.Context, net *testcontainers.DockerNe
147147}
148148
149149func dockerModelRunner (t * testing.T , ctx context.Context , net * testcontainers.DockerNetwork ) string {
150+ containerCustomizerOpts := []testcontainers.ContainerCustomizer {
151+ testcontainers .WithExposedPorts ("12434/tcp" ),
152+ testcontainers .WithWaitStrategy (wait .ForHTTP ("/engines/status" ).WithPort ("12434/tcp" ).WithStartupTimeout (10 * time .Second )),
153+ testcontainers .WithEnv (map [string ]string {
154+ "DEFAULT_REGISTRY" : "registry.local:5000" ,
155+ "INSECURE_REGISTRY" : "true" ,
156+ }),
157+ network .WithNetwork ([]string {"dmr" }, net ),
158+ }
150159 if os .Getenv ("BUILD_DMR" ) == "1" {
151160 t .Log ("Building DMR container..." )
152161 out , err := exec .CommandContext (ctx , "make" , "-C" , "../../.." , "docker-build" ).CombinedOutput ()
153162 if err != nil {
154163 t .Fatalf ("Failed to build DMR container: %v\n %s" , err , out )
155164 }
165+ } else {
166+ // Always pull the image if it's not build locally.
167+ containerCustomizerOpts = append (containerCustomizerOpts , testcontainers .WithAlwaysPull ())
156168 }
157169 t .Log ("Starting DMR container..." )
158170 ctr , err := testcontainers .Run (
159171 ctx , "docker/model-runner:latest" ,
160- testcontainers .WithExposedPorts ("12434/tcp" ),
161- testcontainers .WithWaitStrategy (wait .ForHTTP ("/engines/status" ).WithPort ("12434/tcp" ).WithStartupTimeout (10 * time .Second )),
162- testcontainers .WithEnv (map [string ]string {
163- "DEFAULT_REGISTRY" : "registry.local:5000" ,
164- "INSECURE_REGISTRY" : "true" ,
165- }),
166- network .WithNetwork ([]string {"dmr" }, net ),
172+ containerCustomizerOpts ... ,
167173 )
168174 require .NoError (t , err )
169175 testcontainers .CleanupContainer (t , ctr )
0 commit comments