Skip to content

Add Aspire component #125

@LeftTwixWand

Description

@LeftTwixWand

It would be amazing, if we can have Flagsmith Aspire component.
I can provide some help in development of this aspire component.

Why?

How it should look like

// AppHost.Program.cs

var builder = DistributedApplication.CreateBuilder(args);

var flagsmith = builder.AddFlagsmith();

var apiService = builder.AddProject<My_WebApi>("apiservice")
	.WithEnvironment(flagsmith); // Pupulates URL and EnvironmentKey
// ServiceDefaults.Extensions.cs

public static TBuilder AddServiceDefaults<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
      builder.AddFlagsmithClient(); // Registers FlagsmithClient into DI with URL and EnvironmentKey
}

Example of configuration with database

// AppHost.Program.cs

var builder = DistributedApplication.CreateBuilder(args);

var postgresServer = builder.AddPostgres("postgresserver")
	// Mount the SQL scripts directory into the container.
	// Init script would create a flagsmith database, becuase Aspire doesn't create DB by default yet.
	.WithContainerName("postgresserver")
	.WithBindMount("../Postgres", "/docker-entrypoint-initdb.d");

var flagsmithDatabase = postgresServer.AddDatabase("flagsmithDatabase", databaseName: "flagsmithdb");

var flagsmith = builder.AddFlagsmith()
	.WithReference(flagsmithDatabase) // Populates DATABASE_URL
	.WaitFor(flagsmithDatabase)

var apiService = builder.AddProject<My_WebApi>("apiservice")
	.WithEnvironment(flagsmith);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions