From 426e3366a8d70b9d025e09855083bb8335b388a7 Mon Sep 17 00:00:00 2001 From: Eric Deandrea Date: Tue, 10 Dec 2024 16:12:27 -0500 Subject: [PATCH] Move ollama port to a constant and provide new `getPort` method (#9623) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: EddĂș MelĂ©ndez Gonzales --- .../org/testcontainers/ollama/OllamaContainer.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/ollama/src/main/java/org/testcontainers/ollama/OllamaContainer.java b/modules/ollama/src/main/java/org/testcontainers/ollama/OllamaContainer.java index 1c739b95a6b..db611a34a39 100644 --- a/modules/ollama/src/main/java/org/testcontainers/ollama/OllamaContainer.java +++ b/modules/ollama/src/main/java/org/testcontainers/ollama/OllamaContainer.java @@ -24,6 +24,8 @@ public class OllamaContainer extends GenericContainer { private static final DockerImageName DOCKER_IMAGE_NAME = DockerImageName.parse("ollama/ollama"); + private static final int OLLAMA_PORT = 11434; + public OllamaContainer(String image) { this(DockerImageName.parse(image)); } @@ -49,7 +51,7 @@ public OllamaContainer(DockerImageName dockerImageName) { }); } } - withExposedPorts(11434); + withExposedPorts(OLLAMA_PORT); } /** @@ -74,7 +76,11 @@ public void commitToImage(String imageName) { } } + public int getPort() { + return getMappedPort(OLLAMA_PORT); + } + public String getEndpoint() { - return "http://" + getHost() + ":" + getMappedPort(11434); + return "http://" + getHost() + ":" + getPort(); } }