• Install AWS CLI:

    • AWS CLI: https://aws.amazon.com/cli/
    • After installation, authenticate to an admin account or an account with ECR permissions: https://docs.aws.amazon.com/cli/v1/userguide/cli-chap-authentication.html
  • From the AWS console, create an ECR repo (private) for each app / GitHub repo on a region (us-east-1)

  • From the local machine, build each Docker image, tag them with AWS tags, then push to ECR (Push commands are available at console)

    • It is recommended to build images for multiple platforms: linux/amd64 and linux/arm64, as EC2 instances come with different types.
      • For example, t3a instances use amd64 CPU, while t4g ones use arm64 CPU.

      • Using amd64 images on a t4g.micro instance cause lower performance

      • Some AWS instance types use AWS’s own processor - Graviton: https://aws.amazon.com/ec2/graviton/

        → Better and cheaper instance types, but because it is ARM-based, so image platform must be considered

    # Make sure AWS CLI is installed and authenticated, login docker to ECR
    aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <aws_id>.dkr.ecr.us-east-1.amazonaws.com
    
    # Navigate to each app repo, build & tag the image, then push it to AWS
    docker build -t mortredn/eks-demo-coffeeshop-frontend:latest .
    docker tag mortredn/eks-demo-coffeeshop-frontend:latest <aws_id>.dkr.ecr.us-east-1.amazonaws.com/mortredn/eks-demo-coffeeshop-frontend:latest
    docker push <aws_id>.dkr.ecr.us-east-1.amazonaws.com/mortredn/eks-demo-coffeeshop-frontend:latest
    # Or building for multi-platform and pushing straight to AWS, use buildx
    docker buildx build --platform linux/amd64,linux/arm64 -t <aws_id>.dkr.ecr.us-east-1.amazonaws.com/mortredn/eks-demo-coffeeshop-frontend:latest --provenance=false --push .
    

    image.png