一键导入
deploying-to-databricks
Use when deploying BrickChat to Databricks Apps, updating an existing deployment, or troubleshooting deployment issues (project)
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when deploying BrickChat to Databricks Apps, updating an existing deployment, or troubleshooting deployment issues (project)
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when applying a brand theme configuration to the app. Reads theme_config.json and updates Dart theme files with new colors, gradients, logos, and animation effects.
Use when configuring app branding, theming, or visual styling. Guides through Q&A to capture logo, colors, and animation preferences, then generates theme_config.json.
| name | deploying-to-databricks |
| description | Use when deploying BrickChat to Databricks Apps, updating an existing deployment, or troubleshooting deployment issues (project) |
Before proceeding, always ask the user these questions using AskUserQuestion:
brickchat)DEFAULT, 9cefok, or other configured profile)Store responses as <APP_NAME> and <PROFILE> for use in all commands below.
All databricks commands must include --profile <PROFILE>.
BEFORE any deployment steps, check if the app exists:
databricks apps get <APP_NAME> --profile <PROFILE>
If the app does NOT exist (error: "does not exist or is deleted"):
databricks apps create <APP_NAME> --description "BrickChat - AI Chat Application" --profile <PROFILE>
If the app EXISTS: Proceed directly to deployment workflow.
Deploy BrickChat (Flutter WASM frontend + FastAPI backend) to Databricks Apps. The deployment folder contains all files needed for a self-contained deployment.
databricks auth login)digraph deployment {
rankdir=TB;
"Gather info (app name, profile)" -> "Check app exists";
"Check app exists" -> "App exists?" [shape=diamond];
"App exists?" -> "Create app" [label="no"];
"App exists?" -> "Update deployment files" [label="yes"];
"Create app" -> "Update deployment files";
"Update deployment files" -> "Upload to workspace";
"Upload to workspace" -> "Deploy from workspace";
"Deploy from workspace" -> "Verify deployment";
}
Option A: Use the update script
cd deployment
./update_deployment.sh
Option B: Manual steps
# Build Flutter WASM
flutter build web --wasm
# Copy frontend (note: deployment expects build/, not build/web/)
rm -rf deployment/build
mkdir -p deployment/build
cp -r build/web/* deployment/build/
# Copy backend files
cp backend/app.py deployment/
cp backend/database.py deployment/
cp backend/auth.py deployment/
cp backend/routers/* deployment/routers/
# Update requirements
cd backend && uv pip freeze > ../deployment/requirements.txt
IMPORTANT: After copying app.py, verify build paths match:
deployment/app.py should reference build/ (not build/web/)backend/app.py references build/web/ or ../build/web/Secrets are referenced in app.yaml using valueFrom:
| Secret Name | Purpose |
|---|---|
DATABRICKS_TOKEN | API access token |
REPLICATE_API_TOKEN | TTS via Replicate |
DEEPGRAM_API_TOKEN | Speech-to-text |
Configure in Databricks workspace settings or via CLI.
cd deployment
cp .env.example .env # Edit with your values
uv pip install -r requirements.txt
uv run uvicorn app:app --host 0.0.0.0 --port 8000
Verify at http://localhost:8000:
curl http://localhost:8000/healthIMPORTANT: The databricks apps deploy command requires a workspace path, not a local path. You must upload local files to the workspace first.
Why not databricks sync? The databricks sync command respects .gitignore, which excludes build/ folders. Using databricks workspace import-dir bypasses .gitignore and uploads all files directly.
Replace <YOUR_EMAIL> with the user's Databricks email (can be found from databricks apps get output under creator field).
# Delete old deployment from workspace to ensure clean state
databricks workspace delete /Workspace/Users/<YOUR_EMAIL>/brickchat --recursive --profile <PROFILE>
Note: This command may fail if the folder doesn't exist yet - that's fine for first deployments.
# Upload deployment folder directly (bypasses .gitignore)
databricks workspace import-dir ./deployment /Workspace/Users/<YOUR_EMAIL>/brickchat --profile <PROFILE> --overwrite
Verify upload:
databricks workspace list /Workspace/Users/<YOUR_EMAIL>/brickchat --profile <PROFILE>
You should see app.py, app.yaml, build/, routers/, etc.
# Deploy from the workspace path (NOT local path)
databricks apps deploy <APP_NAME> --source-code-path /Workspace/Users/<YOUR_EMAIL>/brickchat --profile <PROFILE>
Common mistake: Using --source-code-path ./deployment will fail with "must be a valid workspace path" error.
For subsequent updates:
# Check app status
databricks apps get <APP_NAME> --profile <PROFILE>
# View logs (if needed)
databricks apps logs <APP_NAME> --profile <PROFILE>
Success indicators:
app_status.state: RUNNINGcompute_status.state: ACTIVEactive_deployment.status.state: SUCCEEDEDurl: The app URL will be displayed| Task | Command |
|---|---|
| Check app exists | databricks apps get <APP_NAME> --profile <PROFILE> |
| Create app (once) | databricks apps create <APP_NAME> --description "BrickChat - AI Chat Application" --profile <PROFILE> |
| Update deployment | cd deployment && ./update_deployment.sh |
| Local test | cd deployment && uv run uvicorn app:app --host 0.0.0.0 --port 8000 |
| Delete from workspace | databricks workspace delete /Workspace/Users/<EMAIL>/brickchat --recursive --profile <PROFILE> |
| Upload to workspace | databricks workspace import-dir ./deployment /Workspace/Users/<EMAIL>/brickchat --profile <PROFILE> --overwrite |
| Verify upload | databricks workspace list /Workspace/Users/<EMAIL>/brickchat --profile <PROFILE> |
| Deploy | databricks apps deploy <APP_NAME> --source-code-path /Workspace/Users/<EMAIL>/brickchat --profile <PROFILE> |
| Check status | databricks apps get <APP_NAME> --profile <PROFILE> |
| View logs | databricks apps logs <APP_NAME> --profile <PROFILE> |
| Health check | curl http://localhost:8000/health |
This happens when using a local path with databricks apps deploy. Solution:
databricks workspace import-dir ./deployment /Workspace/Users/<EMAIL>/brickchat --profile <PROFILE> --overwritedatabricks apps deploy <APP_NAME> --source-code-path /Workspace/Users/<EMAIL>/brickchat --profile <PROFILE>If using databricks sync, the build/ folder is skipped because it's in .gitignore. Solution: Use databricks workspace import-dir instead, which ignores .gitignore and uploads all files directly.
Create the app first:
databricks apps create <APP_NAME> --description "BrickChat - AI Chat Application" --profile <PROFILE>
Wait for creation to complete before deploying.
databricks apps logs <APP_NAME> --profile <PROFILE>deployment/build/ contains Flutter WASM files (including index.html)index.html exists in build directoryflutter build web --wasmWhen copying app.py from backend/ to deployment/, the build paths may differ:
| Location | Expected build path |
|---|---|
backend/app.py | build/web/ or ../build/web/ |
deployment/app.py | build/ (no web/ subfolder) |
After copying backend files, verify deployment/app.py uses correct paths:
# Deployment should check for build/ not build/web/
if os.path.exists("build/index.html"): # Correct for deployment
Use /debug/info endpoint to diagnose:
curl http://localhost:8000/debug/info
This shows which paths exist and helps identify mismatches.
DATABRICKS_TOKEN and DATABRICKS_BASE_URL are correct| File | Purpose |
|---|---|
app.yaml | Databricks Apps configuration |
app.py | FastAPI entry point (uses build/ path) |
requirements.txt | Python dependencies |
build/ | Flutter WASM frontend (deployment) |
.env.example | Environment template |