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 Risposta
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
ESPERTO
GK
con risposta un mese fa
profile picture
ESPERTO
verificato un mese fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande