CI/CD ও ডিপ্লয়মেন্ট
build once/deploy many, canary/blue-green, migrations আর rollback।
Start with the production incident, then the design decision that fixes it.
শুক্রবার সন্ধ্যায় চলো-র deploy গেল, ১০ মিনিট পরে 5xx ৪০%। নুসরাত rollback করতে গিয়ে দেখল, image tag latest, পুরোনো image আর নেই; database migration already applied; আর config change আলাদা করে কোথাও লেখা নেই। দুই ঘণ্টা outage।
মাহিন বলল, "deploy মানে শুধু নতুন code নয়—image, migration, config, feature flag আর rollback plan একসাথে।" CI/CD-র লক্ষ্য দ্রুত deploy নয়; নিরাপদে, বারবার, একই ফলাফলে deploy। Build once, deploy many; একই immutable artifact staging আর production-এ যাবে।
CI (Continuous Integration)। প্রতিটা commit-এ lint, typecheck, unit/contract test, build, image bake; fast feedback (≤১০ মিনিট)। Red build merge block।
CD (Continuous Delivery/Deployment)। Delivery মানে artifact ready, deploy manual approval; Deployment মানে স্বয়ংক্রিয়। Production-এ canary/blue-green/rolling—risk অনুযায়ী।
Build once। Image digest/tag commit SHA; staging-এ test করা same digest production-এ। latest নয়; rollback-এর জন্য পুরোনো tag রাখো।
Blue-green। পুরোনো stack (blue) চালু, নতুন (green) পুরো stack up; smoke pass হলে traffic switch; fail হলে switch back। DB migration backward-compatible হতে হবে।
Canary। ১–৫% traffic নতুন version-এ; SLO/error/latency দেখে ধীরে বাড়াও; fail হলে auto rollback। Feature flag দিয়ে code deploy আর feature enable আলাদা করো।
Migrations। Expand → migrate → contract: নতুন column nullable যোগ, dual-write/backfill, পরে পুরোনো সরাও। এক deploy-এ destructive drop নয়; rollback compatibility রাখো।
Secrets/config। Environment-specific, vault/CI secret; image-এ নয়। Config change-ও versioned/audited।
| ধাপ | কী | Gate |
|---|---|---|
| CI | lint, type, test, build, image | red block |
| Staging deploy | same digest | smoke/E2E |
| Production | canary/blue-green | SLO, error |
| Post-deploy | health, smoke, trace | rollback ready |
| Rollback | previous digest/config | one command |
GitHub Actions-ধাঁচের minimal pipeline:
name: deploy
on:
push:
branches: [main]
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pnpm install --frozen-lockfile
- run: pnpm lint && pnpm typecheck && pnpm test
- run: docker build -t app:${{ github.sha }} .
- run: docker push app:${{ github.sha }}
deploy:
needs: verify
steps:
- run: ./deploy.sh --image app:${{ github.sha }} --canary 5
- run: ./smoke.sh
- run: ./promote.sh --to 100
# rollback is a first-class command, not a guess
./deploy.sh --image app:$PREVIOUS_SHA --rollback
Image tag commit SHA; latest নেই। Canary ৫% → smoke → ৫০% → ১০০%; প্রতিটা ধাপে error/latency gate।
১. Pipeline দ্রুত করো। Lint/type/unit/contract/build ≤১০ মিনিট; integration/E2E আলাদা job। Cache dependency।
২. Immutable artifact। Commit SHA tag, SBOM, signed image; staging same digest।
৩. Migration expand/contract। নতুন column nullable, backfill, dual-read, পরে drop। Rollback-compatible।
৪. Deploy strategy। Low-risk canary, database-heavy blue-green, stateless rolling; health check + smoke।
৫. Rollback drill। Previous image/config one command; rollback staging-এ মাসে একবার practice। Feature flag kill switch।
latest image tag। কোন commit চলছে বোঝা যায় না, rollback-ও অনুমান; SHA tag ব্যবহার করো।একটা deploy-এ নতুন column যোগ করলে আর code বদলালে—কোন ক্রমে deploy করবে? যদি ৫ মিনিট পরে rollback লাগে, DB column/backfill কী হবে? কাগজে expand → deploy → backfill → contract ক্রম লেখো, আর প্রতিটা ধাপে rollback action।
Deploy আর migration একসাথে করলে rollback জটিল; backward-compatible migration আগে, code পরে। Healthcheck শুধু process নয়, DB/Redis/queue dependency দেখুক। Deploy log-এ commit, image digest, migration version, operator—সব থাকুক; incident review-তে এটাই timeline।
See the mental model first — the animation and the steps below it say the same thing.
Concept visual
একই immutable image সব পরিবেশে যায়, তাই staging-এ যা চলেছে প্রোডে-ও সেটাই চলে।
Write a short design on paper or in a note, then compare it with the rubric. This is not a judge submission.
Design practice
image `latest`, migration applied, rollback নেই।
One timed attempt. Solve every problem to earn the module badge.
Final checkpoint
Ready to prove this module?
Ask questions, share an approach or leave a study tip for this lesson.
Was this lesson helpful?
Your reaction helps other learners judge these notes.
0 comments
Sign in to ask a question or share an approach.
Sign in to commentNo comments yet
Be the first to ask a question or leave a study tip.
| প্রশ্ন | উত্তর |
|---|
| Image tag? | commit SHA |
| Build? | once, same digest |
| DB? | expand/contract |
| Deploy? | canary/blue-green |
| Rollback? | previous digest/config |
| Feature? | flag separate |