How should I customize a Docker container Image to run it on Lambda function

0

I have a docker image that is stored in ECR and works perfectly when it's deployed on ECS. Now, I deployed this same image on lambda but gives me the following on test result: { "errorMessage": "2022-12-27T15:04:49.710Z ce12da2d-a733-4779-b8df-aa30f0b84ac9 Task timed out after 180.10 seconds" }

Here is the log output on testing INFO Accepting connections at http://0.0.0.0:8080

Here is what I have on my dockerfile:

  • FROM node:carbon as builder
  • ENV NODE_ENV=PRODUCTION
  • WORKDIR /app
  • COPY package.json ./
  • RUN npm install --production
  • COPY . .
  • RUN npm run build
  • FROM node:14-alpine
  • RUN npm -g install serve
  • WORKDIR /app
  • COPY --from=builder /app/build .
  • CMD ["serve", "-p", "8080"]
Ellon
asked a year ago399 views
2 Answers
0

It looks like your default runtime for your lambda function needs to be increased. Have you tried this yet? By default lambda has a timeout of 3 seconds. You may need to increase that to account for the build process. you can also check to see if the resource limits (cpu/memory) are getting maxed out in lambda. if so, you can increase those as well. Also have you considered launching in fargate rather than ECS if you are looking for a serverless approach?

Cloud_G
answered a year ago
0

You can't use the same container image for ECS and Lambda. Container images for Lambda have to implement Lambda Runtime API. There are many open source implementations for various programming languages.

Please refer document https://docs.aws.amazon.com/lambda/latest/dg/images-create.html for more information.

AWS
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions