Skip to content

Commit b2e22a0

Browse files
authored
Adding constant and overridable method to OllamaContainer
1 parent 8ce2045 commit b2e22a0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

modules/ollama/src/main/java/org/testcontainers/ollama/OllamaContainer.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
public class OllamaContainer extends GenericContainer<OllamaContainer> {
2424

2525
private static final DockerImageName DOCKER_IMAGE_NAME = DockerImageName.parse("ollama/ollama");
26+
private static final int OLLAMA_PORT = 11434;
2627

2728
public OllamaContainer(String image) {
2829
this(DockerImageName.parse(image));
@@ -49,7 +50,7 @@ public OllamaContainer(DockerImageName dockerImageName) {
4950
});
5051
}
5152
}
52-
withExposedPorts(11434);
53+
withExposedPorts(OLLAMA_PORT);
5354
}
5455

5556
/**
@@ -74,7 +75,11 @@ public void commitToImage(String imageName) {
7475
}
7576
}
7677

78+
public int getPort() {
79+
return getMappedPort(OLLAMA_PORT);
80+
}
81+
7782
public String getEndpoint() {
78-
return "http://" + getHost() + ":" + getMappedPort(11434);
83+
return "http://" + getHost() + ":" + getPort();
7984
}
8085
}

0 commit comments

Comments
 (0)