Giter Site home page Giter Site logo

Comments (6)

josephjohansson avatar josephjohansson commented on July 24, 2024 2

@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.

jamespegg avatar jamespegg commented on July 24, 2024 1

@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.

jamespegg avatar jamespegg commented on July 24, 2024

@rodrigjg Did you manage to figure how to do it?

from docker-lambda.

mrpatrick avatar mrpatrick commented on July 24, 2024

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.

mhart avatar mhart commented on July 24, 2024

@mrpatrick there's no need for node – that's only required if you want to use the test runner.

from docker-lambda.

brq-cr avatar brq-cr commented on July 24, 2024

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:

screen shot 2018-10-03 at 2 08 58 pm

Notice "lambci/lambda" isn't necessary in the runtime configuration.

from docker-lambda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.