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 Antwort
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
EXPERTE
GK
beantwortet vor einem Monat
profile picture
EXPERTE
überprüft vor einem Monat

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen