Self-compiled gems

It’s great that Jets can download recompiled Ruby gems however, is it possible to build into the workflow somewhere a https://github.com/lambci/docker-lambda or similar-based compilation solution to package up compiled gems during the layers deploy step?

Yes, that’s a great idea. Been thinking about it already.

1 Like

Dug into this. The docker build process seems good, but it only works for the simplest cases. Even for common gems like mysql, it doesn’t work. You’ve got to deal with the quirks of each gem’s libraries development headers and confirm each one individually works. When the libraries change, you have to figure it out all over again. It would be ongoing issues and maintenance. So it’s not as simple as it might seem.

A better solution is Custom Lambda Layers. You can add your own Custom Lambda Layer to a Jets application. It provides full control over the build process. Use Docker, Firecracker (the actually microVM that AWS lambda uses), EC2, or whatever to build the Lambda Layer. It’ll work with the specific libraries and quirks for your application. Jets adds the Lambda Layer to the functions. It’s a nice simple way of handling it. Think this is why AWS has chosen to do it this way.

Disclosure: Think that the Lambda Gems service is the most friendly manner to handle this for Jets user. It saves people time. Lambda Gems is a considerable amount of work which is why it will have a partially paid service model. Hopefully, it helps to support Jets development also. Lambda Gems is currently in beta. Over time, if Lambda Gems is supported and grows, think it will become rarer for people to have to use a Custom Layer, which is great for the Jets user experience. Lambda Gems cannot handle every case though. That’s why there are Custom Lambda Layers also. Eventually, think will also add general build hooks so users can call out to whatever build process they wish.