Files
backend/.cursor/rules/git-deploy.mdc
T
Alireza HassaniandCursor c76c3967bb Point backend deploy docs at gitea.meshkee.com.
Production now pulls meshkee-app/backend over SSH port 2222 instead of the old git.meshkee.com remote.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-14 11:20:48 +03:30

51 lines
1.7 KiB
Plaintext

---
description: Backend production deploy must use git push then git pull on the API VM — never rsync/scp as the primary deploy path.
alwaysApply: true
---
# Backend deploy (git only)
When deploying the Meshkee CMS API to production (`api.meshkee.com` / VM `/opt/meshkee/app`):
1. **Commit** the changes (only when the user asked to commit/deploy).
2. **Push** to `origin` (`https://gitea.meshkee.com/meshkee-app/backend.git`, usually `main`).
3. **On the API VM**, update from git and rebuild — do **not** rsync/scp the app tree as the normal deploy path.
```bash
ssh -i ~/.ssh/id_ed25519 root@185.164.72.119 'bash -s' <<'REMOTE'
set -euo pipefail
cd /opt/meshkee/app
git fetch origin
git reset --hard origin/main
./database/migrate.sh
npm ci
npm run prisma:generate
npm run build
pm2 restart meshkee-api
REMOTE
```
## Hard rules
- Never use `rsync`/`scp` of the full project as the default deploy once the VM has a working git remote.
- Preserve the server `.env` (never overwrite it from the laptop).
- Exclude: do not commit `.env`, secrets, `node_modules`, or `dist`.
- If `git pull` fails (missing deploy key / auth), fix git access on the VM — do not silently fall back to rsync unless the user explicitly allows an emergency sync.
## VM git access
Deploy key (read-only) on `gitea.meshkee.com` for repo `meshkee-app/backend`, installed as `/root/.ssh/id_ed25519` on the API VM.
Gitea SSH listens on **port 2222** (not 22). The API VM must have `/root/.ssh/config`:
```
Host gitea.meshkee.com
HostName gitea.meshkee.com
User git
Port 2222
IdentityFile /root/.ssh/id_ed25519
IdentitiesOnly yes
```
Remote URL: `git@gitea.meshkee.com:meshkee-app/backend.git` (port comes from SSH config).