Skip to content

Commit

Permalink
Move ollama port to a constant and provide new getPort method (#9623)
Browse files Browse the repository at this point in the history
Co-authored-by: Eddú Meléndez Gonzales <[email protected]>
  • Loading branch information
edeandrea and eddumelendez authored Dec 10, 2024
1 parent 037b03c commit 426e336
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class OllamaContainer extends GenericContainer<OllamaContainer> {

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));
}
Expand All @@ -49,7 +51,7 @@ public OllamaContainer(DockerImageName dockerImageName) {
});
}
}
withExposedPorts(11434);
withExposedPorts(OLLAMA_PORT);
}

/**
Expand All @@ -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();
}
}

0 comments on commit 426e336

Please sign in to comment.