lambgeo / docker-lambda

AWS Lambda friendly GDAL Docker images and AWS Lambda layer
MIT License
124 stars 18 forks source link

"RUN yum install -y gcc gcc-c++" adds 500MB to image but is unused at runtime #55

Closed philvarner closed 8 months ago

philvarner commented 1 year ago

The Dockerfile directive RUN yum install -y gcc gcc-c++ in https://github.com/lambgeo/docker-lambda/blob/master/dockerfiles/runtimes/python adds 500MB to the image, but is unused at runtime.

A more efficient approach would be to use a multi-stage build and copy only the files that are necessary for runtime into the resulting image.

Additionally and/or alternatively, && yum clean all && rm -rf /var/cache/yum /var/lib/yum/history can be added to the command to reduce the size of the layer.

vincentsarago commented 1 year ago

To be honest, I don't think we should use the image as a runtime but more as a mean to create lambda package or layer. gcc can be useful when you need to install complex python library which require C code 🤷

philvarner commented 10 months ago

Ah! I understand what you mean now. I only now got back around to working on what I was originally doing with this, and using that image as a lambda base image did not work -- which is to be expected, since it's not configured to be one.

I'll still submit a pr for the image cleanup commands.