Strider CI on AWS EC2
Part 1: Strider Setup
This guide will show you how to run Strider Continuous Deployment server on AWS EC2 Ubuntu instance.
Before you proceed, and if you haven't done it yet, go ahead and create yourself an Ubuntu 14.04 LTS 64bit server.
Configuring DNS to point to
ci.your-server-name.com domain is not necessary but doing it will make your life easier. If you are with AWS go ahead and use Route53 service to do so before proceeding.
SSH to your server using .pem keys. If you need help with that you can take a look at ssh configuration with .pem keys.
Host name update
/etc/hostname appending server hostname to the top 127.0.0.1 line to prevent from
sudo from throwing errors.
You can check host name running
hostname bash command.
Run below script to install gcc compilers, node, update npm and install git
curl -L https://gist.githubusercontent.com/indieforger/20e345cf9dff308a7392/raw/setup-node-webserver.sh | bash
Install MongoDB as well
curl -L https://gist.githubusercontent.com/indieforger/20e345cf9dff308a7392/raw/install-mongodb.sh | bash
Strider can be installed with npm so go ahead and do so.
npm install -g strider
sudo service mongod start
We are going to create separate deployment user called
strider as both system and application user. It is always good idea to do so. Deployment user should have minimal required privileges to reduce the risk of compromising the system.
Sole responsibilty of system deployment user is running CI server. It doesn't need to have neither home directory or tty. Lets go head and create system user called
sudo adduser --system --no-create-home strider
We also need application user, run below command and follow instructions. Put details you will want to use to log into strider.
Strider mongodb user
We are going to skip this step for now for simplicity. However, if CI server is exposed publicly, securing mongodb is always a good idea.
Strider builds directory
Strider will need a directory to store all project build files. Let's call it
strider-builds and put it in our home directory.
mkdir -p /home/ubuntu/strider-builds
Port 80 redirection
Instant iptables update
Redirect all traffic from port 80 to 3000 - default strider port.
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
iptables update after system reboot
/etc/rc.local file and add below line to setup redirection after instance boots up.
Note: Same as above but without sudo.
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
PM2 is great process manager with awesome logging capabilities.
npm install -g pm2
Start strider with pm2
Now, you should start strider with some environment properties.
NODE_ENV="production" \ SERVER_NAME="http://ci.your-server-name.com" \ STRIDER_CLONE_DEST="/home/ubuntu/strider-builds/" \ pm2 start strider
Save PM2 configuration.
You can now navigate to
http://ci.your-server-name.com and log into Strider.
PM2 auto start after reboot
PM2 comes with
startup command that will help you to auto start pm2 start after system reboot.
pm2 startup ubuntu
It should output something like below, so just follow these instructions.
# [PM2] You have to run this command as root. Execute the following command: # sudo su -c "env PATH=$PATH:/usr/bin pm2 startup linux -u ubuntu --hp /home/ubuntu"
Now you should be able to restart the server.
Wait a minute or two and refresh your Strider in your browser.
Published by IndieForger