Skip to content

MrHassanMurtaza/deploy-python-flask-app-with-ecs-fargate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Learn to deploy Python Flask App using Docker, AWS ECS and AWS Fargate.

Deploy Python App using ECS Fargate

→ Use Docker to Deploy Flask App

  • Clone this project
  • Move to project directory
  • Run this to build the image:
docker build -t flask-demo-app .
  • Now we need to run the container from image. Run this command:
docker run -it -p 5000:5000 flask-demo-app:latest
  • You should be able to open the flask app in browser using:
http://localhost:5000

→ Use ECS Fargate to Deploy Flask App

  • Create Repository in Elastic Container Registry (ECR):

aws ecr create-repository --repository-name demo-flask-app

  • Get a command you can use for logging in to the ECR repository you’ve just created:

aws ecr get-login --region $YOUR_REGION --no-include-email

  • Let's put our local docker image to ECR (ACCOUNTID is your account id and REGIONNAME is your region):

docker tag flask-demo-app:latest ACCOUNTID.dkr.ecr.REGIONNAME.amazonaws.com

  • Go to ECS. Create cluster and click on get started

Create ECS Cluster

  • Write container name and give the link to the docker image and you uploaded in the preivous steps. You should be able to get it from ECR as well.

Enter ECR Image

  • Click on next

Task Definition

  • Make sure the service has ecsContainerRole Click on next

Service Definition

  • Click on next

Configure Definition

  • Finally, Review and create the cluster

Review Cluster

💯 Yay! You'll see the success message

About

Deploy Python flask with ECS Fargate

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published