การ build Docker image และ container ระดับ production เป็นไปตาม best practice ที่ได้รับการยอมรับ — สำหรับ ขนาด image, ความปลอดภัย, caching, การกำหนดค่า และ ความน่าเชื่อถือ การปฏิบัติตามจะสร้าง image ที่เล็ก, ปลอดภัย, มีประสิทธิภาพ และบำรุงรักษาได้
ขนาด image และประสิทธิภาพ
✓ Use SMALL base images (alpine, slim, distroless) — smaller, fewer vulnerabilities
✓ MULTI-STAGE builds — exclude build tools from the final image
✓ Order Dockerfile for LAYER CACHING (dependencies before code)
✓ Use .dockerignore — exclude unneeded files (node_modules, .git, secrets) from context
✓ Combine RUN commands and clean up in the same layer (smaller layers)
