Skip to content

Docker Deployment Example: ECS scripts container

Courteney edited this page Mar 21, 2018 · 1 revision

nypl/circ-scripts on ECS

Prerequisites: a local ssh key for AWS use

Creating the Cluster

  1. Navigate to the ECS console on AWS.
  2. Select the "Task Definition" tab from the left-hand menu. Then select "Create New Task Definition".
  3. Set the Task Definition Name (e.g. simplye-circulation-scripts), then scroll down and click the "Add container" button.
  4. Configure the container and select "create" for the Task Definition. Required settings include:
    • Container Name (e.g. circ-scripts)
    • Image: nypl/circ-scripts:<YOUR_TARGET_TAG>
    • Memory Limits: Soft Limit of at least 1536 MiB
    • Essential: checked/true
    • Environment Variables: SIMPLIFIED_PRODUCTION_DATABASE is required. TZ and SIMPLIFIED_DB_TASK are optional.
  5. Navigate to the "Clusters" tab and select "Create Cluster". Select "EC2 Linux + Networking".
  6. Configure and create the Cluster. Suggested settings include:
    • Cluster name (e.g. simplye-circulation-scripts)
    • Provisioning Model: On-Demand instance
    • EC2 instance type: t2.small
    • Number of instances: 1
    • Key pair: your AWS ssh key
    • Appropriate VPC, subnet, security group, and IAM role selections
  7. In your new Cluster's console, select "Create Service".
  8. Configure and create the Service with the following suggested settings:
    • Launch type: EC2
    • Task definition: the name of the task you defined earlier
    • Service name: (e.g. simplye-circulation-scripts)
    • Number of tasks: 1
    • Load balancer type: None
    • Service Auto Scaling: Do not adjust the service's desired count. Upon creation, the task should start automatically.

Updating the container

  1. To deploy a new version, return to your Task Definition and select "Create new revision".
  2. Update the tag on the selected Docker container image (e.g. 2.2.0 -> 2.2.1) and any relevant environment variables before saving the new revision.
  3. Navigate to the Cluster, select your Service, and click the "Update" button.
  4. Update the Task Definition on your Service to have the appropriate new revision number. For example, simplye-circulation-scripts:1 => simplye-circulation-scripts:2. Update the service.
  5. In the Cluster console, navigate to the "Tasks" tab. Stop the running Task, which is the old Task Definition revision. A new Task, with the new Task Definition, should begin automatically.
Clone this wiki locally