# Manual deploy & CLI

URL: https://skali.dppst.com/docs/manual-deploy/

> Deploy Skali manually with Wrangler, run it locally for development, or script batch publishing with the pure-Rust skali CLI.

While most users deploy and update Skali in one click from the desktop app, Skali is also first-class for developers, sysadmins, and CI/CD pipelines.

## Using the `skali` CLI

The pure-Rust `skali` CLI ships alongside the desktop app (named `skali` on Linux/macOS and `skali-cli.exe` on Windows):

```bash
# Check or install FFmpeg
skali ffmpeg status

# Manage instances
skali instance add my-site https://video.example.com --api-key skl_...

# Encode locally and publish a video
skali publish ./holiday-4k.mp4 --preset auto

# Check for updates, deploy, update, or roll back via Cloudflare API
skali check-updates
skali deploy
skali update
skali rollback
```

Run `skali --help` (or `skali <subcommand> --help`) to view all available flags.

## Manual deployment with Wrangler

If you prefer managing Cloudflare resources through `wrangler` and your own repository:

```bash
git clone https://github.com/toorop/skali.git
cd skali/apps/web
npm install
```

1. **Create D1 database &amp; R2 bucket**:
   ```bash
   npx wrangler d1 create skali-db
   npx wrangler r2 bucket create skali-media
   ```
2. **Create a private production config** (never commit personal emails, domains, or UUIDs into the tracked `wrangler.jsonc`):
   ```bash
   cp wrangler.jsonc wrangler.prod.jsonc
   ```
   Fill in your `database_id`, `APP_URL`, `SITE_NAME`, `EMAIL_FROM`, `ADMIN_EMAIL`, and custom domain route in `wrangler.prod.jsonc` (which is gitignored).
3. **Optional: enable Cloudflare Email Service** on your sending domain:
   ```bash
   npx wrangler email sending enable yourdomain.com
   ```
4. **Set Worker secrets**:
   ```bash
   npx wrangler secret put PLAYBACK_HMAC_SECRET --config wrangler.prod.jsonc
   npx wrangler secret put R2_ACCOUNT_ID --config wrangler.prod.jsonc
   npx wrangler secret put R2_ACCESS_KEY_ID --config wrangler.prod.jsonc
   npx wrangler secret put R2_SECRET_ACCESS_KEY --config wrangler.prod.jsonc
   ```
5. **Apply migrations and deploy**:
   ```bash
   npx wrangler d1 migrations apply skali-db --remote --config wrangler.prod.jsonc
   npm run build
   npx wrangler deploy --config wrangler.prod.jsonc
   ```
6. Visit `https://your-domain/login`, sign in with your `ADMIN_EMAIL` Magic Link, and create an API key in `/admin` for the Skali desktop/CLI app.

## Local development

### Web (`apps/web`)
```bash
cd apps/web
npm install
cp .dev.vars.example .dev.vars
npm run db:migrate:local
npm run dev
```
Open `http://localhost:5173`. During local dev, Magic Link URLs are printed directly in your terminal.

Run verification checks:
```bash
npm run typecheck
npm test
npm run build
```

### Desktop & CLI (`apps/desktop`)
```bash
cd apps/desktop
cargo test --workspace
cargo clippy --workspace --all-targets -- -D warnings
cargo run -p skali-desktop
```
