Restore git-pull-only deploy: single compose path with schema from git
Deploy is back to the flow that worked: build dist locally, push, then on the server only `git pull` + `docker compose up -d --build`. The Dockerfile now also takes prisma/ and package.json from git and runs `prisma generate`, so schema and migration changes ship without rebuilding the 120MB node_modules bundle. Removes the prebuilt compose path, which could never work on a server without npm. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -25,30 +25,43 @@ npm run prisma:seed
|
||||
npm run start:dev
|
||||
```
|
||||
|
||||
## دیپلوی با Docker Compose (پیشنهادی برای سرور)
|
||||
## دیپلوی: بیلد روی سیستم خودت، اجرا روی سرور
|
||||
|
||||
روی سرور داخل `fabric_trade_server`:
|
||||
روی سرور هیچ `npm` یا دانلودی لازم نیست. `node_modules` از قبل داخل
|
||||
`deploy-bundle.tar.gz` (روی گیت) است و `dist` هم روی گیت commit میشود.
|
||||
|
||||
**۱) روی سیستم خودت:**
|
||||
|
||||
```bash
|
||||
# اولین بار با دیتای فیک:
|
||||
RUN_SEED=true docker compose up -d --build
|
||||
cd fabric_trade_server
|
||||
npm run build
|
||||
git add dist && git commit -m "..." && git push
|
||||
```
|
||||
|
||||
# بعداً بدون seed:
|
||||
**۲) روی سرور:**
|
||||
|
||||
```bash
|
||||
cd /opt/parche/server
|
||||
git pull
|
||||
docker compose up -d --build
|
||||
docker compose logs -f api
|
||||
```
|
||||
|
||||
اگر بیلد بهخاطر رجیستری npm یا Alpine خطا داد (رایج روی سرورهای ایران):
|
||||
`Dockerfile` باندل را باز میکند، بعد `dist` و `prisma` و `package.json` را از
|
||||
گیت روی آن مینویسد و `prisma generate` میزند؛ پس تغییر schema و مایگریشن
|
||||
جدید هم فقط با `git pull` میرسد.
|
||||
|
||||
**فقط اگر پکیج npm جدید اضافه شد** باندل را دوباره بساز و push کن:
|
||||
|
||||
```bash
|
||||
# پیشفرض Dockerfile از میرور npmmirror استفاده میکند.
|
||||
# در صورت نیاز:
|
||||
docker compose build --build-arg NPM_REGISTRY=https://registry.npmmirror.com
|
||||
RUN_SEED=true docker compose up -d
|
||||
bash scripts/pack-bundle.sh
|
||||
git add deploy-bundle.tar.gz && git commit -m "refresh deploy bundle" && git push
|
||||
```
|
||||
|
||||
- API روی `127.0.0.1:3000` بالا میآید
|
||||
- `env` سرور از `.env` همان پوشه خوانده میشود (`env_file` در compose)
|
||||
- API روی `127.0.0.1:${API_PORT}` بالا میآید (سرور: `8585`)
|
||||
- مایگریشن موقع استارت کانتینر اجرا میشود
|
||||
- LiteSpeed را Reverse Proxy کنید به `http://127.0.0.1:3000`
|
||||
- LiteSpeed را Reverse Proxy کنید به `http://127.0.0.1:8585`
|
||||
|
||||
مثال مسیر LiteSpeed: `https://domain.com/api/` → `http://127.0.0.1:3000/api/`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user