hackforla / peopledepot

A project to setup a datastore for people and projects at HackforLA. The link below takes you to the code documentation
https://hackforla.github.io/peopledepot/
GNU General Public License v2.0
5 stars 24 forks source link

Switch to alpine base image in Dockerfile #177

Open fyliu opened 11 months ago

fyliu commented 11 months ago

Overview

The current PD docker image is 1.3GB. We should switch to alpine so that we can reduce the image size.

Action Items

Resources/Instructions

fyliu commented 3 months ago

I'm picking up from where @alexlaw528 left off. This change will make the image smaller and reduce the download required to build the image.

fyliu commented 3 months ago

I'm able to reduce the image size to 3xxMB by switching to alpine. However, the erd script doesn't work anymore. It generates a junk image.

Considering abandoning image generation for erd, and maybe do it separately on the host or use an online service. Without the erd image generation helpers, the image is 138MB, which is 1/10 the size of the debian-based image.

fyliu commented 3 months ago

The bad png image was caused by the Roboto font being specified in the .dot file but not being found in the alpine system. It generated the png correctly after I installed the font.

The problem I'm having is that there's not a good way to automate downloading the font when building the image. I manually downloaded and installed it in the container for testing. Maybe the solution is to choose a font that already exists or is easy to install in alpine.

fyliu commented 3 months ago

I left a message in the django-extensions mailing list but there's no response. I can only assume that Roboto is the designated default font, so I'm checking it into git and installing it into the image at build time so that the erd.png generation can work as before.

The final image size is 203MB on my machine.

I made a PR.

fyliu commented 4 weeks ago

A couple things happened in the PR thread. We'll need to add these tasks