# aerostack deploy

> Deploy Aerostack projects to managed cloud or your own Cloudflare account. Supports staging and production with environment variable injection.

Deploy your project. Supports two modes: deploy to Aerostack's managed cloud, or deploy directly to your own Cloudflare account.

## Usage

```bash
aerostack deploy [service-name] [flags]
```

## Flags

| Flag | Default | Description |
|------|---------|-------------|
| `-e, --env` | `staging` | Target environment: `staging` or `production` |
| `--all` | false | Deploy all services in the project |
| `--cloudflare` | false | Deploy to your Cloudflare account instead of Aerostack |
| `--public` | false | Make the service publicly accessible (no auth required) |
| `--private` | false | Require authentication for all requests |
| `--sync-secrets` | false | Push `.dev.vars` secrets to the target environment before deploying |

## Deploy to Aerostack (default)

Aerostack hosts and manages your Worker on your behalf. Requires `aerostack login`.

```bash
# Deploy to staging
aerostack deploy

# Deploy to production
aerostack deploy --env production

# Deploy all services
aerostack deploy --all --env production

# Sync secrets from .dev.vars, then deploy
aerostack deploy --sync-secrets --env production
```

After deploy, the CLI prints your service URL and test instructions.

## Deploy to your Cloudflare account

Use `--cloudflare` to deploy directly to your own Cloudflare account via Wrangler. Requires `CLOUDFLARE_API_TOKEN` in your environment or `npx wrangler login`.

```bash
# Deploy to Cloudflare (staging)
aerostack deploy --cloudflare

# Deploy to Cloudflare production
aerostack deploy --cloudflare --env production
```

When using `--cloudflare`, Cloudflare resources (D1, KV, R2, Queues) must be created first. Run `aerostack resources create` or let the deploy command create them automatically.

## Deploy an MCP server

```bash
aerostack deploy mcp [file] [flags]
```

| Flag | Default | Description |
|------|---------|-------------|
| `-e, --env` | `production` | Target environment |
| `--slug` | (directory name) | Unique slug for the MCP server |

```bash
# Deploy bundled MCP server (default: dist/index.js)
aerostack deploy mcp

# Deploy with explicit slug
aerostack deploy mcp dist/index.js --slug my-notion-mcp
```

## Visibility flags

```bash
# Make a service fully public (no API key required)
aerostack deploy --public

# Require authentication (default behavior)
aerostack deploy --private
```

## Full production workflow

```bash
# 1. Deploy to staging first
aerostack deploy --env staging

# 2. Test staging
curl https://your-staging-url.aerostack.dev/api/health

# 3. Deploy to production with secrets sync
aerostack deploy --env production --sync-secrets
```
