Skip to content

Commit 7391d6b

Browse files
authored
Add Search/AI Assistant to dev enviroment. (#1736)
This also exposes the proxy to `docs-builder serve-static`. It now also wires up the configuration for our dotnet aspire project.
1 parent 1b54c85 commit 7391d6b

File tree

5 files changed

+42
-6
lines changed

5 files changed

+42
-6
lines changed

config/assembler.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ environments:
3030
uri: http://localhost:4000
3131
content_source: current
3232
path_prefix: docs
33+
feature_flags:
34+
SEARCH_OR_ASK_AI: true
3335

3436
shared_configuration:
3537
stack: &stack

src/tooling/docs-builder/Http/DocumentationWebHost.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ private void SetUpRoutes()
144144
_ = _webApplication.MapGet("/api/{**slug}", (string slug, ReloadableGeneratorState holder, Cancel ctx) =>
145145
ServeApiFile(holder, slug, ctx));
146146

147-
148147
var apiV1 = _webApplication.MapGroup("/docs/_api/v1");
149148
apiV1.MapElasticDocsApiEndpoints();
150149

src/tooling/docs-builder/Http/StaticWebHost.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information
44

5+
using Elastic.Documentation.Api.Infrastructure;
56
using Elastic.Documentation.Configuration;
67
using Elastic.Documentation.ServiceDefaults;
7-
using Elastic.Documentation.Tooling;
88
using Microsoft.AspNetCore.Builder;
99
using Microsoft.AspNetCore.Hosting;
1010
using Microsoft.AspNetCore.Http;
@@ -28,6 +28,8 @@ public StaticWebHost(int port)
2828

2929
_ = builder.AddDocumentationServiceDefaults();
3030

31+
builder.Services.AddElasticDocsApiUsecases("dev");
32+
3133
_ = builder.Logging
3234
.AddFilter("Microsoft.AspNetCore.Hosting.Diagnostics", LogLevel.Error)
3335
.AddFilter("Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware", LogLevel.Error)
@@ -51,6 +53,10 @@ private void SetUpRoutes()
5153
_ = WebApplication.MapGet("/", (Cancel _) => Results.Redirect("docs"));
5254

5355
_ = WebApplication.MapGet("{**slug}", ServeDocumentationFile);
56+
57+
var apiV1 = WebApplication.MapGroup("/docs/_api/v1");
58+
apiV1.MapElasticDocsApiEndpoints();
59+
5460
}
5561

5662
private async Task<IResult> ServeDocumentationFile(string slug, Cancel _)

tests-integration/Elastic.Assembler.IntegrationTests/AssembleFixture.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public async ValueTask InitializeAsync()
3434
_ = builder.Services.AddElasticDocumentationLogging(LogLevel.Information);
3535
_ = builder.Services.AddLogging(c => c.AddXUnit());
3636
_ = builder.Services.AddLogging(c => c.AddInMemory());
37+
// TODO expose this as secrets for now not needed integration tests
38+
_ = builder.AddParameter("LlmGatewayUrl", "");
39+
_ = builder.AddParameter("LlmGatewayServiceAccountPath", "");
3740
DistributedApplication = await builder.BuildAsync();
3841
InMemoryLogger = DistributedApplication.Services.GetService<InMemoryLogger>()!;
3942
await DistributedApplication.StartAsync();

tests-integration/Elastic.Documentation.Aspire/AppHost.cs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,39 @@
1919

2020
var builder = DistributedApplication.CreateBuilder(args);
2121

22+
// Add a secret parameter named "secret"
23+
var llmUrl = builder.AddParameter("LlmGatewayUrl", secret: true);
24+
var llmServiceAccountPath = builder.AddParameter("LlmGatewayServiceAccountPath", secret: true);
25+
2226
var cloneAll = builder.AddProject<Projects.docs_assembler>("DocsAssemblerCloneAll").WithArgs(["repo", "clone-all", .. globalArguments]);
2327

2428
var buildAll = builder.AddProject<Projects.docs_assembler>("DocsAssemblerBuildAll").WithArgs(["repo", "build-all", .. globalArguments])
2529
.WaitForCompletion(cloneAll);
2630

27-
var elasticsearch = builder.AddElasticsearch("elasticsearch");
31+
var elasticsearch = builder.AddElasticsearch("elasticsearch")
32+
.WithEnvironment("LICENSE", "trial");
2833

2934
var api = builder.AddProject<Projects.Elastic_Documentation_Api_Lambda>("ApiLambda").WithArgs(globalArguments)
35+
.WithEnvironment("ENVIRONMENT", "dev")
36+
.WithEnvironment("LLM_GATEWAY_FUNCTION_URL", llmUrl)
37+
.WithEnvironment("LLM_GATEWAY_SERVICE_ACCOUNT_KEY_PATH", llmServiceAccountPath)
3038
.WaitFor(elasticsearch)
3139
.WithReference(elasticsearch);
3240

3341
var indexElasticsearch = builder.AddProject<Projects.docs_assembler>("DocsAssemblerElasticsearch")
34-
.WithArgs(["repo", "build-all", "--exporters", "html,elasticsearch", .. globalArguments])
42+
.WithArgs(["repo", "build-all", "--exporters", "elasticsearch", .. globalArguments])
43+
.WithEnvironment("DOCUMENTATION_ELASTIC_URL", elasticsearch.GetEndpoint("http"))
44+
.WithEnvironment(context =>
45+
{
46+
context.EnvironmentVariables["DOCUMENTATION_ELASTIC_PASSWORD"] = elasticsearch.Resource.PasswordParameter;
47+
})
48+
.WithReference(elasticsearch)
49+
.WithExplicitStart()
50+
.WaitFor(elasticsearch)
51+
.WaitForCompletion(cloneAll);
52+
53+
var indexElasticsearchSemantic = builder.AddProject<Projects.docs_assembler>("DocsAssemblerElasticsearchSemantic")
54+
.WithArgs(["repo", "build-all", "--exporters", "semantic", .. globalArguments])
3555
.WithEnvironment("DOCUMENTATION_ELASTIC_URL", elasticsearch.GetEndpoint("http"))
3656
.WithEnvironment(context =>
3757
{
@@ -44,11 +64,17 @@
4464

4565
var serveStatic = builder.AddProject<Projects.docs_builder>("DocsBuilderServeStatic")
4666
.WithReference(elasticsearch)
67+
.WithEnvironment("LLM_GATEWAY_FUNCTION_URL", llmUrl)
68+
.WithEnvironment("LLM_GATEWAY_SERVICE_ACCOUNT_KEY_PATH", llmServiceAccountPath)
69+
.WithEnvironment("DOCUMENTATION_ELASTIC_URL", elasticsearch.GetEndpoint("http"))
70+
.WithEnvironment(context =>
71+
{
72+
context.EnvironmentVariables["DOCUMENTATION_ELASTIC_PASSWORD"] = elasticsearch.Resource.PasswordParameter;
73+
})
4774
.WithHttpEndpoint(port: 4000, isProxied: false)
4875
.WithArgs(["serve-static", .. globalArguments])
4976
.WithHttpHealthCheck("/", 200)
77+
.WaitFor(elasticsearch)
5078
.WaitForCompletion(buildAll);
5179

52-
53-
5480
builder.Build().Run();

0 commit comments

Comments
 (0)