Deploying to multiple instances

nodejs
aws

#1

I’m on my way to understand and configure continuous deployment system and I want to deploy the same repo to multiple EC2 instances using ssh. I have docker between circleCI and AWS so first I should make a container images and then deploy it to the multiple instances.

Questions:
1)What should I write in circle.yml and .sh file to deploy same webservers to two EC2 instances?
2)How can I deploy parts of repo to different instances? (I’m going to have nginx load-balancer on one server and two nodeJS servers on two other instances.)


#2

This is a very broad question—the answers would depend on your exact workflow, but a few ideas below.

The circle.yml file’s content is plain bash, so you could write something like this:

deployment:
  production: # just a label
    branch: master
    commands:
      - for s in server1 server2 server3; do scp production-image.tar.gz $s.example.com:~/new/production-image.tar.gz; done

If you are copying two different images:

deployment:
  production: # just a label
    branch: master
    commands:
      - scp production-image-1.tar.gz server1.example.com:~/new/production-image.tar.gz
      - scp production-image-2.tar.gz server2.example.com:~/new/production-image.tar.gz

Does that make sense?


#3

Yes, that make sense. I know a few bash commands. Thanks.


#4