My project is in python, using poetry
.
So far, my package is too big (> 300 Mb zipped!) and I went to investigate. I found in my sls zipped package files like:
skimage/morphology/tests/__pycache__/__init__.cpython-38.pyc
I’ve added to my serverless.yml
, so far:
package:
patterns:
- '!node_modules/**' # by try-and-error I know this one work for sure and so others similar
- '!test/**'
- '!**/test*/**' # but, this one?
- '!docs/**'
- '!dist/**'
- '!tools/**'
- '!__pycache__/**'
- '!**/__pycache__/**'
- '!.mypy_cache/**'
- '!integration_test/**'
- '!my_pkg*/**'
- '!*pytest_*'
- '!*.pyc'
I really hoped at least - '!*.pyc'
could work but, alas, no!
What patterns above do work, should work and definitely won’t work?
Could Serverless Framework Guide - AWS Lambda Guide - Packaging be improved?
Why not make use of a plain simple .ignore
file? A property that could be added to the serverless.yml
that, hopefully, wil work.
Could it be that package.patterns
don’t work for the requirements
?
Because I’ve cleaned $HOME/.cache/serverless-python-requirements/*
and find-and-remove *.pyc
, __pycache__
etc. and that seemed to have made a difference in my pkg size which is down to 100 Mb.
Last but not least. Serverless is a FANTASTIC stuff take tons out of ours shoulders when dealing with the horrible AWS services.