SeaweedFS integration in the AppHost
Konten ini belum tersedia dalam bahasa Anda.
The SeaweedFS hosting package runs the SeaweedFS container and exposes its APIs when enabled. For an overview, see Get started with the SeaweedFS integration.
Installation
Section titled “Installation”Install the package in the AppHost:
aspire add seaweedfsAspire CLI interaktif; pilih hasil pencarian yang sesuai saat diminta:
Select an integration to add:
> seaweedfs (CommunityToolkit.Aspire.Hosting.SeaweedFS)> Other results listed as selectable options...#:package CommunityToolkit.Aspire.Hosting.SeaweedFS@*<PackageReference Include="CommunityToolkit.Aspire.Hosting.SeaweedFS" Version="*" />Add a SeaweedFS resource
Section titled “Add a SeaweedFS resource”AddSeaweedFS starts the Master and Volume APIs. Call WithFiler to enable the native Filer API. Call WithS3 to enable the S3 gateway; this also enables Filer because the gateway depends on it.
import { function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder } from './.aspire/modules/aspire.mjs';
const const builder: IDistributedApplicationBuilder
builder = await function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder();
const const seaweedfs: SeaweedFSContainerResource
seaweedfs = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addSeaweedFS(name: string): SeaweedFSContainerResource
Adds a base SeaweedFS container (Master and Volume APIs) to the application model. Chain with .WithS3() or .WithFiler() to enable additional APIs.
addSeaweedFS('seaweedfs');await const seaweedfs: SeaweedFSContainerResource
seaweedfs.SeaweedFSContainerResource.withS3(options?: { s3Port?: number;}): SeaweedFSContainerResource (+1 overload)
Enables the SeaweedFS S3-Compatible API Gateway.
withS3();
const const api: ProjectResource
api = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: { launchProfileOrOptions?: string | ProjectResourceOptions;}): ProjectResource (+1 overload)
Adds a .NET project resource
addProject('api', '../Api/Api.csproj');await const api: ProjectResource
api.ProjectResource.withReference(source: IResource | EndpointReference | string | uri, options?: { connectionName?: string; optional?: boolean; name?: string;} | undefined): ProjectResource (+1 overload)
Adds a reference to another resource
withReference(const seaweedfs: SeaweedFSContainerResource
seaweedfs);
await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.build(): DistributedApplication
Builds the distributed application
build().DistributedApplication.run(cancellationToken?: cancellationToken): void
Runs the distributed application
run();var builder = DistributedApplication.CreateBuilder(args);
var seaweedfs = builder.AddSeaweedFS("seaweedfs") .WithS3();
builder.AddProject<Projects.Api>("api") .WithReference(seaweedfs);
// After adding all resources, run the app...builder.Build().Run();The resource starts with Master port 9333 and Volume port 8080. WithFiler adds Filer port 8888; WithS3 adds S3 port 8333. Aspire assigns host ports automatically unless a method receives a fixed port.
Select APIs and host ports
Section titled “Select APIs and host ports”Use the native Filer endpoint without starting S3. The example also sets a host port for the Master API and Filer API:
import { function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder } from './.aspire/modules/aspire.mjs';
const const builder: IDistributedApplicationBuilder
builder = await function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder();
const const seaweedfs: SeaweedFSContainerResource
seaweedfs = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addSeaweedFS(name: string): SeaweedFSContainerResource
Adds a base SeaweedFS container (Master and Volume APIs) to the application model. Chain with .WithS3() or .WithFiler() to enable additional APIs.
addSeaweedFS('seaweedfs');await const seaweedfs: SeaweedFSContainerResource
seaweedfs.SeaweedFSContainerResource.withFiler(filerPort?: number): SeaweedFSContainerResource (+1 overload)
Enables the SeaweedFS Native Filer API.
withFiler(8888);await const seaweedfs: SeaweedFSContainerResource
seaweedfs.SeaweedFSContainerResource.withHostPort(port: number | null): SeaweedFSContainerResource
Configures the Master API host port that the SeaweedFS resource is exposed on.
withHostPort(9333);
await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.build(): DistributedApplication
Builds the distributed application
build().DistributedApplication.run(cancellationToken?: cancellationToken): void
Runs the distributed application
run();var builder = DistributedApplication.CreateBuilder(args);
var seaweedfs = builder.AddSeaweedFS("seaweedfs") .WithFiler(filerPort: 8888) .WithHostPort(9333);
// After adding all resources, run the app...builder.Build().Run();WithHostPort sets the host port for the Master API. The optional port parameters on WithFiler and WithS3 set the host ports for those endpoints.
Configure S3 credentials
Section titled “Configure S3 credentials”AddSeaweedFS creates an admin access-key parameter and a generated secret-key parameter. Provide your own parameters when the S3 identity should use other credentials:
import { function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder } from './.aspire/modules/aspire.mjs';
const const builder: IDistributedApplicationBuilder
builder = await function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder();
const const accessKey: ParameterResource
accessKey = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addParameter(name: string, options?: { value?: string; publishValueAsDefault?: boolean; secret?: boolean;}): ParameterResource (+1 overload)
Adds a parameter resource
addParameter('seaweedfs-access-key', { secret?: boolean | undefined
secret: true,});const const secretKey: ParameterResource
secretKey = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addParameter(name: string, options?: { value?: string; publishValueAsDefault?: boolean; secret?: boolean;}): ParameterResource (+1 overload)
Adds a parameter resource
addParameter('seaweedfs-secret-key', { secret?: boolean | undefined
secret: true,});const const seaweedfs: SeaweedFSContainerResource
seaweedfs = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addSeaweedFS(name: string): SeaweedFSContainerResource
Adds a base SeaweedFS container (Master and Volume APIs) to the application model. Chain with .WithS3() or .WithFiler() to enable additional APIs.
addSeaweedFS('seaweedfs');await const seaweedfs: SeaweedFSContainerResource
seaweedfs.SeaweedFSContainerResource.withAccessKey(accessKey: string | ParameterResource): SeaweedFSContainerResource
Configures the Access Key that the SeaweedFS S3 resource uses.
withAccessKey(const accessKey: ParameterResource
accessKey);await const seaweedfs: SeaweedFSContainerResource
seaweedfs.SeaweedFSContainerResource.withSecretKey(secretKey: string | ParameterResource): SeaweedFSContainerResource
Configures the Secret Key that the SeaweedFS S3 resource uses.
withSecretKey(const secretKey: ParameterResource
secretKey);await const seaweedfs: SeaweedFSContainerResource
seaweedfs.SeaweedFSContainerResource.withS3(options?: { s3Port?: number;}): SeaweedFSContainerResource (+1 overload)
Enables the SeaweedFS S3-Compatible API Gateway.
withS3();
await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.build(): DistributedApplication
Builds the distributed application
build().DistributedApplication.run(cancellationToken?: cancellationToken): void
Runs the distributed application
run();var builder = DistributedApplication.CreateBuilder(args);
var accessKey = builder.AddParameter("seaweedfs-access-key", secret: true);var secretKey = builder.AddParameter("seaweedfs-secret-key", secret: true);
var seaweedfs = builder.AddSeaweedFS("seaweedfs") .WithAccessKey(accessKey) .WithSecretKey(secretKey) .WithS3();
// After adding all resources, run the app...builder.Build().Run();The integration writes the selected credentials into the S3 identity configuration it generates for the container. Store secrets in a secret provider rather than source control.
Persist SeaweedFS data
Section titled “Persist SeaweedFS data”Use WithDataVolume to persist /data outside the container lifecycle. Aspire generates a volume name unless you provide one:
import { function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder } from './.aspire/modules/aspire.mjs';
const const builder: IDistributedApplicationBuilder
builder = await function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder();
const const seaweedfs: SeaweedFSContainerResource
seaweedfs = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addSeaweedFS(name: string): SeaweedFSContainerResource
Adds a base SeaweedFS container (Master and Volume APIs) to the application model. Chain with .WithS3() or .WithFiler() to enable additional APIs.
addSeaweedFS('seaweedfs');await const seaweedfs: SeaweedFSContainerResource
seaweedfs.SeaweedFSContainerResource.withS3(options?: { s3Port?: number;}): SeaweedFSContainerResource (+1 overload)
Enables the SeaweedFS S3-Compatible API Gateway.
withS3();await const seaweedfs: SeaweedFSContainerResource
seaweedfs.SeaweedFSContainerResource.withDataVolume(name?: string, isReadOnly?: boolean): SeaweedFSContainerResource (+1 overload)
Adds a named volume for the SeaweedFS data folder.
withDataVolume('seaweedfs-data');
await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.build(): DistributedApplication
Builds the distributed application
build().DistributedApplication.run(cancellationToken?: cancellationToken): void
Runs the distributed application
run();var builder = DistributedApplication.CreateBuilder(args);
var seaweedfs = builder.AddSeaweedFS("seaweedfs") .WithS3() .WithDataVolume("seaweedfs-data");
// After adding all resources, run the app...builder.Build().Run();Use WithDataBindMount to access a specific host directory directly:
import { function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder } from './.aspire/modules/aspire.mjs';
const const builder: IDistributedApplicationBuilder
builder = await function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder();
const const seaweedfs: SeaweedFSContainerResource
seaweedfs = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addSeaweedFS(name: string): SeaweedFSContainerResource
Adds a base SeaweedFS container (Master and Volume APIs) to the application model. Chain with .WithS3() or .WithFiler() to enable additional APIs.
addSeaweedFS('seaweedfs');await const seaweedfs: SeaweedFSContainerResource
seaweedfs.SeaweedFSContainerResource.withFiler(options?: { filerPort?: number;}): SeaweedFSContainerResource (+1 overload)
Enables the SeaweedFS Native Filer API.
withFiler();await const seaweedfs: SeaweedFSContainerResource
seaweedfs.SeaweedFSContainerResource.withDataBindMount(source: string, options?: { isReadOnly?: boolean;}): SeaweedFSContainerResource (+1 overload)
Adds a bind mount for the SeaweedFS data folder.
withDataBindMount('./data/seaweedfs');
await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.build(): DistributedApplication
Builds the distributed application
build().DistributedApplication.run(cancellationToken?: cancellationToken): void
Runs the distributed application
run();var builder = DistributedApplication.CreateBuilder(args);
var seaweedfs = builder.AddSeaweedFS("seaweedfs") .WithFiler() .WithDataBindMount("./data/seaweedfs");
// After adding all resources, run the app...builder.Build().Run();Named volumes persist data without depending on a host path. Bind mounts are useful during development when you need to inspect or edit host files directly.
Use a custom S3 configuration file
Section titled “Use a custom S3 configuration file”Call WithS3ConfigFile after enabling S3 to mount a custom configuration file read-only at /etc/seaweedfs/s3-custom.json. The method throws if WithS3 has not been called:
import { function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder } from './.aspire/modules/aspire.mjs';
const const builder: IDistributedApplicationBuilder
builder = await function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder();
const const seaweedfs: SeaweedFSContainerResource
seaweedfs = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addSeaweedFS(name: string): SeaweedFSContainerResource
Adds a base SeaweedFS container (Master and Volume APIs) to the application model. Chain with .WithS3() or .WithFiler() to enable additional APIs.
addSeaweedFS('seaweedfs');await const seaweedfs: SeaweedFSContainerResource
seaweedfs.SeaweedFSContainerResource.withS3(options?: { s3Port?: number;}): SeaweedFSContainerResource (+1 overload)
Enables the SeaweedFS S3-Compatible API Gateway.
withS3();await const seaweedfs: SeaweedFSContainerResource
seaweedfs.SeaweedFSContainerResource.withS3ConfigFile(configFilePath: string): SeaweedFSContainerResource
Configures the SeaweedFS S3 API to use a specific external security configuration file.
withS3ConfigFile('./seaweedfs/s3.json');
await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.build(): DistributedApplication
Builds the distributed application
build().DistributedApplication.run(cancellationToken?: cancellationToken): void
Runs the distributed application
run();var builder = DistributedApplication.CreateBuilder(args);
var seaweedfs = builder.AddSeaweedFS("seaweedfs") .WithS3() .WithS3ConfigFile("./seaweedfs/s3.json");
// After adding all resources, run the app...builder.Build().Run();The custom file replaces the generated S3 identity configuration. Define the desired identities and credentials in that file. The AppHost still exposes its credential parameters in the connection string; set WithAccessKey and WithSecretKey to credentials matching an identity in the file.
Hosting integration health checks
Section titled “Hosting integration health checks”The integration adds a SeaweedFS health check that queries the Master API at /dir/status with Accept: application/json. It requires a successful response containing a non-zero Topology.Max value, which indicates that the Volume Server has registered storage capacity. A running Master alone is not considered ready. This probe does not separately check the S3 or Filer APIs.
Connection properties
Section titled “Connection properties”With both S3 and Filer enabled, referencing the resource creates a connection string with this shape:
Endpoint=http://{s3-host}:{s3-port};AccessKey={key};SecretKey={secret};FilerEndpoint=http://{filer-host}:{filer-port}Endpoint points to the S3 API when enabled, or the Master API otherwise. The connection properties include Host, Port, and MasterUrl; S3Url, AccessKey, and SecretKey are available when S3 is enabled; FilerUrl is available when Filer is enabled. See Connect to SeaweedFS for client configuration.
Exported AppHost API
Section titled “Exported AppHost API”AddSeaweedFS(name)creates the base Master and Volume resource.WithS3(s3Port)enables the S3 gateway and implicitly enables Filer.WithFiler(filerPort)enables the native Filer API.WithHostPort(port)selects the Master API host port.WithAccessKey(parameter)andWithSecretKey(parameter)select custom S3 credential parameters.WithS3ConfigFile(configFilePath)mounts a custom S3 configuration file. Call it after enabling S3.WithDataBindMount(source, isReadOnly)mounts a host directory at/data.WithDataVolume(name, isReadOnly)mounts a named volume at/data.
All listed APIs are exported to TypeScript AppHosts with their corresponding camel-case names.