charmd-cf-worker
Workers — Rust crates compiled to WASM via worker-build and tested with Vitest.The module layers CF worker tooling (Node.js, pnpm, wasm-tools, worker-build)
on top of the Rust dev container and exposes Build, Test, and Deploy functions.
pnpm is used as the Node package manager across all CHARMD stack applications.
Installation
dagger install github.com/moosingin3space/daggerverse/modules/charmd-cf-worker@885cb1f53ec035a25e6f3c6f77917c6aaa95c127Entrypoint
Return Type
CharmdCfWorker Example
dagger -m github.com/moosingin3space/daggerverse/modules/charmd-cf-worker@885cb1f53ec035a25e6f3c6f77917c6aaa95c127 call \
func (m *MyModule) Example() *dagger.CharmdCfWorker {
return dag.
CharmdCfWorker()
}@function
def example() -> dagger.CharmdCfWorker:
return (
dag.charmd_cf_worker()
)@func()
example(): CharmdCfWorker {
return dag
.charmdCfWorker()
}Types
CharmdCfWorker 🔗
container() 🔗
Return Type
Container ! Example
dagger -m github.com/moosingin3space/daggerverse/modules/charmd-cf-worker@885cb1f53ec035a25e6f3c6f77917c6aaa95c127 call \
containerfunc (m *MyModule) Example() *dagger.Container {
return dag.
CharmdCfWorker().
Container()
}@function
def example() -> dagger.Container:
return (
dag.charmd_cf_worker()
.container()
)@func()
example(): Container {
return dag
.charmdCfWorker()
.container()
}build() 🔗
Build compiles the Cloudflare Worker in release mode via worker-build.
Return Type
String ! Example
dagger -m github.com/moosingin3space/daggerverse/modules/charmd-cf-worker@885cb1f53ec035a25e6f3c6f77917c6aaa95c127 call \
buildfunc (m *MyModule) Example(ctx context.Context) string {
return dag.
CharmdCfWorker().
Build(ctx)
}@function
async def example() -> str:
return await (
dag.charmd_cf_worker()
.build()
)@func()
async example(): Promise<string> {
return dag
.charmdCfWorker()
.build()
}deploy() 🔗
Deploy deploys the Cloudflare Worker using Wrangler.
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| cloudflareApiToken | Secret ! | - | Cloudflare API token for authentication |
| cloudflareAccountId | Secret ! | - | Cloudflare account ID |
Example
dagger -m github.com/moosingin3space/daggerverse/modules/charmd-cf-worker@885cb1f53ec035a25e6f3c6f77917c6aaa95c127 call \
deploy --cloudflare-api-token env:MYSECRET --cloudflare-account-id env:MYSECRETfunc (m *MyModule) Example(ctx context.Context, cloudflareApiToken *dagger.Secret, cloudflareAccountId *dagger.Secret) string {
return dag.
CharmdCfWorker().
Deploy(ctx, cloudflareApiToken, cloudflareAccountId)
}@function
async def example(cloudflare_api_token: dagger.Secret, cloudflare_account_id: dagger.Secret) -> str:
return await (
dag.charmd_cf_worker()
.deploy(cloudflare_api_token, cloudflare_account_id)
)@func()
async example(cloudflareApiToken: Secret, cloudflareAccountId: Secret): Promise<string> {
return dag
.charmdCfWorker()
.deploy(cloudflareApiToken, cloudflareAccountId)
}devContainer() 🔗
DevContainer creates a CHARMD stack Cloudflare Worker build environment on top of the Rust dev container, installing Node.js, pnpm, and the worker-build toolchain. Call Build, Test, or Deploy on the returned value.
Return Type
CharmdCfWorker !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory | - | No description provided |
| workerDir | String ! | - | Subdirectory within source that contains the worker package.json (e.g. "hubdash-cf") |
| toolchainFile | File | - | No description provided |
| pnpmVersion | String | "10.30.3" | pnpm version to install globally via npm |
| pnpmCacheVolume | String | - | Name of the Dagger cache volume used for the pnpm store. If empty, the pnpm store is not cached between runs. |
Example
dagger -m github.com/moosingin3space/daggerverse/modules/charmd-cf-worker@885cb1f53ec035a25e6f3c6f77917c6aaa95c127 call \
dev-container --worker-dir stringfunc (m *MyModule) Example(workerDir string) *dagger.CharmdCfWorker {
return dag.
CharmdCfWorker().
DevContainer(workerDir)
}@function
def example(worker_dir: str) -> dagger.CharmdCfWorker:
return (
dag.charmd_cf_worker()
.dev_container(worker_dir)
)@func()
example(workerDir: string): CharmdCfWorker {
return dag
.charmdCfWorker()
.devContainer(workerDir)
}test() 🔗
Test performs a dry-run wrangler deploy (to validate the build and config) followed by the vitest suite.
Return Type
String ! Example
dagger -m github.com/moosingin3space/daggerverse/modules/charmd-cf-worker@885cb1f53ec035a25e6f3c6f77917c6aaa95c127 call \
testfunc (m *MyModule) Example(ctx context.Context) string {
return dag.
CharmdCfWorker().
Test(ctx)
}@function
async def example() -> str:
return await (
dag.charmd_cf_worker()
.test()
)@func()
async example(): Promise<string> {
return dag
.charmdCfWorker()
.test()
}