deltabase deploy
Deploy infrastructure from configuration file
Deploy event stores and subscriptions from a deltabase.config.ts file.
deltabase deploy [options]Or without global installation:
pnpx @delta-base/cli deploy [options]Options
Section titled “Options”| Option | Description | Default |
|---|---|---|
--config <path> | Path to config file | deltabase.config.ts |
--api-key <key> | DeltaBase API key | $DELTABASE_API_KEY |
--api-url <url> | API URL | https://api.delta-base.com |
--dry-run | Preview changes without applying | false |
--verbose | Show detailed output | false |
Examples
Section titled “Examples”Basic Deployment
Section titled “Basic Deployment”pnpx @delta-base/cli deploy --api-key your-api-keyWith Environment Variable
Section titled “With Environment Variable”export DELTABASE_API_KEY=your-api-keypnpx @delta-base/cli deployCustom Config File
Section titled “Custom Config File”pnpx @delta-base/cli deploy --config ./config/production.tsDry Run (Preview)
Section titled “Dry Run (Preview)”pnpx @delta-base/cli deploy --dry-run --api-key your-api-keyVerbose Output
Section titled “Verbose Output”pnpx @delta-base/cli deploy --verbose --api-key your-api-keyConfiguration File
Section titled “Configuration File”The deploy command reads from deltabase.config.ts:
import type { InfrastructureConfig as DeltaBaseConfig } from '@delta-base/server';
const config: DeltaBaseConfig = { eventStores: [ { name: 'my-service-events', description: 'Events for my service', settings: { retentionPeriodDays: 365, maxStreamSizeBytes: 1073741824, // 1GB }, subscriptions: [ { id: 'users-projection', eventFilter: ['user.created', 'user.updated', 'user.deleted'], subscriberType: 'webhook', webhook: { url: process.env.WEBHOOK_URL || 'https://my-app.com/webhooks', headers: { Authorization: `Bearer ${process.env.WEBHOOK_TOKEN}`, }, retryPolicy: { maxAttempts: 5, backoffMinutes: 2, }, }, }, ], }, ],};
export default config;Reconciliation
Section titled “Reconciliation”The deploy command performs reconciliation - comparing your config to the current state and making only necessary changes.
Event Stores
Section titled “Event Stores”| Scenario | Action |
|---|---|
| In config, doesn’t exist | Create |
| In config, exists with different settings | Update |
| In config, matches current state | No change |
Subscriptions
Section titled “Subscriptions”| Scenario | Action |
|---|---|
| In config, doesn’t exist | Create |
| In config, exists with different settings | Update |
| Exists but not in config | Delete |
| In config, matches current state | No change |
Warning: Subscriptions not in your config file will be deleted. This ensures your config is the single source of truth.
Output
Section titled “Output”Successful Deployment
Section titled “Successful Deployment”Deploying DeltaBase infrastructure...
Event Stores: ✓ my-service-events (created)
Subscriptions: ✓ users-projection (created)
Deployment complete!Dry Run Output
Section titled “Dry Run Output”DRY RUN - No changes will be applied
Event Stores: + my-service-events (would create)
Subscriptions: + users-projection (would create)
Run without --dry-run to apply changes.Authentication
Section titled “Authentication”API Key Methods
Section titled “API Key Methods”1. Command line flag:
pnpx @delta-base/cli deploy --api-key your-api-key2. Environment variable:
export DELTABASE_API_KEY=your-api-keypnpx @delta-base/cli deploy3. .env file:
DELTABASE_API_KEY=your-api-keysource .env && pnpx @delta-base/cli deployCI/CD Integration
Section titled “CI/CD Integration”GitHub Actions
Section titled “GitHub Actions”name: Deploy Infrastructure
on: push: branches: [main] paths: - 'deltabase.config.ts'
jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4
- uses: actions/setup-node@v4 with: node-version: '20'
- name: Deploy DeltaBase run: pnpx @delta-base/cli deploy env: DELTABASE_API_KEY: ${{ secrets.DELTABASE_API_KEY }} WEBHOOK_URL: ${{ vars.WEBHOOK_URL }} WEBHOOK_TOKEN: ${{ secrets.WEBHOOK_TOKEN }}GitLab CI
Section titled “GitLab CI”deploy: stage: deploy image: node:20 script: - npx @delta-base/cli deploy only: - main variables: DELTABASE_API_KEY: $DELTABASE_API_KEYError Handling
Section titled “Error Handling”Common Errors
Section titled “Common Errors”“Configuration not found”
Error: Could not find deltabase.config.tsEnsure the file exists or use --config to specify the path.
“Authentication failed”
Error: Invalid API keyCheck your API key is correct and has the necessary permissions.
“Validation error”
Error: Event store name must be 3-63 charactersFix the validation error in your config file.
Exit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
0 | Success |
1 | Error |
Best Practices
Section titled “Best Practices”1. Use Dry Run First
Section titled “1. Use Dry Run First”Always preview changes before applying:
pnpx @delta-base/cli deploy --dry-run2. Version Control Your Config
Section titled “2. Version Control Your Config”Treat deltabase.config.ts like any infrastructure code:
git add deltabase.config.tsgit commit -m "Add users projection subscription"3. Use Environment Variables for Secrets
Section titled “3. Use Environment Variables for Secrets”// Goodheaders: { Authorization: `Bearer ${process.env.WEBHOOK_TOKEN}`,}
// Bad - never commit secretsheaders: { Authorization: 'Bearer actual-secret-token',}4. Separate Configs per Environment
Section titled “4. Separate Configs per Environment”# Developmentpnpx @delta-base/cli deploy --config config/development.ts
# Productionpnpx @delta-base/cli deploy --config config/production.tsWhat’s Next?
Section titled “What’s Next?”- Infrastructure as Code Guide - Detailed configuration guide
- Deploy to Production - Full deployment walkthrough
- dev command - Local development