Docker Volumes: الـ data بتتحفَظ فين

جارٍ التحميل…

01 / ملخص الدرس

Docker Volumes: الـ data بتتحفَظ فين

الـ orders راحت بعد docker compose down، و redis بيبدأ فاضي كل مرة، والـ bind mount غطّى node_modules، والـ container بيعدّل الـ config على الـ host، والـ docker socket متركّب جُوّه. بنفهم الـ writable layer، و named و anonymous volumes، و bind mounts، و tmpfs، والـ copy-up، والـ permissions، و down -v، والـ backup الصح. والتحدي: volumes.js بيمثّل قواعد Docker و lint قصاد أربعتاشر حالة.

02 / شرح الدرس مكتوبًا

نص شرح المعلم والكود الذي كتبه ونتيجة تشغيله، بنفس ترتيب الدرس.

أهلًا بيك. الدرس اللي فات الـ stack بقى يقوم بأمر واحد. دلوقتي جرّب الحكاية دي: docker compose up، تعمل orders، تعمل docker compose down علشان تعمل update للـ image، وتعمل up تاني. الـ database فاضية. ليه؟ لأن الـ container ليه writable layer صغير فوق الـ image. أي file بيتكتب من غير volume بيروح هناك. و restart بيسيبه، أما down بيمسح الـ container، ومعاه الـ layer ده بكل اللي فيه. بص على compose dot naive dot yaml. المشاكل: db: مفيش volumes خالص. الـ data في الـ writable layer، وأول down بيمسحها. redis: فيه volume، بس من غير اسم. ده anonymous volume. compose بيعمله جديد كل مرة الـ container يتعمل من الأول، فبعد down و up بيبدأ فاضي، والقديم بيتمسح أو بيفضل مرمي على الـ disk. api: bind mount للـ project كله على slash app. ده كويس في الـ development، بس بيغطّي الـ node_modules اللي اتعملت جُوّه الـ image. فـ express مش موجود، أو أسوأ: بياخد node_modules بتاعة الـ laptop، وفيها native modules متعملة لـ macOS مش Linux. nginx dot conf متركّب read write، فالـ container يقدر يعدّل files على الـ host. والـ docker socket متركّب جُوّه. اللي يتحكم في الـ socket ده يقدر يشغّل container بـ privileged ويركّب slash بتاع الـ host كله. يعني ده root على الـ server.

أنواع الـ mounts: named volume، زي pgdata على slash var slash lib slash postgresql slash data: Docker هو اللي بيدير مكانها على الـ disk، تحت slash var slash lib slash docker slash volumes. بتعيش بعد down، وبتتركّب تاني في up الجاي بنفس الاسم. ودي اللي بتستخدمها لأي data مهمة. anonymous volume: نفس الحكاية بس من غير اسم، فمفيش طريقة compose يرجعلها. مفيدة لحاجة واحدة بس هنشوفها، node_modules. bind mount: folder أو file من الـ host نفسه، زي dot slash على slash app. اللي على الـ host هو اللي الـ container بيشوفه، وأي تعديل من أي ناحية بيبان في الناحية التانية. ممتاز للـ development وللـ config، وخطر لو read write. tmpfs: في الـ RAM، بيتمسح مع أي restart. للـ temp files وللحاجات الحساسة اللي مش عايزها تتكتب على الـ disk أصلًا.

تفصيلتين مهمين: الـ copy-up: لما تركّب named volume فاضية على folder في الـ image فيه files، Docker بينسخ الـ files دي في الـ volume أول مرة بس. ودي الحيلة بتاعة node_modules: anonymous volume على slash app slash node_modules بتاخد نسخة الـ image، والـ bind mount بتاع dot slash على slash app ما يقدرش يغطّيها، لأن الـ mount الأطول يكسب. الـ bind mount مفيهوش copy-up. هو بيغطّي اللي تحته في الـ image، وخلاص. والـ copy-up بيحصل مرة واحدة. لو الـ volume فيها حاجة، Docker مش بيلمسها. يعني لو عملت update للـ image و node_modules اتغيرت، الـ anonymous volume القديمة لسه فيها القديم. الحل: docker compose up بـ renew anon volumes، أو down وبعدين up.

والـ permissions: في درس الـ Dockerfile شغّلنا الـ app بـ user مش root. لو الـ volume اتعملت والـ files فيها ملك root، الـ app مش هيقدر يكتب، وهيقع بـ EACCES. الحل: في الـ Dockerfile، اعمل الـ folder و chown للـ user قبل USER. والـ copy-up بيسيب نفس الـ owner، فالـ volume الجديدة بتطلع صح. الـ bind mount بياخد الـ uid بتاع الـ host زي ما هو. فلو الـ host user رقمه غير الـ container user، هتقابل files مش بتاعتك. علشان كده user ألف على ألف في الـ development. و read only: لو الـ container مش محتاج يكتب، اعمله ro. والأحسن كمان read_only true على الـ container كله، و tmpfs للـ slash tmp بس. لو حد اخترق الـ app مش هيقدر يكتب أي حاجة. ده compose dot yaml الجديد. db على named volume اسمها pgdata، و tmpfs للـ slash tmp. والـ password من file، مش في الـ environment. redis على named volume، و appendonly yes، علشان redis نفسه يكتب الـ data على الـ disk، وإلا الـ volume مش هتفرق كتير. api: bind للـ code، و anonymous volume على node_modules، والـ nginx dot conf بالـ long syntax و read_only true. والـ docker socket اتشال. وتحت خالص: volumes، فيها الأسامي. compose بيحط قبلها اسم الـ project، فهتلاقيها في docker volume ls باسم shop underscore pgdata. وده للـ development. في production مفيش bind mount للـ code خالص: الـ code جُوّه الـ image، والـ volumes للـ data بس.

مفيش Docker هنا، فهنكتب simulator بنفس القواعد. lab dot js بيجرّب الـ db بتلات طرق: من غير volume، وعلى anonymous، وعلى named. وكل مرة: restart، وبعدين down و up، وبعدين down v. وبيجرّب الـ api بالـ bind mount لوحده، ومعاه volume على node_modules و config ro. التحدي: اكتب volumes dot js. التفاصيل كلها في الكومنت، و test dot js فيه أربعتاشر حالة.

تمرين

volumes.js: parseMount بالـ short والـ long syntax، و mountsOf و mountFor بالـ mount الأطول، و createDocker فيه up بالـ copy-up و write و read و restart و down و down -v والـ anonymous volumes، و lintMounts بـ DATA-NOT-PERSISTED و ANON-DATA و DOCKER-SOCK و CONFIG-WRITABLE و HIDES-NODE-MODULES.

الحل. parseMount: الـ source لو شكله path يبقى bind، غير كده اسم volume. mountFor: filter على الـ mounts اللي الـ path تحتها، و sort بطول الـ target. up: الـ copy-up بيحصل بس لو الـ volume مش موجودة، ودي القاعدة اللي بتعمل مشكلة node_modules القديمة. read: الـ bind بيرجّع من الـ host وبس، حتى لو الـ image فيها الـ file. ودي اللي بتخبّي node_modules. down: الـ anonymous بتتمسح دايمًا، والـ named بس مع volumes true. نشغّل lab dot js.

volumes.js
// volumes.js: simulator للـ mounts في Docker: named volumes و anonymous و bind mounts و tmpfs، و lint
import { posix } from "node:path";

export function parseMount(spec) {
  if (typeof spec === "object") return { type: spec.type, source: spec.source ?? null, target: spec.target, readOnly: !!spec.read_only };
  const parts = String(spec).split(":");
  if (parts.length === 1) return { type: "volume", source: null, target: parts[0], readOnly: false }; // anonymous
  const [source, target, mode = "rw"] = parts;
  const bind = /^(\/|\.\/|\.\.\/|~|\.$)/.test(source);
  return { type: bind ? "bind" : "volume", source, target, readOnly: mode.split(",").includes("ro") };
}

export const mountsOf = (svc) => [...(svc.volumes ?? []).map(parseMount), ...(svc.tmpfs ?? []).map((t) => ({ type: "tmpfs", source: null, target: t, readOnly: false }))];

const under = (path, dir) => path === dir || path.startsWith(dir.endsWith("/") ? dir : dir + "/");

export function mountFor(mounts, path) {
  return mounts.filter((m) => under(path, m.target)).sort((a, b) => b.target.length - a.target.length)[0] ?? null;
}

export function createDocker({ images = {}, host = new Map() } = {}) {
  const volumes = new Map(); // الاسم ← Map(path ← content)
  const containers = new Map();
  let anon = 0;
  const hostKey = (m, path) => posix.normalize(posix.join(m.source, posix.relative(m.target, path))).replace(/^\.\//, "");

  function up(name, svc) {
    if (containers.has(name)) return containers.get(name);
    const image = images[svc.image] ?? {};
    const c = { svc, image, layer: new Map(), tmp: new Map(), mounts: mountsOf(svc).map((m) => ({ ...m })) };
    for (const m of c.mounts) {
      if (m.type !== "volume") continue;
      if (!m.source) m.source = `anon-${++anon}`;
      if (!volumes.has(m.source)) {
        // volume جديدة فاضية ← Docker بينسخ فيها اللي في الـ image تحت الـ target ده (copy-up). الـ bind mount لأ
        const v = new Map();
        for (const [p, content] of Object.entries(image)) if (under(p, m.target)) v.set(p, content);
        volumes.set(m.source, v);
      }
    }
    containers.set(name, c);
    return c;
  }

  const get = (name) => { const c = containers.get(name); if (!c) throw new Error(`مفيش container اسمه ${name}`); return c; };

  function write(name, path, content) {
    const c = get(name), m = mountFor(c.mounts, path);
    if (m?.readOnly) throw Object.assign(new Error(`EROFS: ${path} read only`), { code: "EROFS" });
    if (!m) return void c.layer.set(path, content);
    if (m.type === "tmpfs") return void c.tmp.set(path, content);
    if (m.type === "bind") return void host.set(hostKey(m, path), content);
    volumes.get(m.source).set(path, content);
  }

  function read(name, path) {
    const c = get(name), m = mountFor(c.mounts, path);
    if (m?.type === "tmpfs") return c.tmp.get(path) ?? null;
    if (m?.type === "bind") return host.get(hostKey(m, path)) ?? null; // الـ bind بيغطّي اللي في الـ image تحت الـ target
    if (m?.typ
…

المخرجات

$ node lab.js

=== db من غير volume ===
  ERROR DATA-NOT-PERSISTED: /var/lib/postgresql/data مش على volume: الـ data هتروح مع أول down
  بعد restart:     orders "عشرين ألف order" | tmp مش موجود
  بعد down و up:   orders مش موجود
  بعد down -v و up: orders مش موجود | volumes -

=== db على anonymous volume ===
  WARN ANON-DATA: /var/lib/postgresql/data على anonymous volume: up بعد down هيبدأ فاضي
  بعد restart:     orders "عشرين ألف order" | tmp مش موجود
  بعد down و up:   orders مش موجود
  بعد down -v و up: orders مش موجود | volumes anon-3

=== db على named volume ===
  بعد restart:     orders "عشرين ألف order" | tmp مش موجود
  بعد down و up:   orders "عشرين ألف order"
  بعد down -v و up: orders مش موجود | volumes pgdata

=== api في الـ development: bind mount للـ code ===
  -- bind على /app بس
     WARN HIDES-NODE-MODULES: ./ على /app بيغطّي node_modules بتاعة الـ image: ضيف volume على /app/node_modules
     WARN CONFIG-WRITABLE: ./nginx.conf config: اعمله ro
     server.js: "v2 لسه متعدّل" | express: مش موجود
     الـ container غيّر nginx.conf على الـ host: "اتغيّر من جُوّه"
  -- ومعاه volume على node_modules و config ro
     server.js: "v2 لسه متعدّل" | express: "express (Linux b
…

من غير volume: الـ orders عاشت بعد restart، وراحت مع down. والـ lint قالها من الأول: DATA-NOT-PERSISTED. الـ anonymous: نفس النتيجة بالضبط بعد down. الـ volume موجودة، بس واحدة جديدة فاضية. الـ named: عاشت بعد down و up، وراحت بس مع down v. والـ tmp اتمسح مع restart في التلاتة، لأنه tmpfs. الـ api بالـ bind لوحده: server dot js هو النسخة اللي على الـ host، تمام، بس express مش موجود. والـ container عدّل nginx dot conf على الـ host. ومع الـ volume على node_modules: express رجع، نسخة الـ Linux من الـ image. والكتابة في الـ config بقت EROFS. ونشغّل test dot js.

volumes.js

المخرجات

$ node test.js
✅ parseMount: named و anonymous 
✅ parseMount: bind بـ ./ و / و ro 
✅ parseMount: الـ long syntax 
✅ mountsOf: volumes و tmpfs 
✅ mountFor: الأطول يكسب، و /application مش تحت /app 
✅ من غير volume: الـ writable layer بيعيش بعد restart، ويروح مع down 
✅ named volume: copy-up من الـ image، وبيعيش بعد down، و down -v بيمسحه 
✅ anonymous volume: volume جديدة بعد down و up، والقديمة اتمسحت 
✅ tmpfs: بيتمسح مع restart 
✅ bind: بيقرا من الـ host ويغطّي الـ image، والكتابة بتروح على الـ host 
✅ ro: الكتابة بترمي EROFS والـ host ما اتغيّرش 
✅ anonymous volume على node_modules: بياخد نسخة الـ image (copy-up) والـ code من الـ host 
✅ lint: DATA-NOT-PERSISTED و ANON-DATA و named نضيف 
✅ lint: DOCKER-SOCK و CONFIG-WRITABLE و HIDES-NODE-MODULES 

14/14

كله نجح. آخر حاجة: الـ backup. الـ named volume بتعيش بعد down، بس مش بعد disk وقع، أو rm غلط، أو down v من غير قصد. الطريقة الأساسية: pg_dump من جُوّه الـ container. ده logical backup متّسق حتى والـ database شغّالة. وجرّب الـ restore فعلًا. backup ما اتجرّبش restore بتاعه ما تعتمدش عليه. backup للـ volume كله: container مؤقت زي alpine، بيركّب الـ volume ro، ويعمل tar. بس والـ database واقفة. نسخ الـ data dir بتاع Postgres وهو شغّال بيطلّع نسخة ممكن ما تقومش. docker volume ls و inspect بيقولولك الـ volume فين، و system df بيقولك مين واكل المساحة. وخلي بالك من اتنين: down v، و volume prune. الاتنين بيمسحوا data من غير ما يسألوا كتير. كده الـ data في أمان. بس الـ container ممكن يكون شغّال ومش شغّال: الـ process موجود، والـ app معلّق، أو واكل كل الـ memory بتاعة الـ server. الدرس الجاي: الـ healthcheck والـ restart policies والـ resource limits، memory و cpu، و Node جُوّه container ليه limits.

compose.naive.yaml
# compose.naive.yaml: كله شغّال... لحد أول docker compose down
services:
  db:
    image: postgres:17
    environment:
      POSTGRES_PASSWORD: dev
    # مفيش volumes: الـ data في الـ writable layer بتاع الـ container

  redis:
    image: redis:7
    volumes:
      - /data            # anonymous volume: كل up بعد down بيبدأ فاضي

  api:
    build: .
    working_dir: /app
    command: node --watch server.js
    volumes:
      - ./:/app          # بيغطّي /app/node_modules اللي اتعمل جُوّه الـ image
      - ./nginx.conf:/etc/nginx/nginx.conf   # الـ container يقدر يعدّل الـ file على الـ host
      - /var/run/docker.sock:/var/run/docker.sock   # root على الـ host
compose.yaml
# compose.yaml: الـ data على named volumes، والـ code بـ bind mount للـ development بس
services:
  db:
    image: postgres:17
    environment:
      POSTGRES_PASSWORD_FILE: /run/secrets/pg_password
    volumes:
      - pgdata:/var/lib/postgresql/data
    tmpfs:
      - /tmp

  redis:
    image: redis:7
    command: redis-server --appendonly yes
    volumes:
      - redisdata:/data

  api:
    build: .
    working_dir: /app
    user: "1000:1000"
    command: node --watch server.js
    volumes:
      - ./:/app
      - /app/node_modules          # node_modules بتاعة الـ image (Linux build) تفضل زي ما هي
      - type: bind
        source: ./nginx.conf
        target: /etc/nginx/nginx.conf
        read_only: true
    tmpfs:
      - /tmp

volumes:
  pgdata:       # docker volume ls ← <project>_pgdata
  redisdata:
lab.js
// lab.js: بنجرّب الـ mounts في الـ simulator: مين بيعيش بعد restart، وبعد down و up، وبعد down -v
import { createDocker, lintMounts } from "./volumes.js";

const images = {
  "postgres:17": {},
  "shop-api:dev": { "/app/server.js": "v1", "/app/node_modules/express/index.js": "express (Linux build)" },
};
const show = (v) => (v === null ? "مش موجود" : JSON.stringify(v));

function story(title, svc) {
  const d = createDocker({ images });
  console.log(`\n=== ${title} ===`);
  for (const f of lintMounts("db", svc)) console.log(`  ${f.severity} ${f.rule}: ${f.msg}`);
  d.up("db", svc);
  d.write("db", "/var/lib/postgresql/data/orders", "عشرين ألف order");
  d.write("db", "/tmp/sort.tmp", "شغل مؤقت");
  d.restart("db");
  console.log(`  بعد restart:     orders ${show(d.read("db", "/var/lib/postgresql/data/orders"))} | tmp ${show(d.read("db", "/tmp/sort.tmp"))}`);
  d.down("db"); d.up("db", svc);
  console.log(`  بعد down و up:   orders ${show(d.read("db", "/var/lib/postgresql/data/orders"))}`);
  d.down("db", { volumes: true }); d.up("db", svc);
  console.log(`  بعد down -v و up: orders ${show(d.read("db", "/var/lib/postgresql/data/orders"))} | volumes ${d.volumes().join(" ") || "-"}`);
}

story("db من غير volume", { image: "postgres:17", tmpfs: ["/tmp"] });
story("db على anonymous volume", { image: "postgres:17", volumes: ["/var/lib/postgresql/data"], tmpfs: ["/tmp"] });
story("db على named volume", { image: "postgres:17", volumes: ["pgdata:/var/lib/postgresql/data"], tmpfs: ["/tmp"] });

console.log("\n=== api في الـ development: bind mount للـ code ===");
const host = new Map([["server.js", "v2 لسه متعدّل"], ["nginx.conf", "server {}"]]);
for (const [title, svc] of [
  ["bind على /app بس", { image: "shop-api:dev", working_dir: "/app", volumes: ["./:/app", "./nginx.conf:/etc/nginx/nginx.conf"] }],
  ["ومعاه volume على node_modules و config ro", { image: "shop-api:dev", working_dir: "/app", volumes: ["./:/app", "/app/node_modules", "./nginx.conf:/etc/nginx/nginx.conf:ro"] }],
]) {
  const d = createDocker({ images, host });
  console.log(`  -- ${title}`);
  for (const f of lintMounts("api", svc)) console.log(`     ${f.severity} ${f.rule}: ${f.msg}`);
  d.up("api", svc);
  console.log(`     server.js: ${show(d.read("api", "/app/server.js"))} | express: ${show(d.read("api", "/app/node_modules/express/index.js"))}`);
  try { d.write("api", "/etc/nginx/nginx.conf", "اتغيّر من جُوّه"); console.log(`     الـ container غيّر nginx.conf على الـ host: ${show(host.get("nginx.conf"))}`); host.set("nginx.conf", "server {}"); }
  catch (e) { console.log(`     الكتابة في nginx.conf: ${e.code}`); }
}
03 / دروس المسار (122)
  1. 01أهلًا بيك: يعني إيه backend، والكورس ده ماشي إزاي
  2. 02الملفات والفولدرات والـ terminal: تتحرك على جهازك زي المبرمجين
  3. 03Node وأول برنامج: تشغّل وتقرا رسالة الخطأ
  4. 04القيم والمتغيرات والأنواع: const و let و typeof
  5. 05القرارات والتكرار: if و === والـ truthy والـ loops
  6. 06الـ functions: parameters و return والـ arrow functions والـ scope
  7. 07الـ objects والـ arrays: destructuring و spread و map و filter و reduce
  8. 08JSON والنصوص والتواريخ: اللغة اللي الـ backend بيتكلم بيها
  9. 09الـ callbacks والـ closures وأول لمسة async: setTimeout
  10. 10الـ classes والـ errors: throw و try/catch و stack trace
  11. 11git: تحفَظ كل خطوة وترجعلها، وما تسرّبش أسرارك
  12. 12ESM و CommonJS و package exports: Node بيلاقي الـ modules إزاي
  13. 13الـ Promises و async/await: sequential و parallel والأخطاء والإلغاء
  14. 14الـ event loop والـ microtasks: Node بيعمل كل حاجة بـ thread واحد إزاي
  15. 15الـ Streams والـ Backpressure: ملفات أكبر من الـ memory
  16. 16الـ File System والـ paths: قراية وكتابة صح، ومن غير path traversal
  17. 17الـ Buffers والبيانات الـ binary: الـ bytes من جُوّه
  18. 18Crypto APIs والأسرار: random و hash و HMAC و AES-GCM
  19. 19الـ Worker Threads: شغل CPU تقيل من غير ما توقف الـ server
  20. 20الـ Errors على مستوى الـ process: operational و programmer و crash-only
  21. 21الـ Node test runner والـ debugging: tests من غير مكتبات
  22. 22HTTP من جُوّه: الـ methods والـ status codes والـ headers
  23. 23Express والـ Routing: الـ params والـ query والترتيب والـ Router
  24. 24Express 5: إيه اللي اتغيّر، وإزاي تنقل مشروع قديم
  25. 25الـ Middleware ودورة حياة الـ request جُوّه Express
  26. 26Validation للمدخلات بـ Zod: ما تصدّقش أي حاجة جاية من برة
  27. 27تصنيف الأخطاء و Problem Details: شكل واحد لكل الـ errors
  28. 28الـ CORS والـ Cookies: المتصفح بيحمي المستخدم إزاي
  29. 29رفع الملفات وحدود الحجم: multer من غير ثغرات
  30. 30الـ Realtime: Server-Sent Events و WebSockets
  31. 31OpenAPI والـ API Versioning: عقد مكتوب، وتغيير من غير ما تكسر حد
  32. 32PostgreSQL: الـ DDL وأنواع البيانات الصح لكل عمود
  33. 33الـ Constraints: PK و FK و UNIQUE و CHECK — الـ database بتحمي نفسها
  34. 34الـ Normalization والـ ERD: تقسّم البيانات صح من أول يوم
  35. 35الـ JOINs والتجميع: INNER و LEFT و GROUP BY و HAVING و window functions
  36. 36JSONB في PostgreSQL: إمتى تستخدمه، وإزاي تسأله وتعمله index
  37. 37الـ Indexes من جُوّه: B-tree و GIN و BRIN
  38. 38Partial و Covering indexes: indexes أصغر وأسرع
  39. 39الـ Pagination بالـ Keyset: ليه OFFSET بيبطّأ وبيكرر
  40. 40Full Text Search في Postgres: بحث بالكلمات، بالعربي والإنجليزي
  41. 41EXPLAIN ANALYZE والـ Planner: اقرا الـ plan وصلّح الـ query
  42. 42الـ Transactions بـ node-postgres: كله أو ولا حاجة
  43. 43الـ MVCC ومستويات الـ Isolation: transactions كتير في نفس الوقت
  44. 44الـ Locks والـ Deadlocks: مين مستني مين
  45. 45SKIP LOCKED و Job Leasing: Postgres كـ job queue
  46. 46Row Level Security والـ Multi-tenancy: كل عميل يشوف بياناته بس
  47. 47Migrations من غير downtime: expand و backfill و contract
  48. 48الـ Replication والـ Read Replicas: نسخ حية من الـ database
  49. 49الـ Connection Pooling و PgBouncer: connections أقل، requests أكتر
  50. 50الـ Partitioning والـ VACUUM والمراقبة: Postgres على المدى الطويل
  51. 51Redis وأنواع البيانات: strings و hashes و lists و sets و sorted sets
  52. 52Cache-aside والـ TTL: Redis قدام الـ database
  53. 53الـ Cache invalidation والـ Stampede: لما الـ key الشهير يموت
  54. 54Lua والـ Atomicity في Redis: كام أمر كأنهم أمر واحد
  55. 55الـ Rate Limiting في Redis: fixed window و sliding window و token bucket
  56. 56الـ Sessions في Redis: تسجيل دخول تقدر تلغيه في أي وقت
  57. 57Redis Streams والـ Consumer Groups: log بيتوزع على workers
  58. 58Pub/Sub و BullMQ: إشارات بين الـ instances، وطوابير شغل محترمة
  59. 59Redis لما يقع: الـ persistence (RDB و AOF) والـ replication
  60. 60Redis في الإنتاج: الـ ACLs والـ Cluster والمراقبة
  61. 61تخزين الـ Passwords بـ Argon2id: صح من أول مرة
  62. 62Session Fixation والـ Rotation: id جديد مع كل صلاحية جديدة
  63. 63الـ Cookie Flags والـ CSRF: المتصفح بيبعت الـ cookie، فلازم تتأكد مين اللي طلب
  64. 64الـ XSS والـ Content Security Policy: ما تخليش النص يتحوّل لـ code
  65. 65الـ OAuth و OpenID Connect و PKCE: login بـ Google من غير ما تشوف الـ password
  66. 66التأكد من الـ JWT صح: التوقيع والـ claims والـ scopes
  67. 67الـ BOLA و BFLA: الـ token السليم مش معناه إن الطلب مسموح
  68. 68الـ RBAC و ABAC والملكية: policy واحدة بدل ifs متفرقة
  69. 69الـ MFA والـ recovery: التاني factor اللي بجد
  70. 70الـ Passkeys و WebAuthn: login من غير password وضد الـ phishing
  71. 71الـ Threat Modeling بـ STRIDE: فكّر زي المهاجم قبل ما تكتب code
  72. 72الـ SQL Injection والـ Parameterization: الـ data ما تبقاش code
  73. 73الـ SSRF والـ Egress: ما تخليش الـ server بتاعك يزور الشبكة الداخلية
  74. 74الـ Security Headers والـ TLS: كل response يقول للـ browser يحمي المستخدم إزاي
  75. 75توقيع الـ Webhooks والـ Replay: الـ webhook ده جاي فعلًا من Stripe؟
  76. 76تغيير الأسرار والـ HMAC: إزاي تغيّر مفتاح من غير ما كل حاجة تقع
  77. 77سلسلة التوريد والـ SBOM: إنت واثق في ألف package ما تعرفهمش؟
  78. 78الـ Audit والـ Privacy Logs: سجّل مين عمل إيه، من غير ما تسجّل الأسرار
  79. 79اختبار الأمان و OWASP ASVS: الأمن جُوّه الـ CI، مش audit آخر السنة
  80. 80الـ Prototype Pollution والـ Resource DoS: request واحد يخلّي الكل admin أو يوقّع الـ server
  81. 81الـ SLI والـ SLO والـ Error Budget: إمتى تصحّي الـ on-call وإمتى تسيبه نايم
  82. 82الـ Event Loop Delay والـ ELU: لما Node نفسه يتخنق
  83. 83الـ Worker Threads والـ CPU Profiling: الشغل التقيل بره الـ event loop، والوقت راح فين
  84. 84الـ Memory والـ GC والـ Leaks: الـ process اللي بيكبر لحد ما يقع
  85. 85الـ N+1 Queries والـ DataLoader: صفحة واحدة بمِيّتين query
  86. 86الـ HTTP Caching والـ Compression: أسرع request هو اللي ما بيوصلش
  87. 87الـ Load Testing والـ Soak Testing: الـ server بيستحمل قد إيه بجد
  88. 88الـ Concurrency Limits والـ Bulkheads: dependency بطيئة ما توقعش الـ app كله
  89. 89الـ Timeouts والـ Retries والـ Circuit Breakers: إزاي تتعامل مع dependency بطيئة أو واقعة
  90. 90OpenTelemetry والـ Distributed Tracing: الـ request راح فين وضاع وقته فين
  91. 91Docker Layers والـ Build Context: ليه الـ build بياخد دقيقة وفيه الـ .env بتاعك
  92. 92Multi-stage Builds و Non-root: image صغيرة ومن غير root
  93. 93Docker Compose والـ Networks: الـ services بتلاقي بعض إزاي
  94. 94Docker Volumes: الـ data بتتحفَظ فينانت هنا
  95. 95Healthcheck و Restart و Resource Limits: running مش معناها شغّال
  96. 96BuildKit والـ Build Secrets: الـ token ما يدخلش الـ image
  97. 97Reverse Proxy و TLS: اللي واقف قدام الـ app
  98. 98Multi-arch Images والـ Native Modules: اشتغلت عندي
  99. 99CI/CD و Rollback و Canary: الـ deploy يبقى ممل
  100. 100Kubernetes من الأول: Pods و Deployments و Services و Probes
  101. 101Modular Monolith و DDD: حدود واضحة من غير network
  102. 102Transactional Outbox و Inbox: الـ event ما يضيعش وما يتنفذش مرتين
  103. 103Sagas: عملية واحدة على تلات services من غير transaction واحدة
  104. 104CQRS و Event Sourcing: الـ events هي الحقيقة
  105. 105الـ Queues والـ Brokers: BullMQ و RabbitMQ و Kafka و SQS
  106. 106Realtime على أكتر من instance: Redis pub/sub و presence و resume
  107. 107الـ Object Storage والـ Media: presigned URLs و uploads مباشرة
  108. 108التكامل مع الـ Email والـ Search: retries و webhooks و indexes
  109. 109GraphQL و gRPC في الإنتاج: contracts و DataLoader و limits و deadlines
  110. 110Kafka على أكتر من zone و region: الـ replication والـ ISR والـ acks والـ MirrorMaker والـ failover
  111. 111TypeScript و runtime boundaries: الـ types بتختفي، والـ schemas لأ
  112. 112ORM ولا SQL: query builders و repositories و migrations و transactions
  113. 113الـ Serverless من جُوّه: cold starts و freeze و timeouts و connections
  114. 114الـ Testing Pyramid: unit و integration و e2e على Postgres حقيقية
  115. 115Contract Testing و Property-Based Testing بـ fast-check
  116. 116الـ Payments: idempotency و webhooks و refunds و reconciliation
  117. 117الـ Timezones والـ Internationalization: UTC و DST والـ locales والـ plurals والفلوس
  118. 118الـ Privacy والـ Data Retention: consent و export و erasure و crypto shredding
  119. 119الـ ADRs والـ Feature Flags: القرارات المكتوبة والـ rollout من غير deploy
  120. 120Multi-region active-active: حل الـ conflicts بـ HLC و CRDTs
  121. 121Readiness و Liveness و Startup Probes: الـ pod جاهز ولا عايش؟
  122. 122Incident Runbooks: من الـ alert للـ postmortem