Skip to content

Instantly share code, notes, and snippets.

@Ravenstine
Created September 8, 2016 16:27
Show Gist options
  • Save Ravenstine/b92706816241639787e0651e6daff125 to your computer and use it in GitHub Desktop.
Save Ravenstine/b92706816241639787e0651e6daff125 to your computer and use it in GitHub Desktop.
KPCC Audiogram Deployment

Deployment

Prerequisites:

  • Docker w/ running docker-machine
  • brew install awscli

Instructions

  1. If you haven't already, run aws configure and enter your access ID and access secret, a long with us-west-1 as the region. Then initialize your environment by running eval $(docker-machine env default) and eval $(aws ecr get-login --region us-west-1). It may be wise to place those last two commands in your ~/.bash_profile if you are going to be interacting with Docker and Amazon ECS a lot.

  2. You will then need to either build a Docker image, as seen in the [installation instructions], or pull an existing image like so:

docker pull audiogram:<revision name> <docker repo uri>

It is recommended that you pull from the git repo and build your own image.

  1. Once changes have been made, you will need to tag the image.
docker tag audiogram:latest <docker repo uri>

By default, the revision name "latest" should be used.

  1. Push it to the repo:
docker push <docker repo uri>

Updating the server

We use Amazon Elastic Container Service(ECS) to run Docker containers in a cluster. A "task" is used in ECS to run the configuration to deploy a new image. Tasks are continually-running until you kill them.

  1. Look for any running tasks on our cluster:
aws ecs list-tasks --cluster audiogram
  1. Kill the running task(s) by id:
aws ecs stop-task --cluster audiogram --task <task id>
  1. Run a new task:
aws ecs run-task --cluster audiogram --task-definition audiogram-app:2

The task definition, in this case, is always audiogram-app, though the revision # may be different. At the time of writing this, the latest revision for that task is 2

In case of failure

Killing the deployment task and starting a new one, as seen above, is the first avenue to resolving a failure. If that doesn't work, the next step would be to kill all the instances by "scaling down" in the AWS ECS interface, and then scaling back up to 1 or more instances. You could always restart the instance manually, though scaling would seem to be the preferred way as that would also clear out any health problems recorded by the load balancer. Also be sure to check that the load balancer isn't always considering your instances as "OutOfService", as that's either a sign that the load balancer settings are incorrect or that there's something seriously wrong with the Docker images being deployed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment