I'm looking for recommandations about the best way to deploy updated versions of a Node.JS application when using multiple instances spawned by auto-scaling.
My code is hosted on GitHub, usual deployment was made using GitHub Actions, pushing the updates and triggering install/db updates after CI on specific hosts.
Now that my instances are "variables", I was thinking of some kind of polling at a regular interval, but this solution isn't appropriate because it breaks the usual CI process.
Did you have any good practices to setup all this properly ?
You can add the script in user-data section to update or perform any init process.
Your instance should be able to pull code from Github and the init script will perform the necessary operation. Note: The user-data script will only execute once new instance spawned from the auto-scaling group.
For example
#!/bin/bash
cd /app;
git pull;
npm install;
pm2 start myapp.js