From b817bf8e7218e99c767aeacae0ec82b802af8bed Mon Sep 17 00:00:00 2001 From: Fredi Machado Date: Sun, 19 May 2024 08:46:56 +1000 Subject: [PATCH] Add data volume to EventStore resource --- .../EventStoreBuilderExtensions.cs | 9 +++++++++ src/Aspire/NCafe.AppHost/Program.cs | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Aspire/Aspire.Hosting.EventStore/EventStoreBuilderExtensions.cs b/src/Aspire/Aspire.Hosting.EventStore/EventStoreBuilderExtensions.cs index 02bd19c..93e39f8 100644 --- a/src/Aspire/Aspire.Hosting.EventStore/EventStoreBuilderExtensions.cs +++ b/src/Aspire/Aspire.Hosting.EventStore/EventStoreBuilderExtensions.cs @@ -28,6 +28,15 @@ public static IResourceBuilder AddEventStore( .WithEnvironment(context => ConfigureEventStoreContainer(context, eventStoreContainer)); } + /// + /// Adds a named volume for the data folder to an EventStore container resource. + /// + /// The resource builder. + /// The name of the volume. Defaults to an auto-generated name based on the application and resource names. + /// The . + public static IResourceBuilder WithDataVolume(this IResourceBuilder builder, string? name = null) + => builder.WithVolume(name ?? "eventstore-volume-data", "/var/lib/eventstore"); + private static void ConfigureEventStoreContainer(EnvironmentCallbackContext context, EventStoreResource resource) { context.EnvironmentVariables.Add("EVENTSTORE_CLUSTER_SIZE", "1"); diff --git a/src/Aspire/NCafe.AppHost/Program.cs b/src/Aspire/NCafe.AppHost/Program.cs index fe8f072..d92fa1a 100644 --- a/src/Aspire/NCafe.AppHost/Program.cs +++ b/src/Aspire/NCafe.AppHost/Program.cs @@ -1,7 +1,8 @@ var builder = DistributedApplication.CreateBuilder(args); -var eventStore = builder.AddEventStore("eventstore"); var rabbitMq = builder.AddRabbitMQ("rabbitmq"); +var eventStore = builder.AddEventStore("eventstore") + .WithDataVolume(); var adminProject = builder.AddProject("admin-api") .WithReference(eventStore);