Skip to content

Latest commit

 

History

History
106 lines (67 loc) · 3.65 KB

deployment_notes.md

File metadata and controls

106 lines (67 loc) · 3.65 KB

Working Deployment Notes

Steps for deploying a basic Rails project using AWS Fargate

  • Dockerize the project
  • Create an Amazon ECR Repository
  • Push the Docker image to Amazon ECR
  • Create a Task Definition
  • Create a Cluster
  • Create a Service
  • Create a Task
    • Dockerize the project

      Update the Dockerfile.

      Run

      docker build . -t retrofit
      docker run -p 3000:3000 retrofit
      

      Check it's up and running at http://localhost:3000.

      Create an Amazon ECR Repository

      In the AWS console go to ECR Private Repositories, click 'Create Repository' to create a new private repository.

      (See AWS documentation)

      Push the Docker image to Amazon ECR

      Authenticate your Docker client to the ECR registry

      aws ecr get-login-password --region <region> | docker login --username AWS --password-stdin <aws_account_id>.dkr.ecr.<region>.amazonaws.com

      Tag the Docker image with the ECR repository URI

      Run docker images to get the image id.

      Get the ECR repository URI from the AWC ECR console.

      Tag the docker image:

      docker tag <image_id> <repository_uri>:<optional_tag>

      Push the Docker image

      docker push <repository_uri>:<optional_tag>

      (See AWS documentation)

      Create a Task Definition

      • In the AWS Console go to ECS Task Definitions and click 'Create a new task definition'.
      • Under 'Launch Type' check 'AWS Fargate'.
      • Under 'Operating system/Architecture' select 'Linux/ARM64'
      • Set desired CPU and Memory.
      • Under 'Container', enter a container name and your ECR repository URI. Then click 'Docker configuration' and under 'Command' enter bundle,exec,rails,server.
      • Click 'Create'

      Create a Cluster

      • In the AWS Console go to ECS Clusters and click 'Create cluster'.
      • Under 'Infrastructure' check 'AWS Fargate (serverless)'
      • Click 'Create'

      Create a Service

      In ECS Clusters click on your cluster name.

      • In the 'Services' tab click 'Create'.
      • Under 'Networking' select default VPC.
      • Under 'Subnets' select one of the default subnets.
      • Click 'Create'.

      Create a Task

      • Go back to your cluster (ECS Clusters and click on your cluster name.)
      • In the 'Tasks' tab click 'Run new task'.

      TBC!

      Glossary

      • Cluster is a logical way to group services and task definition.

      • Services are used to run load balancers in front of group of tasks. This is also where you specify how many instances of task should be running.

      • Tasks are the running instances of a task definition.

      Resources

      Useful blog post on deploying with Fargate