Skip to content

Commit 0e5f74d

Browse files
authored
[docker run] Make the version configurable (#411)
1 parent 3624835 commit 0e5f74d

File tree

5 files changed

+43
-9
lines changed

5 files changed

+43
-9
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ jobs:
5050
docker push $repo/$image:$docker_tag
5151
}
5252
tag_and_push langstream-runtime
53+
tag_and_push langstream-runtime-tester
5354
tag_and_push langstream-cli
5455
tag_and_push langstream-deployer
5556
tag_and_push langstream-control-plane

examples/instances/kafka-docker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ instance:
2020
type: "kafka"
2121
configuration:
2222
admin:
23-
bootstrap.servers: localhost:39092
23+
bootstrap.servers: localhost:9092

langstream-cli/src/main/java/ai/langstream/cli/commands/VersionProvider.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,32 @@
1919
import java.io.InputStream;
2020
import java.net.URL;
2121
import java.util.Enumeration;
22+
import java.util.List;
2223
import java.util.jar.Attributes;
2324
import java.util.jar.Manifest;
2425
import picocli.CommandLine;
2526

2627
public class VersionProvider implements CommandLine.IVersionProvider {
2728

28-
private static final String[] VERSION = new String[] {getVersionFromJar()};
29+
private static final List<String> VERSION_INFO = getVersionFromJar();
30+
31+
public static String getMavenVersion() {
32+
return VERSION_INFO.get(1);
33+
}
2934

3035
public String[] getVersion() {
31-
return VERSION;
36+
return new String[] {VERSION_INFO.get(0)};
3237
}
3338

34-
private static String getVersionFromJar() {
39+
private static List<String> getVersionFromJar() {
3540
try {
3641
Manifest manifest = getManifest();
3742
final String version = getVersionFromManifest(manifest);
3843
final String gitRevision = getGitRevisionFromManifest(manifest);
39-
return String.format("LangStream CLI %s (%s)", version, gitRevision);
44+
return List.of(String.format("LangStream CLI %s (%s)", version, gitRevision), version);
4045
} catch (Throwable t) {
4146
// never ever let this exception bubble up otherwise any command will fail
42-
return String.format("Error: %s", t.getMessage());
47+
return List.of(String.format("Error: %s", t.getMessage()), "unknown");
4348
}
4449
}
4550

langstream-cli/src/main/java/ai/langstream/cli/commands/docker/LocalRunApplicationCmd.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package ai.langstream.cli.commands.docker;
1717

18+
import ai.langstream.cli.commands.VersionProvider;
1819
import ai.langstream.cli.util.LocalFileReferenceResolver;
1920
import java.io.File;
2021
import java.nio.charset.StandardCharsets;
@@ -87,9 +88,35 @@ public class LocalRunApplicationCmd extends BaseDockerCmd {
8788
description = "Command to run docker")
8889
private String dockerCommand = "docker";
8990

91+
@CommandLine.Option(
92+
names = {"--langstream-runtime-version"},
93+
description = "Version of the LangStream runtime to use")
94+
private String dockerImageVersion = VersionProvider.getMavenVersion();
95+
96+
@CommandLine.Option(
97+
names = {"--langstream-runtime-docker-image"},
98+
description = "Docker image of the LangStream runtime to use")
99+
private String dockerImageName;
100+
90101
@Override
91102
@SneakyThrows
92103
public void run() {
104+
105+
if (dockerImageVersion != null && dockerImageVersion.endsWith("-SNAPSHOT")) {
106+
// built-from-sources, not a release
107+
dockerImageVersion = "latest-dev";
108+
}
109+
110+
if (dockerImageName == null) {
111+
if (dockerImageVersion != null && dockerImageVersion.equals("latest-dev")) {
112+
// built-from-sources, not a release
113+
dockerImageName = "langstream/langstream-runtime-tester";
114+
} else {
115+
// default to latest
116+
dockerImageName = "ghcr.io/langstream/langstream-runtime-tester";
117+
}
118+
}
119+
93120
final File appDirectory = checkFileExistsOrDownload(appPath);
94121
final File instanceFile = checkFileExistsOrDownload(instanceFilePath);
95122
final File secretsFile = checkFileExistsOrDownload(secretFilePath);
@@ -169,7 +196,7 @@ private void executeOnDocker(
169196
Files.write(tmpInstanceFile.toPath(), instanceContents.getBytes(StandardCharsets.UTF_8));
170197
File tmpSecretsFile = Files.createTempFile("secrets", ".yaml").toFile();
171198
Files.write(tmpSecretsFile.toPath(), secretsContents.getBytes(StandardCharsets.UTF_8));
172-
String imageName = "langstream/langstream-runtime-tester:latest-dev";
199+
String imageName = dockerImageName + ":" + dockerImageVersion;
173200
List<String> commandLine = new ArrayList<>();
174201
commandLine.add(dockerCommand);
175202
commandLine.add("run");

langstream-cli/src/main/java/ai/langstream/cli/commands/gateway/ChatGatewayCmd.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ public class ChatGatewayCmd extends BaseGatewayCmd {
4141
@CommandLine.Parameters(description = "Application ID")
4242
private String applicationId;
4343

44-
// optional
45-
@CommandLine.Parameters(arity = "1..2", description = "Chat gateway ID")
44+
@CommandLine.Option(
45+
names = {"-g", "--chat-gateway"},
46+
description = "Use a 'chat' gateway")
4647
private String chatGatewayId;
4748

4849
@CommandLine.Option(

0 commit comments

Comments
 (0)