Day 4 of 5
⏱ ~60 minutes
Docker and Cloud for AI — Day 4

Deploying to AWS: ECR, ECS, and App Runner

Day 4 deploys your containerized AI app to AWS. You will push your image to ECR and run it on App Runner — the simplest production-grade deployment on AWS.

The Deployment Pathway

Local container → Push to AWS ECR (Elastic Container Registry) → Run on AWS App Runner. No servers to manage, automatic scaling, SSL included.

Terminal — Setup AWS CLI
# Install AWS CLI
brew install awscli  # macOS
# or download from aws.amazon.com/cli

# Configure with your credentials
aws configure
# Enter: Access Key ID, Secret, Region (us-east-1), format (json)
Push to ECR
# Create ECR repository
aws ecr create-repository   --repository-name my-ai-app   --region us-east-1

# Get login token (replace ACCOUNT_ID and REGION)
aws ecr get-login-password --region us-east-1 |   docker login --username AWS   --password-stdin ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com

# Tag and push
docker tag my-ai-app:latest   ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/my-ai-app:latest

docker push   ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/my-ai-app:latest
Deploy to App Runner (AWS Console)
# In AWS Console:
# 1. Go to App Runner → Create service
# 2. Source: Container registry → Amazon ECR
# 3. Select your image URI
# 4. Port: 8000
# 5. Environment variables:
#    ANTHROPIC_API_KEY = your_key
# 6. Deploy

# App Runner gives you a URL like:
# https://abc123.us-east-1.awsapprunner.com
ℹ️
AWS Free Tier: App Runner charges ~$0.064/vCPU/hour and $0.007/GB/hour. For a low-traffic chatbot, monthly costs are typically under $10. Set a billing alert at $20 to avoid surprises.
Day 4 Exercise
Deploy to AWS App Runner
  1. Create an AWS account if you don't have one.
  2. Install and configure the AWS CLI with your credentials.
  3. Create an ECR repository and push your image.
  4. Create an App Runner service pointing to your ECR image.
  5. Set your ANTHROPIC_API_KEY as an environment variable and deploy.
  6. Test the live URL with a curl request.

Day 4 Summary

  • ECR stores your Docker images in AWS. App Runner runs them without managing servers.
  • Never put API keys in the image — pass them as App Runner environment variables.
  • App Runner handles SSL, load balancing, and auto-scaling automatically.
Finished this lesson?