How to build/push and run lambda application to ecr ?

0

I am building a fast api application and containerzing it via Docker ( sample docker file below) . i want to build this image and push it to ecr and point lambda to this image . I'm planning to create lambda, api gateway resources via terraform, which seems straight forward, but to deploy, what would be the best way to build this image and push it to ecr before i create resources like lambda ? I guess it can be part of my CI/CD , build image in github/gitlab ci cd and push it to ecr , as my build process ?

are there any examples/bestpractices or blogs which cover this?

Dockerfile

FROM python:3.10-slim

WORKDIR /app

COPY requirements.txt .

RUN pip install -r requirements.txt

COPY . .

EXPOSE 8080

CMD ["uvicorn", "fastapi:app", "--host", "0.0.0.0", "--port", "8080"]
已提問 1 個月前檢視次數 286 次
1 個回答
0

Hi

You can use multiple ways to do this here are the alternatives you can consider choose the best for your approach.

Build and Push:

  • You can use Gitlab or Github to Build and push to AWS or
  • Consider using AWS Codepipeline with Multiple stages with Source as Github/Gitlab/Codecommit Build With Codebuild and Codedeploy for ECS or EKS

Official Blogs: https://aws.amazon.com/blogs/devops/build-a-continuous-delivery-pipeline-for-your-container-images-with-amazon-ecr-as-source/

https://aws.amazon.com/blogs/devops/integrating-with-github-actions-ci-cd-pipeline-to-deploy-a-web-app-to-amazon-ec2/

profile picture
專家
GK
已回答 1 個月前
profile picture
專家
已審閱 1 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南