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
질문됨 일 년 전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
답변함 일 년 전
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
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠