From a1a95a731a15fef481772d7b0c4b54c69cb1b9eb Mon Sep 17 00:00:00 2001 From: "Ido V. Z" Date: Sun, 5 Jul 2026 18:58:42 +0300 Subject: [PATCH 1/5] docs: RavenDB hosting integration TypeScript AppHost support --- .../databases/ravendb/ravendb-host.mdx | 139 ++++++++++++++++-- 1 file changed, 128 insertions(+), 11 deletions(-) diff --git a/src/frontend/src/content/docs/integrations/databases/ravendb/ravendb-host.mdx b/src/frontend/src/content/docs/integrations/databases/ravendb/ravendb-host.mdx index 89c9d9bb7..3568d79bf 100644 --- a/src/frontend/src/content/docs/integrations/databases/ravendb/ravendb-host.mdx +++ b/src/frontend/src/content/docs/integrations/databases/ravendb/ravendb-host.mdx @@ -65,15 +65,11 @@ This updates your `aspire.config.json` with the RavenDB hosting integration pack ```json title="aspire.config.json" ins={3} { "packages": { - "CommunityToolkit.Aspire.Hosting.RavenDB": "13.2.1-beta.532" + "CommunityToolkit.Aspire.Hosting.RavenDB": "13.4.0" } } ``` - - @@ -81,6 +77,9 @@ This updates your `aspire.config.json` with the RavenDB hosting integration pack Once you've installed the hosting integration in your AppHost project, you can add a RavenDB server resource and then add a database resource: + + + ```csharp title="AppHost.cs" var builder = DistributedApplication.CreateBuilder(args); @@ -94,6 +93,27 @@ builder.AddProject("apiservice") // After adding all resources, run the app... ``` + + + +```typescript title="apphost.mts" +import { createBuilder } from './.aspire/modules/aspire.mjs'; + +const builder = await createBuilder(); + +const ravenServer = await builder.addRavenDB("ravenServer"); +const ravendb = await ravenServer.addDatabase("ravendb"); + +const apiService = await builder.addProject("apiservice", "../ExampleProject/ExampleProject.csproj"); +await apiService.withReference(ravendb); +await apiService.waitFor(ravendb); + +// After adding all resources, run the app... +``` + + + + 1. When Aspire adds a container image to the app host, as shown in the preceding example with the `docker.io/ravendb/ravendb` image, it creates a new RavenDB instance on your local machine. @@ -104,12 +124,6 @@ builder.AddProject("apiservice") - - @@ -118,6 +132,9 @@ builder.AddProject("apiservice") By default, `AddDatabase` registers the database in the Aspire model but does not create it in RavenDB automatically. Pass `ensureCreated: true` to have Aspire create the database on startup if it does not already exist: + + + ```csharp title="AppHost.cs" var builder = DistributedApplication.CreateBuilder(args); @@ -131,10 +148,34 @@ builder.AddProject("apiservice") // After adding all resources, run the app... ``` + + + +```typescript title="apphost.mts" +import { createBuilder } from './.aspire/modules/aspire.mjs'; + +const builder = await createBuilder(); + +const ravenServer = await builder.addRavenDB("ravenServer"); +const ravendb = await ravenServer.addDatabase("ravendb", { ensureCreated: true }); + +const apiService = await builder.addProject("apiservice", "../ExampleProject/ExampleProject.csproj"); +await apiService.withReference(ravendb); +await apiService.waitFor(ravendb); + +// After adding all resources, run the app... +``` + + + + ## Add RavenDB server resource with data volume Add a data volume to the RavenDB server resource to persist data outside the lifecycle of its container: + + + ```csharp title="AppHost.cs" var builder = DistributedApplication.CreateBuilder(args); @@ -150,12 +191,38 @@ builder.AddProject("apiservice") // After adding all resources, run the app... ``` + + + +```typescript title="apphost.mts" +import { createBuilder } from './.aspire/modules/aspire.mjs'; + +const builder = await createBuilder(); + +const ravenServer = await builder.addRavenDB("ravenServer"); +await ravenServer.withDataVolume(); + +const ravendb = await ravenServer.addDatabase("ravendb"); + +const apiService = await builder.addProject("apiservice", "../ExampleProject/ExampleProject.csproj"); +await apiService.withReference(ravendb); +await apiService.waitFor(ravendb); + +// After adding all resources, run the app... +``` + + + + The data volume is mounted at the `/var/lib/ravendb/data` path in the RavenDB container. When a `name` parameter isn't provided, the name is generated at random. For more information on data volumes and details on why they're preferred over [bind mounts](#add-ravendb-server-resource-with-data-bind-mount), see [Docker docs: Volumes](https://docs.docker.com/engine/storage/volumes). ## Add RavenDB server resource with data bind mount Add a data bind mount to the RavenDB server resource as an alternative to a named volume: + + + ```csharp title="AppHost.cs" var builder = DistributedApplication.CreateBuilder(args); @@ -171,6 +238,29 @@ builder.AddProject("apiservice") // After adding all resources, run the app... ``` + + + +```typescript title="apphost.mts" +import { createBuilder } from './.aspire/modules/aspire.mjs'; + +const builder = await createBuilder(); + +const ravenServer = await builder.addRavenDB("ravenServer"); +await ravenServer.withDataBindMount("C:\\RavenDb\\Data"); + +const ravendb = await ravenServer.addDatabase("ravendb"); + +const apiService = await builder.addProject("apiservice", "../ExampleProject/ExampleProject.csproj"); +await apiService.withReference(ravendb); +await apiService.waitFor(ravendb); + +// After adding all resources, run the app... +``` + + + + Data bind mounts rely on the host machine's filesystem to persist the RavenDB data across container restarts. The data bind mount is mounted at the `C:\RavenDb\Data` on Windows (or the equivalent Unix path) on the host machine in the RavenDB container. For more information on data bind mounts, see [Docker docs: Bind mounts](https://docs.docker.com/engine/storage/bind-mounts).