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
已提问 1 年前399 查看次数
2 回答
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
已回答 1 年前
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
已回答 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则