RustFS integration in the AppHost
The RustFS hosting package runs the rustfs/rustfs:1.0.0 container. For an overview, see Get started with the RustFS integration.
Installation
Section titled “Installation”Install the package in the AppHost:
aspire add rustfsThe Aspire CLI is interactive, be sure to select the appropriate search result when prompted:
Select an integration to add:
> rustfs (CommunityToolkit.Aspire.Hosting.RustFs)> Other results listed as selectable options...#:package CommunityToolkit.Aspire.Hosting.RustFs@*<PackageReference Include="CommunityToolkit.Aspire.Hosting.RustFs" Version="*" />Add a RustFS resource
Section titled “Add a RustFS resource”AddRustFs adds the S3-compatible object store and the console endpoint. It creates access-key and secret-key parameters when you do not provide your own. Aspire assigns host ports unless you choose ports in AddRustFs.
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 rustfs: RustFsResource
rustfs = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addRustFs(name: string, options?: { accessKey?: string | ParameterResource; secretKey?: string | ParameterResource; port?: number; consolePort?: number;}): RustFsResource (+1 overload)
Adds a RustFs container to the application model. The default image is "rustfs/rustfs".
addRustFs('rustfs');await const rustfs: RustFsResource
rustfs.RustFsResource.withDataVolume(options?: { name?: string;}): RustFsResource (+1 overload)
Adds a named volume for the data folder to a RustFs container resource.
withDataVolume();
const const api: NodeAppResource
api = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addNodeApp(name: string, appDirectory: string, scriptPath: string): NodeAppResource
Adds a node application to the application model. Node should be available on the PATH.
addNodeApp('api', './api', 'index.js');await const api: NodeAppResource
api.ExecutableResource.withReference(source: IResource | EndpointReference | string | uri, options?: { connectionName?: string; optional?: boolean; name?: string;} | undefined): NodeAppResource (+1 overload)
Adds a reference to another resource
withReference(const rustfs: RustFsResource
rustfs);
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 rustfs = builder.AddRustFs("rustfs") .WithDataVolume();
builder.AddProject<Projects.Api>("api") .WithReference(rustfs);
// After adding all resources, run the app...builder.Build().Run();The resource exposes the S3 API on container port 9000 and the console on container port 9001. Host ports are allocated by Aspire by default. port and consolePort on AddRustFs let you select fixed host ports.
Configure credentials and ports
Section titled “Configure credentials and ports”Pass AppHost parameter resources to AddRustFs when you need explicit credentials. Leave port and consolePort unset to use dynamically assigned host ports:
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('rustfs-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('rustfs-secret-key', { secret?: boolean | undefined
secret: true,});const const rustfs: RustFsResource
rustfs = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addRustFs(name: string, options?: { accessKey?: string | ParameterResource; secretKey?: string | ParameterResource; port?: number; consolePort?: number;}): RustFsResource (+1 overload)
Adds a RustFs container to the application model. The default image is "rustfs/rustfs".
addRustFs('rustfs', { accessKey?: string | ParameterResource | undefined
accessKey, secretKey?: string | ParameterResource | undefined
secretKey, port?: number | undefined
port: 9000, consolePort?: number | undefined
consolePort: 9001,});await const rustfs: RustFsResource
rustfs.RustFsResource.withDataVolume(options?: { name?: string;}): RustFsResource (+1 overload)
Adds a named volume for the data folder to a RustFs container resource.
withDataVolume();
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("rustfs-access-key", secret: true);var secretKey = builder.AddParameter("rustfs-secret-key", secret: true);
var rustfs = builder.AddRustFs( "rustfs", accessKey: accessKey, secretKey: secretKey, port: 9000, consolePort: 9001) .WithDataVolume();
// After adding all resources, run the app...builder.Build().Run();If you omit either parameter, the integration generates a password parameter for that key. Do not use a fixed host port if another process may already be listening on it.
Persist data
Section titled “Persist data”Use WithDataVolume to keep RustFS data outside the container lifecycle. Aspire creates a named Docker volume unless you provide a name:
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 rustfs: RustFsResource
rustfs = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addRustFs(name: string, options?: { accessKey?: string | ParameterResource; secretKey?: string | ParameterResource; port?: number; consolePort?: number;}): RustFsResource (+1 overload)
Adds a RustFs container to the application model. The default image is "rustfs/rustfs".
addRustFs('rustfs');await const rustfs: RustFsResource
rustfs.RustFsResource.withDataVolume(name?: string): RustFsResource (+1 overload)
Adds a named volume for the data folder to a RustFs container resource.
withDataVolume('rustfs-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 rustfs = builder.AddRustFs("rustfs") .WithDataVolume("rustfs-data");
// After adding all resources, run the app...builder.Build().Run();Use WithDataBindMount to mount a host directory at /data when you need direct access to files during development:
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 rustfs: RustFsResource
rustfs = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addRustFs(name: string, options?: { accessKey?: string | ParameterResource; secretKey?: string | ParameterResource; port?: number; consolePort?: number;}): RustFsResource (+1 overload)
Adds a RustFs container to the application model. The default image is "rustfs/rustfs".
addRustFs('rustfs');await const rustfs: RustFsResource
rustfs.RustFsResource.withDataBindMount(source: string): RustFsResource
Adds a bind mount for the data folder to a RustFs container resource.
withDataBindMount('./data/rustfs');
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 rustfs = builder.AddRustFs("rustfs") .WithDataBindMount("./data/rustfs");
// After adding all resources, run the app...builder.Build().Run();Volumes persist data without coupling it to a host directory path. Bind mounts make the host directory directly accessible to the container.
Provision buckets
Section titled “Provision buckets”Call AddBucket to register a child resource for one bucket. Aspire waits until the RustFS parent is ready, then issues a signed S3 PUT request to create the bucket. A bucket that already exists is treated as ready. The child resource appears in the dashboard and exposes its own connection string with a Bucket property.
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 rustfs: RustFsResource
rustfs = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addRustFs(name: string, options?: { accessKey?: string | ParameterResource; secretKey?: string | ParameterResource; port?: number; consolePort?: number;}): RustFsResource (+1 overload)
Adds a RustFs container to the application model. The default image is "rustfs/rustfs".
addRustFs('rustfs');await const rustfs: RustFsResource
rustfs.RustFsResource.withDataVolume(options?: { name?: string;}): RustFsResource (+1 overload)
Adds a named volume for the data folder to a RustFs container resource.
withDataVolume();const const images: RustFsBucketResource
images = await const rustfs: RustFsResource
rustfs.RustFsResource.addBucket(bucketName: string): RustFsBucketResource
Adds a bucket to the RustFs resource. The bucket is created by issuing a signed PUT request to the RustFs S3 API after the server resource becomes ready.
addBucket('images');const const documents: RustFsBucketResource
documents = await const rustfs: RustFsResource
rustfs.RustFsResource.addBucket(bucketName: string): RustFsBucketResource
Adds a bucket to the RustFs resource. The bucket is created by issuing a signed PUT request to the RustFs S3 API after the server resource becomes ready.
addBucket('documents');
const const api: NodeAppResource
api = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addNodeApp(name: string, appDirectory: string, scriptPath: string): NodeAppResource
Adds a node application to the application model. Node should be available on the PATH.
addNodeApp('api', './api', 'index.js');await const api: NodeAppResource
api.ExecutableResource.withReference(source: IResource | EndpointReference | string | uri, options?: { connectionName?: string; optional?: boolean; name?: string;} | undefined): NodeAppResource (+1 overload)
Adds a reference to another resource
withReference(const images: RustFsBucketResource
images);await const api: NodeAppResource
api.ExecutableResource.withReference(source: IResource | EndpointReference | string | uri, options?: { connectionName?: string; optional?: boolean; name?: string;} | undefined): NodeAppResource (+1 overload)
Adds a reference to another resource
withReference(const documents: RustFsBucketResource
documents);
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 rustfs = builder.AddRustFs("rustfs") .WithDataVolume();var images = rustfs.AddBucket("images");var documents = rustfs.AddBucket("documents");
builder.AddProject<Projects.Api>("api") .WithReference(images) .WithReference(documents);
// After adding all resources, run the app...builder.Build().Run();Use the list overload to add several buckets while keeping the parent builder for further configuration. The TypeScript method name for this overload is addBuckets:
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 rustfs: RustFsResource
rustfs = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addRustFs(name: string, options?: { accessKey?: string | ParameterResource; secretKey?: string | ParameterResource; port?: number; consolePort?: number;}): RustFsResource (+1 overload)
Adds a RustFs container to the application model. The default image is "rustfs/rustfs".
addRustFs('rustfs');await const rustfs: RustFsResource
rustfs.RustFsResource.addBuckets(bucketNames: string[]): RustFsResource
Adds multiple buckets to the RustFs resource. Each bucket is registered as its own RustFsBucketResource child resource and created via the RustFs S3 API once the server resource becomes ready.
addBuckets(['images', 'documents', 'audit-log']);
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 rustfs = builder.AddRustFs("rustfs") .AddBucket(["images", "documents", "audit-log"]);
// After adding all resources, run the app...builder.Build().Run();Configure the signing region
Section titled “Configure the signing region”Bucket provisioning uses AWS Signature Version 4 with the default signing region us-east-1. Call WithSigningRegion when your RustFS setup expects another region:
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 rustfs: RustFsResource
rustfs = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addRustFs(name: string, options?: { accessKey?: string | ParameterResource; secretKey?: string | ParameterResource; port?: number; consolePort?: number;}): RustFsResource (+1 overload)
Adds a RustFs container to the application model. The default image is "rustfs/rustfs".
addRustFs('rustfs');await const rustfs: RustFsResource
rustfs.RustFsResource.withSigningRegion(region: string): RustFsResource
Sets the AWS signing region used when creating buckets via the S3 API. Defaults to us-east-1 if not specified.
withSigningRegion('ap-northeast-1');await const rustfs: RustFsResource
rustfs.RustFsResource.addBucket(bucketName: string): RustFsBucketResource
Adds a bucket to the RustFs resource. The bucket is created by issuing a signed PUT request to the RustFs S3 API after the server resource becomes ready.
addBucket('images');
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 rustfs = builder.AddRustFs("rustfs") .WithSigningRegion("ap-northeast-1") .AddBucket("images");
// After adding all resources, run the app...builder.Build().Run();Hosting integration health checks
Section titled “Hosting integration health checks”The integration configures an HTTP health check against /health on the primary S3 endpoint and expects HTTP 200. Bucket provisioning waits for the RustFS resource’s ready event before making its signed request. If provisioning fails, the child bucket resource reports the error in the dashboard.
Connection properties
Section titled “Connection properties”Reference the RustFS resource to pass a connection string with Endpoint, AccessKey, and SecretKey to a dependent app. The value is formatted as Endpoint=http://{host}:{port};AccessKey={key};SecretKey={secret}. A bucket resource adds Bucket={bucketName}. The resource also exposes the Host, Port, AccessKey, SecretKey, and Uri properties. The console endpoint is visible in the dashboard but is not part of the S3 connection string.
For S3 client configuration, see Connect to RustFS.
Exported AppHost API
Section titled “Exported AppHost API”AddRustFs(name, accessKey, secretKey, port, consolePort)adds the container and its two endpoints.WithDataVolume(name)mounts a Docker volume at/data.WithDataBindMount(source)binds a host directory at/data.WithSigningRegion(region)sets the SigV4 region used when creating buckets.AddBucket(bucketName)adds one child bucket resource; the TypeScript method isaddBucket.AddBucket(bucketNames)adds multiple child resources; the TypeScript method isaddBuckets.