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 Answer
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
EXPERT
GK
answered 16 days ago
profile picture
EXPERT
reviewed 16 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions