Open jarshwah opened 5 years ago
Thanks Josh! I will experiment with using the alpine images and put the results here.
I don't know how much your dockerfile above is edited, but adding ENV PIP_NO_CACHE_DIR=off
can reduce image size by a fair bit as well.
Oops, didn't mean to close the issue as there is still more we can do.
Regarding using the alpine images: I'd like to explore this, but it's a fair bit of work. We need to ensure each of the system packages has a compatible version. For example gdal
is still in testing: https://pkgs.alpinelinux.org/packages?name=gdal&branch=edge
By using the -slim
package and also by using ENV PYTHONDONTWRITEBYTECODE=1
(which adds about 50+mb!) the image goes down from 500mb compressed to 260mb. Locally it goes down about 600mb to 740mb 🎉
Half the size for basically free is a great result 🚀
One way to reduce the final size of the image is to start from a more minimal base. There are alpine builds that can help with this, but it might mean there's a bunch of different setup to be done for databases etc, or it might be impossible to have the same support with alpine. See below for an edited version of an alpine based build I use in a work project:
Then there's the possibility of using build files and copy-from to further reduce the final image size.