Skip to content

Commit

Permalink
Add data volume to EventStore resource
Browse files Browse the repository at this point in the history
  • Loading branch information
fredimachado committed May 18, 2024
1 parent 09d2e03 commit b817bf8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ public static IResourceBuilder<EventStoreResource> AddEventStore(
.WithEnvironment(context => ConfigureEventStoreContainer(context, eventStoreContainer));
}

/// <summary>
/// Adds a named volume for the data folder to an EventStore container resource.
/// </summary>
/// <param name="builder">The resource builder.</param>
/// <param name="name">The name of the volume. Defaults to an auto-generated name based on the application and resource names.</param>
/// <returns>The <see cref="IResourceBuilder{T}"/>.</returns>
public static IResourceBuilder<EventStoreResource> WithDataVolume(this IResourceBuilder<EventStoreResource> 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");
Expand Down
3 changes: 2 additions & 1 deletion src/Aspire/NCafe.AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -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<Projects.NCafe_Admin_Api>("admin-api")
.WithReference(eventStore);
Expand Down

0 comments on commit b817bf8

Please sign in to comment.