MENU

Fun & Interesting

This Is How You Write an Efficient Python Dockerfile

ArjanCodes 41,213 2 months ago
Video Not Working? Fix It Now

👷 Review code better and faster with my 3-Factor Framework: https://arjan.codes/diagnosis. In this video, I’ll take you step-by-step through creating an optimized and efficient Docker image. I’ll cover picking the right base image, removing clutter from your Dockerfile, making it more secure, and a few things that you probably didn’t know where possible. 🔥 GitHub Repository: https://git.arjan.codes/2025/efficient-python-dockerfile. 🎓 ArjanCodes Courses: https://www.arjancodes.com/courses. 🔖 Chapters: 0:00 Intro 0:23 1. Starting Point 3:04 2. Choose The Right Base Image 5:18 3. Do Not Use the Latest Tag 6:21 4. Remove Unnecessary Dependencies 7:25 5. Clean Up Dependencies 8:06 6. Use UV 9:10 7. Use a Multi Stage Build 11:42 8. COPY Only The Things You Need 13:26 9. Load Secrets Using The Secret Mount Type 15:11 10. Run as a local user 16:34 Frustrations 18:15 Final Thoughts #arjancodes #softwaredesign #python

Comment