# استقرار Montech — `montech.ir` > پکیج‌منیجر = **npm**. به پروسه‌های CRM دست نزنید. ## آپدیت سریع (بعد از `git push`) ```bash ssh -p 3031 montime@185.50.38.53 cd /var/www/montech git pull npm run build -w @montech/shared cd apps/api && npx prisma migrate deploy && npx prisma generate && cd ../.. npm run build -w @montech/api npm run build -w @montech/adm npm run build -w @montech/landing pm2 restart montech-api montech-landing ``` --- هاست مشترک مونتایم: `185.50.38.53` (SSH پورت `3031`، کاربر `montime`) دامنه: `https://montech.ir` مسیر کد: `/var/www/montech` پورت داخلی API: `3050` پورت داخلی Nuxt SSR: `3051` PM2: `montech-api`, `montech-landing` کد از Gitea: `http://get.feep.ir/Mahdi/Montech_Landing.git` پورت‌های اشغال‌شده (دست نزنید): ۳۰۰۰ مونتایم · ۳۰۰۱ فوری‌سند · ۳۰۱۰ سوپرادمین · ۳۰۲۰ کاتالوگ · ۳۰۳۰ CRM · ۳۰۴۰ STT --- ## کارهایی که باید انجام شود 1. **DNS:** رکورد `A` برای `montech.ir` روی همان IP سرور. 2. **Postgres:** دیتابیس و کاربر جدا (`montech`) روی `127.0.0.1:15432`. 3. **دسترسی Gitea** برای clone/pull. --- ## روی سرور ```bash ssh -p 3031 montime@185.50.38.53 ``` ### ۱) کلون ```bash sudo mkdir -p /var/www/montech sudo chown montime:montime /var/www/montech git clone http://get.feep.ir/Mahdi/Montech_Landing.git /var/www/montech ``` ### ۲) پورت آزاد ```bash ss -tlnp | grep -E '3050|3051' || true ``` ### ۳) `.env` API ```bash cd /var/www/montech cp deploy/.env.production.example apps/api/.env nano apps/api/.env ``` ### ۴) نصب وابستگی‌ها ```bash cd /var/www/montech npm ci # اگر symlink workspace خراب بود: # rm -rf node_modules/@montech/shared && ln -s ../../packages/shared node_modules/@montech/shared ``` ### ۵) migrate و بیلد ```bash cd /var/www/montech npm run build -w @montech/shared cd apps/api npx prisma migrate deploy npx prisma generate npx prisma db seed cd ../.. npm run build -w @montech/api npm run build -w @montech/adm npm run build -w @montech/landing mkdir -p uploads ``` ### ۶) PM2 ```bash pm2 start /var/www/montech/deploy/ecosystem.config.cjs pm2 save curl -sI http://127.0.0.1:3050/api/health curl -sI http://127.0.0.1:3051/ ``` ### ۷) Nginx ```bash sudo mkdir -p /etc/nginx/snippets /var/www/certbot sudo cp /var/www/montech/deploy/nginx-montech-locations.conf /etc/nginx/snippets/montech-locations.conf # First time (before cert exists): use HTTP-only — see step 7b sudo cp /var/www/montech/deploy/nginx-montech.ir.conf /etc/nginx/sites-available/montech.ir sudo ln -sf /etc/nginx/sites-available/montech.ir /etc/nginx/sites-enabled/ sudo nginx -t && sudo systemctl reload nginx ``` ### ۷b) SSL مستقیم روی سرور (certbot + :443) **نکته WCDN:** اگر DNS دامنه روی CDN است، Let's Encrypt ممکن است به origin نرسد. یکی از این‌ها: - موقتاً رکورد A را مستقیم روی `185.50.38.53` بگذار، گواهی بگیر، بعد دوباره CDN را وصل کن و Origin را HTTPS کن؛ یا - مطمئن شو WCDN درخواست‌های `/.well-known/acme-challenge/` را به origin روی HTTP:80 پاس می‌دهد. ```bash # 1) پکیج‌ها sudo apt update sudo apt install -y certbot python3-certbot-nginx # 2) تا قبل از وجود گواهی، بلاک :443 را موقتاً از سایت بردار # (یا فقط server :80 را نگه دار) و nginx را reload کن sudo nano /etc/nginx/sites-available/montech.ir # کل بلوک server { listen 443 ... } را کامنت کن sudo nginx -t && sudo systemctl reload nginx # 3) گرفتن گواهی (وب‌روت — با مسیر ACME در snippet) sudo mkdir -p /var/www/certbot sudo certbot certonly --webroot -w /var/www/certbot \ -d montech.ir -d www.montech.ir \ --email admin@montech.ir --agree-tos --no-eff-email # یا با پلاگین nginx (اگر بلاک 443 کامنت است و :80 فعال): # sudo certbot --nginx -d montech.ir -d www.montech.ir # 4) فعال کردن :443 sudo cp /var/www/montech/deploy/nginx-montech-locations.conf /etc/nginx/snippets/montech-locations.conf sudo cp /var/www/montech/deploy/nginx-montech.ir.conf /etc/nginx/sites-available/montech.ir sudo nginx -t && sudo systemctl reload nginx # 5) تست لوکال curl -skI https://127.0.0.1/ -H 'Host: montech.ir' ss -tlnp | grep ':443' # 6) تمدید خودکار sudo certbot renew --dry-run ``` بعد در پنل WCDN: - Origin protocol = **HTTPS** - Origin port = **443** - حالت SSL = **Full** (اگر گواهی معتبر Let's Encrypt داری می‌توانی Full Strict هم بزنی) - کش را Purge کن اگر فقط می‌خواهی 502 برطرف شود و SSL روی CDN کافی است، Origin را **HTTP:80** بگذار و این مرحله را لازم نداری. ### ۸) تست 1. `https://montech.ir` → لندینگ 2. `https://montech.ir/adm/` → پنل ادمین (موبایل/رمز از seed) 3. `https://montech.ir/blog` → بلاگ 4. `https://montech.ir/api/health` → `{ ok: true }` پاک نکنید: `uploads/` و `apps/api/.env` --- ## One-time release: artifact landing + Ant Design admin (2026-10) This release replaces the landing content model, adds the `Lead` table and new dependencies on all apps. Run it once instead of the quick update above. ```bash ssh -p 3031 montime@185.50.38.53 cd /var/www/montech # 1) Back up the database first (the migration deletes legacy landing sections) pg_dump -h 127.0.0.1 -p 15432 -U montech -Fc montech > ~/montech-$(date +%F).dump git pull npm ci # new deps: gsap, lenis, tailwindcss@3, ant-design-vue, … npm run build -w @montech/shared cd apps/api npx prisma migrate deploy # creates "Lead", removes marquee/manifesto/services/work/process/stats/team npx prisma generate SEED_RESET_CONTENT=1 npx prisma db seed # overwrites settings, page SEO and sections with the artifact content cd ../.. npm run build -w @montech/api npm run build -w @montech/adm npm run build -w @montech/landing pm2 restart montech-api montech-landing ``` Notes: - Without `SEED_RESET_CONTENT=1` the seed only creates missing rows and never overwrites admin edits. Use the flag only for this release. - Contact phone/email/address and socials are edited in **Admin → تنظیمات سایت** and feed the landing footer. - Consultation requests from the landing are listed in **Admin → درخواست‌های مشاوره** (`POST /api/public/leads`, rate limited to 5 per IP per 10 minutes). - The landing caches pages with stale-while-revalidate (`/` 30s, blog/gallery 120s), so admin edits appear within that window. - Verify after deploy: `curl -s https://montech.ir/robots.txt`, `curl -s https://montech.ir/sitemap.xml`, submit a test consultation and check it in the admin.