This is part two of the Roll your own PaaS tutorial.
Part 1 - Create a Droplet (VPS)
Part 2 - Install & Configure CapRover
1. Setup CapRover
Now that most of the hard work is done and we have a DigitalOcean droplet setup and running with a Firewall and CapRover installed, we need to finish the CapRover setup.
To do this open up your favourite CLI (I'll just use Terminal on Mac). Assuming you have npm installed on your local machine (e.g., your laptop), simply run (add sudo
if needed):
npm install -g caprover
After that has installed, run:
caprover serversetup
You'll be asked a series of questions. Just follow the onscreen prompts.
It will ask for your Droplet's IP address, the domain name we created in Step 1 (i.e - paas.mydomain.com
), a new admin password, an email address for Let'sEncrypt SSL certificates, and finally the hostname of our VPS (in my case it is demo-vps).
You'll get a success message and the URL to login (https://captain.paas.mydomain.com
)
Congratulations
CapRover is now installed and you can access the dashboard via your domain.
2. Captain Definition File
Each of our app(s) requires a definition file. An app in CapRover is a container that will hold anything from HTML/PHP/Node code through to your Database. A definition file sits at the root of your project and it simply tells CapRover what you'd like to run.
For example, in a NodeJS app it sits next to package.json, (or next to index.php in case of PHP). It's a simple JSON called captain-definition and looks like this:
{
"schemaVersion": 2,
"templateId": "node/8.7.0"
}
schemaVersion
is always 2.
templateId
is the piece which defines the foundation you need in order to run your app. It is in LANGUAGE/VERSION
format. LANGUAGE can be one of these: node
, php
, python-django
, ruby-rack
. And VERSION is the version of the language you want to use.
There is a sample NodeJS app here so that you can see the file structure.