REBELinBLUE / deployer

Deployer is a free and open source deployment tool.
http://phpdeployment.org
MIT License
912 stars 185 forks source link

Support for Amazon Aws AutoScale Servers #367

Open aftabnaveed opened 6 years ago

aftabnaveed commented 6 years ago

We have an application running on Amazon AWS which has Amazon AutoScale enabled. Every few days old servers are terminated and new servers are spawned. The biggest problem we have is to deploy the latest code on the newly spawned servers. Currently, we are using Amazon CodeDeploy agent along with bitbucket which automatically pulls the bitbucket code and deploys it.

My question Is there a way to automatically deploy code to the servers created automatically by Amazon AWS's autoscale policy? Is there any artisan command which can be executed to deploy the latest build after server launch?

REBELinBLUE commented 6 years ago

Is this spinning up additional instances with new IP addresses, or is it spinning up new instances with more resources and replacing the old ones with the same IP addresses?

If it is the former I don't think deployer would work without a lot of work as the server would need to be configured in the project.

The latter would in theory work because deployer has a webhook you could call, but it would also require some work. You could set it up to notify an SNS topic when autoscaled https://docs.aws.amazon.com/autoscaling/ec2/userguide/ASGettingNotifications.html then you'd need a simple node worker subscribed to the topic which could call the webhook. Unfortunately the issue I can see is unless they have fixed public IPs before they replace the existing instance (which I assume they won't) you'd hit the same problem as in the first scenario

aftabnaveed commented 6 years ago

The Autoscale servers unfortunately does not have static IP addresses and Amazon assigns a new IP address to the newly spawned server. I know it is a bit tricky to pull the latest code because deployer seems to be based on push model. I do have a suggestion and I am not sure if it would work but I will throw it any way here:

Why not create a worker for deployer and run it on the newly spawned server. The worker listens to the deployer webhooks and pulls the code as soon as the code is pushed to the repository. I may need to add some additional info to support my suggestion but I would like to hear your initial thoughts on this?

skyrpex commented 6 years ago

Not sure if Deployer has an API? I guess not, because you could use it to add/remove the servers and trigger a deployment.

REBELinBLUE commented 6 years ago

At present deployer doesn't have an API, it is on my list and in theory should be fairly simple as most endpoints are simple JSON endpoints anyway as creating/updating/deleting is all done via AJAX. Unfortunately I am not sure when I will get a chance to work on deployer at the moment.

@aftabnaveed I'm not sure I understand, if there is a worker on the server which listens for git pushes how will that trigger a deploy when a new instance is spawned?