
I Shaved 600 MB Off a Production Docker Image Here's What I Learned
I've been contributing to Eventyay an open-source event management platform by FOSSASIA and the first thing I did wasn't write a feature or fix a bug. I looked at the Dockerfile. 1.42 GB. For a Django app. One point four two gigabytes. That's almost the size of a small Linux distro. So naturally, I had to fix it. What was going wrong If you've worked with Docker and Django, you've probably made the same mistakes. I've definitely made them in my own projects before I knew better. The Eventyay Dockerfile had the classics: Everything was in one stage. The image that gets shipped to production had build-essential , gcc , git , and a bunch of other tools that are only needed to compile packages not to run them. Once your Python packages are installed, you don't need a C compiler sitting in your production container. The base image was heavy. The full python:3.12 image is around 900 MB by itself. That's before you add a single line of your own code. apt cache was sticking around. Every apt-g
Continue reading on Dev.to Python
Opens in a new tab




