## Scripts

scripts for dev / ops etc.
/bin is for app stuff (eg. cron jobs etc)
this directory is for scripts to help deploy or provision etc.

### The following are some commands to run

ecs-cli configure --profile default --cluster tracker

  - configures the ecs cli on the server to orchestrate ecs.  the cluster wil be called
    tracker .  the profile is the deafult aws profile created by aws configure

aws configure
  - if you haven't already

ecs-cli up --capability-iam --size 1 --instance-type t2.small --keypair tracker_key
  - create the cluster with a single t2.small ec2 instance  the iam thing means it
    will create iam stuff.  note the user the runs this command needs a lot of
    permissions, a lot!  I think I ended up making them full administrator after
    playing whack-a-mole for an hour or so.

aws ec2 create-key-pair --key-name tracker_key --query 'KeyMaterial' --output text > tracker.pem
  - create a new key pair that amazon knows about.  I don't know what the query is.
    the name is unique and then used to refer to when creating the cluster

ecs-cli push tracker
  - push to the ecr. tracker is the image name, which gets converted to the aulified
    version.  this ualified name is what needs to be used in the docker compose file

docker build -f docker/Dockerfile -t tracker .
  - build the docker image fro mlastest code.  run this from the /tracker dir.

docker tag tracker 322697034778.dkr.ecr.eu-west-1.amazonaws.com/tracker
  - tags the image with the ecr tag (so that we can refer to it locally the
    same way we will in the aws task definition.

docker-compose -f docker/docker-compose.yml up
  - run the image locally with docker compose

aws ecs run-task --cluster tracker --task-definition tracker-canada --count 1 --overrides '{"containerOverrides":[{"name":"tracker", "cpu": 100, "memoryReservation": 256, "command":["/tracker/bin/launch.py", "heartbeat"]}]}'
  - run a one-off task, overriding the cpu and memory (so that it will go on the cluster)

pip install ecs-deploy
  - the ecs deployer of choice

ecs deploy tracker tracker-canada
  - update to the latest tracker image for the 'tracker-canada' service

ecs deploy tracker tracker-canada \
    -e tracker PYTHONUNBUFFERED 1 \
    -e tracker SOME_VARIABLE2 SOME_VALUE2
  - deploy and change / add an environment var

./scripts/build_and_push.sh
  - build and tag the image and push to the ECR repo



AWS_PROFILE=whtlst npm run deploy
  - deploy front end