docker build -t ezw .<\/pre>\nBuild the image, yeah, we did it before.<\/p>\n
docker tag ezw:latest 4__________6.dkr.ecr.us-east-2.amazonaws.com\/ezw:latest<\/pre>\nTag our docker image with your own AWS id (4__________6 in my case).<\/p>\n
docker push 4_________6.dkr.ecr.us-east-2.amazonaws.com\/ezw:latest<\/pre>\nJust push tagged image to the ECR! \nAfter that, our image is stored in the ECR. Remember to copy the “Repository URI”, we will use it in our next step.<\/p>\n
<\/p>\n
<\/p>\n
Launch with Fargate<\/h3>\n We have all our materials ready, now it is time to launch our EZW Flask app globally. We go to the ECS interface again, this time, we click “Clusters” and “Get Started”.<\/p>\n
<\/p>\n
Select “custom” container and press “Configure”<\/p>\n
<\/p>\n
We are going to let Fargate know which docker repository to use. On the “Image” field, let’s copy the “Repository URI” from our previous step to there. (if you forgot the URI, don’t worry, just go to “Amazon ECR” > “Repositories” to find out, it is on the same page as ECS)<\/p>\n
We set a hard memory limit to 128 MiB, as our weather Flask app is just a tiny web app.<\/p>\n
Port mappings is 5000 again as we have already defined it in our Dockerfile.<\/p>\n
<\/p>\n
Since we store our DARK SKY API key in environment variable. We have to set it on the ECS container setting as well. From the “Advanced container configuration”, create a new environment variable, “DARK_SKY_KEY” then enter your API value there.<\/p>\n
<\/p>\n
After that we can use just use the default setting and keep clicking “Next” till Amazon launch our service. We will see a similar screen when the service is ready to launch:\u00a0\u00a0 <\/p>\n
Okay, it is the time we try our EZW Flask App online.<\/p>\n
Try the EZW Flask App Globally<\/h3>\n In order to do it, we need to know the public ip first. Let’s go to “Cluster” > “ezw”\u00a0 (or other cluster name you use for the Flask app) > “Tasks”. Since we have only one task in our EZW cluster, we can click the only task there to see the details. From the “Network” section, we will find the public ip there.<\/p>\n
<\/p>\n
<\/p>\n
Open a browser, copy and paste the public ip there. And don’t forget to add the port number at the end. Here we go:<\/p>\n
<\/p>\n
We did it! We have just deployed our first ever web app on AWS with docker. There are still many things we need to learn and tune in the AWS. Like the maintenance should be cheaper, if we use Amazon EC2 instance instead of Fargate. As we have other pricing options for EC2, like On-Demand and Spot. But Fargate provides us a fast and clean deployment environment, it is good for having a demonstration to your business partners. It can also provide a showcase to your potential employers or audiences on what\u00a0you are capable of, Python, Flask, Docker, ECS and many others.<\/p>\n
<\/p>\n
What have we learnt in this post?<\/h3>\n\nThe way to push docker image to Amazon\u00a0ECR<\/li>\n Usage of Amazon\u00a0ECS<\/li>\n Usage of Fargate<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"We have learnt how to build a\u00a0weather forecast Flask app. We have learnt how to deploy the Flask app to a Raspberry Pi\u00a0using Docker. But we mostly focus on deploying our app in a local machine or a private network. In order to step up our game, we are going to deploy the app globally […]<\/p>\n","protected":false},"author":1,"featured_media":1333,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_newsletter_tier_id":0,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[2],"tags":[94,97,95,68,99,100,96,71,98,60,8,32],"jetpack_publicize_connections":[],"yoast_head":"\n
Amazon Tutorial: Deploy a Flask Docker image in ECS ⋆ Code A Star<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n \n \n \n \n \n\t \n\t \n\t \n