Comments (6)
@jamespegg Yes! I used this along with the serverless simulate plugin. I looked at what made the run and build images they have different and used the code from serverless-python-requirements to figure out what to do. Eventually I came up with this docker file which pulls from the build image.
FROM lambci/lambda:build-python3.6
RUN pip3 install elasticsearch
RUN rm /var/runtime/awslambda/runtime.cpython-36m-x86_64-linux-gnu.so
COPY runtime-mock.py /var/runtime/awslambda/runtime.py
#USER sbx_user1051
ENTRYPOINT ["/var/lang/bin/python3.6", "/var/runtime/awslambda/bootstrap.py"]
You will have to get the runtime.py file from here
With this file in your current directory and same with the Dockerfile above you can docker build give the new docker image a name and tada you will have a docker image. To user this with serverless simulate specify the name of the new image as the run time for the function.
from docker-lambda.
@rodrigjg Awesome, that worked! I had to prepend the Docker tag with lambci/lambda:
and then it worked.
I also updated the pip
installation to use a requirements.txt
file, so it looks like this;
COPY requirements.txt /tmp/requirements.txt
RUN pip3 install -r /tmp/requirements.txt
Have you thought about suggesting a documentation change to the serverless simulate plugin to cover this use case? It really helped me out and I'm sure we're not the only ones with this problem. :)
from docker-lambda.
@rodrigjg Did you manage to figure how to do it?
from docker-lambda.
I know this is closed but thought I'd share - found this tool that does the "packaging" for you so you don't have to build your own docker file and docker-based (no need for node). Just reads the requirements file and puts everything in your working dir. I found this to be a little easier to insert into my workflow:
https://github.com/myrmex-org/docker-lambda-packager
from docker-lambda.
@mrpatrick there's no need for node βΒ that's only required if you want to use the test runner.
from docker-lambda.
Hey, I went able to make it work with the answer above. However I had to spend some time to understand what are those steps to create the docker image because I didn't had nice docker knowledge.
So if somebody comes here with the same problem just run the following command in your root directory to build the docker image:
docker build . -t lambci/lambda:MY-CUSTOM-TAG
Where "MY-CUSTOM-TAG" is the custom tag name I should use in the runtime. Then just update the runtime configuration in the serverless.yml:
Notice "lambci/lambda" isn't necessary in the runtime configuration.
from docker-lambda.
Related Issues (20)
- Missing files from provided.al2 HOT 1
- Need support for python3.9 HOT 10
- nodejs16.x support HOT 6
- Golang update to 1.17 HOT 1
- Is java11 image on AL2 and Corretto?
- How can I build image for python3.9 runtime? HOT 4
- Help with Debugging Go Lambda HOT 1
- Rebuild images? HOT 2
- What is the status of this project? HOT 7
- Make `myfunction` and `9001` configurable?
- Support for Node 14.x? HOT 1
- Boto3 and botocore need upgrading HOT 5
- Require image for ARM64 architecture
- Support for .NET 6
- Multi-arch support specially arm64 HOT 1
- Current ruby release (v2.7.2p137) out of date (now v2.7.6p?) HOT 1
- Missing .py file causing attributeError on lambda
- Jenkins agent install on lambci/lambda:build-python3.7 HOT 2
- Debugging with Pycharm
- [Question] Support for Provided Runtimes (Namely C++)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docker-lambda.