From f6ccadbcd3fd56debff37a109c80658f2f5a5f70 Mon Sep 17 00:00:00 2001 From: yoge Date: Fri, 27 Mar 2026 10:04:41 +0800 Subject: [PATCH] refactor: move deploy scripts into .claude/skills/deploy/ - Added deploy skill (SKILL.md) with dev/prod instructions - Moved deploy_prod.sh, deploy_dev.sh, dev_deploy.sh, speed_take.sh - Updated settings.local.json: new script paths, git merge/push permissions, auto-deploy hook on merge to master - Removed dev_deploy.sh and speed_take.sh from .gitignore Co-Authored-By: Claude Sonnet 4.6 --- .claude/skills/deploy/SKILL.md | 40 +++++++++++++++++++ .../skills/deploy/deploy_dev.sh | 0 .../skills/deploy/deploy_prod.sh | 0 .claude/skills/deploy/dev_deploy.sh | 3 ++ .claude/skills/deploy/speed_take.sh | 7 ++++ .gitignore | 2 - 6 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 .claude/skills/deploy/SKILL.md rename deploy_dev.sh => .claude/skills/deploy/deploy_dev.sh (100%) rename deploy_prod.sh => .claude/skills/deploy/deploy_prod.sh (100%) create mode 100755 .claude/skills/deploy/dev_deploy.sh create mode 100644 .claude/skills/deploy/speed_take.sh diff --git a/.claude/skills/deploy/SKILL.md b/.claude/skills/deploy/SKILL.md new file mode 100644 index 0000000..f5b08bc --- /dev/null +++ b/.claude/skills/deploy/SKILL.md @@ -0,0 +1,40 @@ +--- +name: deploy +description: Use when deploying this project to dev or prod environments, or when asked to run, ship, release, or push to a server. +--- + +# Deploy + +## Environments + +### Dev (`/deploy dev`) +```bash +bash .claude/skills/deploy/deploy_dev.sh +``` +Builds and restarts the service on the dev server (ubuntu). + +### Prod (`/deploy prod`) +Prod deploy requires being on `master`. Steps: +1. Ensure all changes are committed and pushed to `master` +2. Run: +```bash +bash .claude/skills/deploy/deploy_prod.sh +``` + +`deploy_prod.sh` will: +- Pull latest code on ubuntu build host +- Build `linux/amd64` Docker image and push to registry +- SSH into ECS: stop old container, start new one with `-env=prod` + +## Quick Reference + +| Target | Command | Branch required | +|--------|---------|-----------------| +| Dev | `bash .claude/skills/deploy/deploy_dev.sh` | any | +| Prod | `bash .claude/skills/deploy/deploy_prod.sh` | `master` or `main` | + +## Common Mistakes + +- Running `deploy_prod.sh` on a feature branch → script guards against this (exits with error) +- Forgetting to merge/push before deploy → ubuntu build host pulls from remote, so local-only commits won't be included +- Prod logs go to `/app/logs/app.log` inside the container, not stdout — use `docker exec doc_ai tail -f /app/logs/app.log` on ECS to tail them diff --git a/deploy_dev.sh b/.claude/skills/deploy/deploy_dev.sh similarity index 100% rename from deploy_dev.sh rename to .claude/skills/deploy/deploy_dev.sh diff --git a/deploy_prod.sh b/.claude/skills/deploy/deploy_prod.sh similarity index 100% rename from deploy_prod.sh rename to .claude/skills/deploy/deploy_prod.sh diff --git a/.claude/skills/deploy/dev_deploy.sh b/.claude/skills/deploy/dev_deploy.sh new file mode 100755 index 0000000..3a72d3a --- /dev/null +++ b/.claude/skills/deploy/dev_deploy.sh @@ -0,0 +1,3 @@ +docker-compose down +docker image rm doc_ai_backed-doc_ai +docker-compose up -d \ No newline at end of file diff --git a/.claude/skills/deploy/speed_take.sh b/.claude/skills/deploy/speed_take.sh new file mode 100644 index 0000000..6c08f93 --- /dev/null +++ b/.claude/skills/deploy/speed_take.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +echo "=== Testing 401 Request Speed ===" +curl -X POST "https://api.mathpix.com/v3/text" \ + -H "Content-Type: application/json" \ + --data '{}' \ + -w "\n\n=== Timing ===\nHTTP Status: %{http_code}\nTotal: %{time_total}s\nConnect: %{time_connect}s\nDNS: %{time_namelookup}s\nTTFB: %{time_starttransfer}s\n" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4942ebc..a1c3b6a 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,3 @@ texpixel doc_ai document_ai -dev_deploy.sh -speed_take.sh