DAY 31- Deploy Containerized Functions with ECS – Day Thirty One
100 days of Cloud on GitHub – Read On iCTPro.co.nz – Learn on style-tricks.com
Get the app
Right here Iam utilizing a web site with nginx server to deploy on a container with the assistance of ECR.
Let’s get the info
git clone https://github.com/anuvindhs/CLOUD-is-AWSome.git
Docker
Constructing a docker file
-
Lets construct our NGINX docker file for our web site.
-
upon getting created the docker file contained in the folder, copy-paste the under instructions
FROM nginx:newest
COPY ./ /usr/share/nginx/html/
-
I’m utilizing VScode, test under to grasp the folder construction
AWS Permissions
-
Be sure to have programmatic entry through AWS CLI
-
Full permissions to ECS & AmazonEC2ContainerRegistryFullAccess
ECR
Create a repository
- Goto ECR from AWS console and create a repository
- Create a ECR repo ,i’ve named mine
webapp-ecr-repo
Login to ECR
for those who open the repo, on the right-hand facet you possibly can see an possibility for view push instructions.
Now utilizing AWS CLI login to ECR
aws ecr get-login-password --region xx-xxxxxx-xx| docker login --username AWS --password-stdin xxxxxxxxxx.dkr.ecr.xx-xxxxxx-xx.amazonaws.com
Construct the docker picture
docker construct -t webapp-ecr-repo .
Lets tag our picture with repo identify
docker tag webapp-ecr-repo:newest xxxxxxxxx.dkr.ecr.xx-xxxxxx-xx.amazonaws.com/webapp-ecr-repo:newest
Lets push the picture to the repository
docker push xxxxxxxxxx.dkr.ecr.xx-xxxxxxx-xx.amazonaws.com/webapp-ecr-repo:newest
in case you are utilizing PowerShell on home windows please use home windows instructions to push the picture to the repo.
ECS
Create a cluster
- Goto ECS dashboard and click on Create Cluster.
-
Enter Cluster identify & EC2 occasion sort , am protecting it to t2.micro.
-
Choose the default VPC and Subnets obtainable.
-
Additionally allow Auto assign public IP
- you should utilize default Safety group or create a brand new one or can connect a Safety group which is already created.
- Now click on Create
Creating Job Definition
- Click on on create Job Definition & then choose EC2
- I’m naming mine as
Taskdef-webapp-ecr
-
Replace Job reminiscence to 128 and Job CPU to 1 vCPU, then click on Add Container
-
Add a reputation, mine is
container-webapp-ecr
-
Copy your ECR repo URI from the repository and replace that on the picture coloumn
-
Map your ports, right here its 80:80 ,
Run the Job
-
Choose EC2
-
Choose out Job Definition we created.
-
Choose our Cluster
As soon as the Job is created it is possible for you to to see a Working Standing
for those who navigate to exterior Hyperlink it is possible for you to to see the stay web site.
Congratulations, now you’ve gotten efficiently configured a docker picture which you’ve gotten pushed to ECR and Deployed on a container with ECS.
✅Join with me on Twitter
🤝🏽Join with me on Linkedin
🧑🏼🤝🧑🏻 Learn extra submit on style-tricks.com or iCTPro.co.nz
💻 Join with me on GitHub
