@bylocico/testcontainers-rustfs

中文文档
1.0.0-beta.1发布于 2026/05/08MITTypeScriptES Module近 30 天下载 3342

Testcontainers wrapper for RustFS — an S3-compatible object store written in Rust.

原始使用文档
文档目录11 节
  1. Versioning
  2. Install
  3. Usage
  4. API
  5. new RustfsContainer(image?: string)
  6. .withCredentials(user, password)
  7. StartedRustfsContainer
  8. S3 Client Notes
  9. Development
  10. Publishing
  11. Upstreaming

@bylocico/testcontainers-rustfs

A small Testcontainers wrapper for RustFS, an S3-compatible object store written in Rust.

The package is intentionally dependency-light and shaped like the official Testcontainers modules so it can be upstreamed to testcontainers/testcontainers-node later.

Versioning

The npm package version tracks the RustFS Docker image version it targets.

For example, @bylocico/[email protected] defaults to:

rustfs/rustfs:1.0.0-beta.1

Wrapper-only changes should be kept small and released with the next RustFS target version where practical. If an urgent wrapper fix is needed before RustFS moves, publish a patch version and document the exception in the release notes.

CI runs automatically on pull requests and pushes. The update workflow also queries Docker Hub on a schedule, finds every new semver RustFS image tag, tests each one in ascending order, and opens an auto-merge PR that retargets the package to the newest passing tag. Variant image tags such as -glibc are ignored for package versioning because they are image flavors, not RustFS release versions.

Consumers can still pull any valid RustFS image version without waiting for this package to retarget:

await new RustfsContainer('rustfs/rustfs:1.0.0-beta.1').start()
await new RustfsContainer('rustfs/rustfs:latest').start()

Install

npm install --save-dev @bylocico/testcontainers-rustfs @aws-sdk/client-s3

@aws-sdk/client-s3 is a peer dependency because most consumers already own their SDK version.

Usage

import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3'
import { RustfsContainer } from '@bylocico/testcontainers-rustfs'

const rustfs = await new RustfsContainer().start()

try {
  await rustfs.ensureBucket('my-bucket')

  const s3 = new S3Client({
    endpoint: rustfs.getEndpoint(),
    region: 'us-east-1',
    credentials: {
      accessKeyId: rustfs.accessKey,
      secretAccessKey: rustfs.secretKey,
    },
    forcePathStyle: true,
  })

  try {
    await s3.send(
      new PutObjectCommand({
        Bucket: 'my-bucket',
        Key: 'hello.txt',
        Body: 'world',
      }),
    )
  } finally {
    s3.destroy()
  }
} finally {
  await rustfs.stop()
}

API

new RustfsContainer(image?: string)

Creates an unstarted RustFS container. By default it uses the RustFS image version that matches the package version.

Pass an explicit image to test a different RustFS release:

new RustfsContainer('rustfs/rustfs:latest')
new RustfsContainer('rustfs/rustfs:1.0.0-beta.1')

.withCredentials(user, password)

Overrides the default root user/password.

Defaults:

rustfsadmin / rustfsadmin

Example:

const rustfs = await new RustfsContainer()
  .withCredentials('test-user', 'test-password')
  .start()

All normal GenericContainer builder methods remain available through inheritance, including withEnvironment, withCommand, and withNetwork.

StartedRustfsContainer

The started container exposes:

  • getEndpoint(): string - http://<host>:<port> for the S3 API
  • getHost(): string
  • getPort(): number
  • accessKey: string
  • secretKey: string
  • ensureBucket(name): Promise<void>
  • stop(): Promise<void>

ensureBucket() is idempotent and tolerates BucketAlreadyOwnedByYou and BucketAlreadyExists.

S3 Client Notes

Use getEndpoint() rather than hardcoding ports. Testcontainers maps container port 9000 to a random host port.

Use path-style addressing with the AWS SDK:

forcePathStyle: true

Virtual-hosted-style addressing requires DNS entries that the test container does not provide.

Development

Requirements:

  • Node.js 18+
  • npm
  • Docker

Install dependencies:

npm install

Run checks:

npm run typecheck
npm run build
npm test

Run tests against a specific RustFS image:

RUSTFS_IMAGE=rustfs/rustfs:latest npm test

List RustFS release image tags newer than the package target:

node scripts/update-rustfs-version.mjs --list-newer

Retarget the package to a specific RustFS version:

node scripts/update-rustfs-version.mjs --version 1.0.0-beta.1
npm install --package-lock-only

Inspect the package contents before publishing:

npm pack --dry-run

Publishing

Publishing is handled by .github/workflows/publish.yml.

Repository setup:

  1. Create an npm automation token with publish access to @bylocico/testcontainers-rustfs.
  2. Add it to the GitHub repository as NPM_TOKEN.
  3. Ensure GitHub Actions has permission to request OIDC tokens for npm provenance.

Release flow:

  1. Confirm the target RustFS Docker tag exists:

    docker manifest inspect rustfs/rustfs:1.0.0-beta.1
    
  2. Update package.json and DEFAULT_RUSTFS_VERSION to the same version.

  3. Run npm install so package-lock.json records the new package version.

  4. Run npm run typecheck && npm run build && npm test && npm pack --dry-run.

  5. Push to main.

  6. Create a GitHub release for the same version, for example v1.0.0-beta.1.

  7. The publish workflow runs tests and publishes with npm provenance:

    npm publish --access public --provenance
    

Upstreaming

Keep the public API close to the official Testcontainers module style:

  • one container class extending GenericContainer
  • one started container class extending AbstractStartedContainer
  • no application-specific dependencies
  • no Bylocico or Ema-specific runtime behavior

That keeps a future upstream contribution to testcontainers/testcontainers-node small and reviewable.

版本与发布记录

@bylocico/testcontainers-rustfs 共发布 1 个版本,首次发布于 2026/05/08;过去 12 个月发布了 1 个版本。

版本发布日期距今
1.0.0-beta.1latest2026/05/086 个月前

关于 @bylocico/testcontainers-rustfs 的常见问题

@bylocico/testcontainers-rustfs 是什么?

Testcontainers wrapper for RustFS — an S3-compatible object store written in Rust.

如何安装 @bylocico/testcontainers-rustfs?

在项目目录运行 npm install @bylocico/testcontainers-rustfs,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@aws-sdk/client-s3(>=3)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bylocico/testcontainers-rustfs 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bylocico/testcontainers-rustfs 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@bylocico/testcontainers-rustfs 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@bylocico/testcontainers-rustfs 可以商用吗?

@bylocico/testcontainers-rustfs 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bylocico/testcontainers-rustfs 的下载量有多少?

根据 npm 官方下载统计,@bylocico/testcontainers-rustfs 在 2026/10/09 – 2026/11/07 这 30 天内被下载 3,342 次,日均约 111 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bylocico/testcontainers-rustfs 还在维护吗?

最新版本 1.0.0-beta.1 发布于 2026/05/08(6 个月前);至今共发布 1 个版本,其中过去 12 个月发布了 1 个;首次发布于 2026/05/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。