serverless-python-requirements
serverless-python-requirements copied to clipboard
Enable multiple Docker images
We are in a usage scenario where we have an extensive AWS Lambda stack with various large Python dependency packages. To speed up turnaround time, we're trying to move the various setups into dockerized environments both for local testing (using https://github.com/lambci/docker-lambda) and for build purposes.
For our use-case, it would be ideal if we could specify multiple docker images, or define them at the level of the function versus at the level of the service.
I'm wondering if there are more people that face the same use-case. I know there's the option to directly deploy images for lambda to AWS ECR, but I'd like to make use of all the smart slimming down features etc in this existing repo that greatly help to reduce the size of the package.
I'm thinking that somewhere around here in the code, it should be possible to use the module-level as a source for the image name, rather than the service level?:
https://github.com/UnitedIncome/serverless-python-requirements/blob/891a53847e0053ce69f959e27830cd4859f932a0/lib/pip.js#L198-L200
Upon closer look, it's possible to hack something into the pip.js that uses the Modulepath as a proxy for the name, which can be used to dynamically define a docker image there.
However, pre-installed dockers run into an additional problem as the rest of the flow requires a volume mount of /var/task
. In other words: you're mounting a local /var/task/
over the directory in which you preloaded everything in the build-image, defeating the purpose.
Maybe there's not much time to be gained here than simply using the cache options?