Introduction
Strider CD is an open source continuous deployment platform. The application is written in Node.js and uses MongoDB as a storage backend. Strider is backed by many plugins which add various features to the application.
Requirements
- Fresh Rcs Ubuntu 18.04 instance with at least 1 GB RAM.
- Non-root user with sudo privileges.
Ensure that your system is up to date.
sudo apt-get update && sudo apt-get upgrade -y
Step 1: Install Node.js and NPM
Nodesource provides pre-built binaries for Node.js, which can be installed directly using the OS package manager. Configure the Nodesource repository.
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
Install Node.js.
sudo apt-get install -y nodejs
Node.js also installs NPM along with it. Ensure that Node.js and NPM have installed successfully.
strider@vultr:~$ node -v
v10.15.3
strider@vultr:~$ npm -v
6.4.1
Step 2: Install Git and node-gyp
Git comes pre-installed in most Rcs instances. However, you can make sure it's installed and updated.
sudo apt-get install -y git
Install node-gyp
, which is a Node.js native add-on build tool.
sudo npm install -g node-gyp
Step 3: Install MongoDB
Import MongoDB public GPG key to ensure unaltered packages are being installed.
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
Add MongoDB repository file.
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
Update the system repository cache and install the latest MongoDB.
sudo apt-get update
sudo apt-get install -y mongodb-org
Start MongoDB and enable it to automatically start at boot time.
sudo systemctl start mongod
sudo systemctl enable mongod
Step 4: Set up MongoDB Authentication
Open the MongoDB shell by running the mongo
command. You will see the following output.
strider@vultr:~/strider$ mongo
MongoDB shell version v4.0.8
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("a06b2797-6f58-43e1-8a41-c6401edb5083") }
MongoDB server version: 4.0.8
Welcome to the MongoDB shell.
...
Switch to the admin
database.
use admin
Create an admin user. Make sure to replace username admin
and password StrongPassword
with your preferred choice.
db.createUser(
{
user: "admin",
pwd: "StrongPassword",
roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]
}
)
Quit the Mongo shell by pressing Ctrl+C.
Open the configuration file.
sudo nano /etc/mongod.conf
Find the line with the commented word #security:
and replace it with the following text.
security:
authorization: "enabled"
Save the file and exit the editor. Restart the MongoDB server.
sudo systemctl restart mongod
Step 5: Install Strider
Clone the Strider repository from Github.
cd ~
git clone https://github.com/Strider-CD/strider.git
Install Node.js dependencies.
cd ~/strider
npm install
Login to the Mongo shell once again to create a database for Strider.
mongo
Authenticate your Mongo session with the credentials you created earlier.
use admin
db.auth("admin", "StrongPassword" )
Create a new database user for Strider and assign it to database name strider
. Make sure to change the password striderpw
in the command below.
use strider
db.createUser({user: "strider", pwd: "striderpw", roles: [{role: "dbOwner", db: "strider"}]})
Quit the Mongo shell by pressing Ctrl+C.
Create an administrator user for Strider by running the following command.
DB_URI="mongodb://strider:striderpw@localhost:27017/strider" node bin/strider addUser
Provide the requisite information asked by the script. You will be asked for your email address and a new password.
strider@vultr:~/strider$ DB_URI="mongodb://strider:striderpw@localhost:27017/strider" node bin/strider addUser
Connecting to MongoDB URL: mongodb://strider:striderpw@localhost:27017/strider
Enter email []: vultr@example.com
Enter password []: ****
Is admin? (y/n) [n]y
Email: vultr@example.com
Password: ****
isAdmin: y
OK? (y/n) [y]y
User created successfully! Enjoy.
Step 6: Manage Node.js Process with PM2
Install PM2 using NPM.
sudo npm install pm2 -g
Create a PM2 configuration file for your Strider app.
cd ~/strider && nano ecosystem.config.js
Populate the file with the following configuration. Make sure to replace the example IP 203.0.113.1
with the actual IP address of your Rcs instance.
module.exports = {
apps : [{
name : "strider",
script : "npm",
args : "start",
env: {
"NODE_ENV": "production",
"DB_URI": "mongodb://strider:striderpw@localhost:27017/strider",
"SERVER_NAME": "http://203.0.113.1:3000",
"HOST": "0.0.0.0",
"PORT": "3000"
}
}]
}
Start your application.
pm2 start ecosystem.config.js
To make sure that your Strider instance automatically starts after rebooting, run the following command.
pm2 startup
Open your browser and navigate to http://203.0.113.1:3000
where 203.0.113.1
is your actual Rcs IP address. Login using the admin user you've created for Stride.