Deployment¶
Run 2.0 supports multiple deployment targets for your WASI components.
Deployment Targets¶
| Target | Description | Use Case |
|---|---|---|
local | Package for local/self-hosted | VMs, containers, local servers |
registry | Publish to component registry | Sharing, distribution |
edge | Deploy to edge platforms | Serverless, CDN |
Local Deployment¶
Package components for local deployment:
This creates a deployment bundle:
dist/deploy/
├── deploy.json # Manifest with checksums
├── run.toml # Configuration
├── api.wasm # Component binaries
└── worker.wasm
Custom Output¶
Deploy Profile¶
Configure in run.toml:
Use:
Registry Deployment¶
Publish to the component registry:
See Registry for details.
Edge Deployment¶
Deploy to serverless edge platforms.
Supported Providers¶
| Provider | Status | Config Key |
|---|---|---|
| Cloudflare Workers | Supported | cloudflare |
| AWS Lambda | Planned | aws-lambda |
| Vercel | Planned | vercel |
| Fastly Compute | Planned | fastly |
Cloudflare Workers¶
- Set up credentials:
- Configure
run.toml:
[deploy.edge]
target_type = "edge"
provider = "cloudflare"
[deploy.edge.options]
workers_dev = true
# Or specify a zone:
# zone_id = "your-zone-id"
# route = "example.com/*"
- Deploy:
Deploy Profiles¶
Define multiple deployment configurations:
[deploy.staging]
target_type = "edge"
provider = "cloudflare"
[deploy.staging.options]
workers_dev = true
name_suffix = "-staging"
[deploy.production]
target_type = "edge"
provider = "cloudflare"
[deploy.production.options]
zone_id = "abc123"
route = "api.example.com/*"
Deploy to staging:
Deploy to production:
CI/CD Integration¶
GitHub Actions¶
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install Run
run: cargo install run-kit --features v2
- name: Build
run: run v2 build --release --reproducible
- name: Deploy to Registry
env:
RUN_AUTH_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
run: run v2 publish
- name: Deploy to Edge
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT }}
run: run v2 deploy --target edge --provider cloudflare
Reproducible Builds¶
For consistent CI/CD builds:
- Lock toolchains:
- Build with reproducibility:
- Verify:
Build Before Deploy¶
Always build before deploying:
# Explicit build
run v2 build --release
run v2 deploy --target edge
# Or use --build flag
run v2 deploy --target edge --build
Component Selection¶
Deploy specific components:
Deployment Manifest¶
The deploy.json manifest includes:
{
"project": "my-app",
"version": "1.0.0",
"target": "local",
"created_at": 1704067200,
"components": [
{
"name": "api",
"path": "api.wasm",
"sha256": "abc123...",
"size": 524288,
"language": "rust"
}
]
}
Use this for:
- Deployment verification
- Rollback tracking
- Audit logging