multi-stage-dockerfile
ما الذي تفعله
ينشئ هذا الوكيل ملفات Dockerfile فعّالة لتشغيل البرامج داخل حاويات. ينظم العملية في مراحل، لضمان أن تكون النتيجة النهائية أصغر وأكثر أماناً وأسرع.
متى تستخدمها
- ✓عندما تريد إنشاء «حزمة» لتشغيل برنامجك في أي مكان.
- ✓لجعل حزمة برنامجك أصغر ما يمكن.
- ✓لجعل حزمة برنامجك أكثر أماناً ضد الهجمات.
رابط المهارة
https://github.com/github/awesome-copilot/blob/main/skills/multi-stage-dockerfile/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“أنشئ ملف Dockerfile محسّناً لتطبيق Node.js يستخدم React.”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
تستخدم تقنية تُسمى «multi-stage builds»، حيث تبني مرحلة البرنامج، ثم تشغّله مرحلة ثانية أنظف. وهذا يضمن أن النتيجة النهائية تحتوي على الضروريات فقط.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من GitHub.
Your goal is to help me create efficient multi-stage Dockerfiles that follow best practices, resulting in smaller, more secure container images.
Multi-Stage Structure
- Use a builder stage for compilation, dependency installation, and other build-time operations
- Use a separate runtime stage that only includes what's needed to run the application
- Copy only the necessary artifacts from the builder stage to the runtime stage
- Use meaningful stage names with the
ASkeyword (e.g.,FROM node:18 AS builder) - Place stages in logical order: dependencies → build → test → runtime
Base Images
- Start with official, minimal base images when possible
- Specify exact version tags to ensure reproducible builds (e.g.,
python:3.11-slimnot justpython) - Consider distroless images for runtime stages where appropriate
- Use Alpine-based images for smaller footprints when compatible with your application
- Ensure the runtime image has the minimal necessary dependencies
Layer Optimization
- Organize commands to maximize layer caching
- Place commands that change frequently (like code changes) after commands that change less frequently (like dependency installation)
- Use
.dockerignoreto prevent unnecessary files from being included in the build context - Combine related RUN commands with
&&to reduce layer count - Consider using COPY --chown to set permissions in one step
Security Practices
- Avoid running containers as root - use
USERinstruction to specify a non-root user - Remove build tools and unnecessary packages from the final image
- Scan the final image for vulnerabilities
- Set restrictive file permissions
- Use multi-stage builds to avoid including build secrets in the final image
Performance Considerations
- Use build arguments for configuration that might change between environments
- Leverage build cache efficiently by ordering layers from least to most frequently changing
- Consider parallelization in build steps when possible
- Set appropriate environment variables like NODE_ENV=production to optimize runtime behavior
- Use appropriate healthchecks for the application type with the HEALTHCHECK instruction
الأسئلة الشائعة
ما هو Dockerfile؟
هو ملف نصي يحتوي على تعليمات لـ Docker لإنشاء بيئة معزولة (حاوية) يعمل فيها برنامجك.
لماذا تُعد «المراحل المتعددة» أفضل؟
لأنها تفصل أدوات بناء البرنامج عن بيئة التشغيل، فتكون الحاوية النهائية أصغر وأكثر أماناً بكثير.
ما هي «الحاويات» (containers)؟
هي صناديق معزولة تحتوي على كل ما يحتاجه البرنامج ليعمل، مما يسهّل تشغيله على أجهزة مختلفة.
التفاصيل
الوصف الأصلي من المؤلف
Create optimized multi-stage Dockerfiles for any language or framework
repo: github/awesome-copilot
الشعبية
- نجوم GitHub
- 40k
- الترتيب
- #7301
- الترخيص
- MIT
- آخر تحديث
- 15/10/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
acquire-codebase-knowledge
40kيساعد وكيلك على فهم مشروع برمجي موجود وتوثيقه. مفيد لتعريف الأشخاص الجدد أو للحصول على نظرة عامة على البنية.
acreadiness-assess
40kيمكّن وكيلك من تقييم جاهزية مشروع للذكاء الاصطناعي وإنشاء تقرير. مفيد لمعرفة مدى استعداد المشروع لاستخدام أدوات الذكاء الاصطناعي.
acreadiness-generate-instructions
40kيساعد وكيلك على إنشاء تعليمات لأدوات الذكاء الاصطناعي بناءً على تقييم. مفيد لتحسين طريقة تفاعل الذكاء الاصطناعي مع الكود وسد الثغرات المحددة.
acreadiness-policy
40kيمكّن وكيلك من تحديد أو تطبيق سياسات لتقييم مشاريع الذكاء الاصطناعي. مفيد لتوحيد طريقة تقييم المشاريع وضمان الالتزام.
مهارات مشابهة
openclaw-update
394kيساعد وكيلك على تحديث بوابة OpenClaw Gateway الموجودة، مع اختيار طريقة التحديث المناسبة لطريقة تثبيتها والحفاظ على جلستك.
diagnose-gateway
394kيساعد وكيلك على معرفة سبب فشل بوابة OpenClaw Gateway عبر فحص الإعدادات والقنوات والمنافذ دون تغيير أي شيء.
crabbox-apps
394kيساعد وكيلك على فتح تطبيق وتشغيله على جهاز سحابي مؤقت، ثم عرض واجهته في الشريط الجانبي للدردشة.