implement gitlab blue-green ci cd

This commit is contained in:
Meghdad committed 2026-07-23 08:17:56 +03:30
1 parent a353b80a15
commit 0f2dee08cb
13 files changed
+686 -230

No files matched your search

+11 -4
View File
@@ -182,14 +182,21 @@ make benchmark
## CI/CD و استقرار
GitHub Actions این مراحل را اجرا می‌کند:
GitLab CI روی مخزن اصلی `git.sharifict.com` این مراحل را اجرا می‌کند:
1. نصب وابستگی‌ها از `pyproject.toml`؛
2. Ruff lint/format، mypy strict؛
3. unit و integration test با حداقل coverage برابر ۸۵٪؛
3. unit، integration و Redis واقعی با حداقل coverage برابر ۸۵٪؛
4. تولید `coverage.xml` و artifact؛
5. build ایمیج Docker؛
6. اجرای اختیاری SonarQube با `SONAR_TOKEN` و `SONAR_HOST_URL`.
5. اعتبارسنجی build ایمیج بدون دسترسی privileged؛
6. اجرای اختیاری و blocking بودن quality gate سونار در صورت تنظیم متغیرها؛
7. ساخت artifact نسخه‌دار و کنترل checksum؛
8. استقرار خودکار blue-green روی production پس از موفقیت شاخه محافظت‌شده
`main`.
در استقرار blue-green، نسخه جدید ابتدا روی slot غیرفعال سالم‌سازی می‌شود، سپس
Nginx به‌صورت graceful به آن سوییچ می‌کند. slot قبلی تا پایان health check و
smoke test عمومی روشن می‌ماند و در صورت خطا rollback خودکار انجام می‌شود.
فایل `deploy/kubernetes.yaml` شامل Deployment غیر-root و read-only، probes، resource limits، Service و HPA از ۲ تا ۲۰ replica است. قبل از اعمال، آدرس image و Secret را برای محیط مقصد تنظیم کنید.