This project was developed using Python Flask for the backend and React.js for the frontend. You can see the below how to containerize these applications and 3 different hosting and distribution solutions.
Run the applications as a container on the local Docker environment using docker-compose.
Run the applications as a container on the AWS Fargate serverless infrastructure using the Elastic Container Service and Elastic Container Registry.
Create a new IAM [User Group] named "ecs-admin" with the following Permission Policies to manage ECS Fargate Cluster;
Create a new IAM [User] and add it to the newly created as "ecs-admin" [User Group] above to manage the ECS Fargate Cluster.
Note:
Get the Access and Secret Keys generated for this user to access AWS using Terraform and manage the ECS Cluster. Please don't forget to set the keys in the "iac/terraform-ecs/terraform.tfvars/" file.
Create a new Elastic Container Registry(ECR) Private Repository to store application Images
Login to ECR Private Repository in the local Docker using the aws-cli;
aws ecr get-login-password --region <region> | docker login --username AWS --password-stdin <account_id>.dkr.ecr.<region>.amazonaws.com
Set the ECR Repository address as a ENV value;
export ECR_REPO="<account_id>.dkr.ecr.<region>.amazonaws.com/<repo_name>"
Build and Push the Image to ECR Private Repository for Python Restapi application;
cd api
docker build -t $ECR_REPO:api-0.0.1 .
docker push $ECR_REPO:api-0.0.1
cd ..
Build and Push the Image to ECR Private Repository for React front-end application;
cd sys-stats
docker build -t $ECR_REPO:client-0.0.1 .
docker push $ECR_REPO:client-0.0.1
cd ..
Build and Push the Image to ECR Private Repository for Nginx proxy server;
cd nginx
docker build --build-arg NGINX_CONF=aws-ecs -t $ECR_REPO:nginx-0.0.1 .
docker push $ECR_REPO:nginx-0.0.1
cd ..
After the creation IAM requirements(Step 1) and ECR Private Repository(Step 2) go to the "iac/terraform-ecs" directory to create Elastic Container Service Cluster and other Services, Components using Terraform;
Go to AWS Fargate - ECS example using Terraform
Deploy the applications as a container and using Nginx Ingress Controller to Kubernetes.