Roll your own PaaS - Heroku alternative (Part 2)

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)

:tada: Congratulations :tada: 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.

7 Likes

Thank you so much for taking the time to explain this all so thoroughly, this is going to be very handy as well as a far cheeper alternative to run sites for certain clients. Really appreciate all the effort this would have taken to put together for us.

1 Like

This is indeed very useful tutorial! Explains everything very clear.

Also caprover seems a great solution, we might also add more direct integration in Wappler just as we did with Heroku - so it works out of the box.

5 Likes

Thanks Brad Paul,

Not finished quite yet, Apps are relatively self-explanatory but would be good to expand the tutorial on databases and clustering/scaling.

3 Likes

Happy to hear it, the more info the better, this is going to be so helpful you can even call me Brad, after all he is a cool dude @brad, lol.
I am Paul though, mwahahaha.

1 Like

Oops, lol, my millennial brain hasn’t switched on yet, give it a few hours!

1 Like

Just wanted to add in that I enjoyed this guide, found it useful and would love any more you had/planned if you get time :grin:

1 Like

:+1:

I learned about CapRover not from the Wappler forum, but by studying third-party resources on hosting and managing nodejs applications. The documentation of CapRover itself is very good, and describes all the steps in quite detail. Therefore, I managed to install and make the initial configuration of CapRover according to official documents without any problems. But when I got to the deployment of projects, there were a lot of questions. The deployment methods in the official documents are described in general clearly, but for those who do not have much experience in deploying applications, there will be a great lack of visual examples.

@max_gb which deployment method do you think is optimal if you create an application in Wappler using Docker? Do you make any specific application settings on the CapRover side when deploying the Wappler application? Is it possible to create a target on the Wappler side to make a deployment directly from Wappler?

It would be great if you would supplement the guide with visual examples of app deployment and recommendations for use in conjunction with Wappler. Thank you for your work and help.

Integrating CapRover into Wappler would be a terrific solution. Let me explain why this is so important.

At the moment, the weakest side of nodejs projects, compared to php, is the ease of hosting php projects. Php hosting is everywhere and is very cheap. And if the customer needs hosting at their own facilities, then there are a lot of lamp / wamp solutions that also make the task extremely simple.

I use a $4 hosting service where I can host up to 25 php projects. This is ideal in the development and debugging process. After development, I transfer the project to a hosting solution that is specific to each customer.

With nodejs today, everything is not so simple in terms of hosting. But it is thanks to CapRover that everything can become as simple as with php for absolutely everyone.

I rented an inexpensive VDS server from my hosting for $2.5, put CapRover on it, and now I can host and manage nodejs projects without restrictions in quantity (restrictions only in disk space and power, but at the development stage projects are undemanding). This is even better than the conditions for php.

A CapRover-based solution, or perhaps there are other analogs, is the key to all the doors in hosting tasks. You need the cheapest possible hosting for development without a load? You took an inexpensive VDS/VPS from absolutely any provider, installed CapRover and host your projects. You need solutions for a project with a load? You took a powerful VDS/VPS from a reliable provider, installed CapRover and deployed the project. The customer wants the application to be hosted on their own server? No problem, install CapRover and deploy the project on the customer’s server. At the same time, everything is simple and clear. And accessible to everyone. Absolute freedom and maximum flexibility.

This is why I believe that CapRover (or an analog) so important to Wappler and the integration would be very useful to absolutely all users.

4 Likes

So, at this point, I’m stalled on deploying the app using Docker in CapRover. If I don’t use Docker Hub, how do I deploy the app from my computer?

Can I somehow create a target in Wappler and upload the app images to the server via Wappler?

Or do I need to manually save the images to disk and then import them to the server?

If only the latter option is possible, how do I do it correctly? If open Docker, then my application consists of two images app_development_web and mysql. How do I properly save them to disk and then import them to the server in the application so that they work correctly?

I would be grateful for any advice and recommendations. Thanks!

When I get time I will update the tutorial to include a working example of a Node project.

I know that you can use git webhooks to deploy a container to caprover but I’m not sure that Wappler supports them just yet.

1 Like

Just installed caprover on Oracle Cloud and everything went seamlessly. Great piece of software and nice UI.

So many niceties I don’t know where to start :smiley:

I need a new home media server so that might be a good beginning.

Just as a reminder. Oracle provides two of these for free “forever”. Quoted because you know how these things are. It’s free forever until it’s not :slight_smile:

3 Likes

Sounds like Google :slight_smile:

1 Like

I’ve been thinking about this and I’m not sure if hosting your entire project in a docker container directly on CapRover is the best solution.

I would personally separate code from your DB which would sit in persistent app. That way your node project can easily be scaled in a cluster and your DB is on a separate container (non-clustered). Of course if you’re working on a small site or app then a single container for both code and DB would work. It’s just personal preference and how much advanced planning you’d like to do.

1 Like

Thank you so much @max_gb, for your help. I really appreciate it.

Yes, that’s exactly what I’m having trouble with at the moment. Wappler creates two Docker containers when creating an application. The application itself is in one container, and the database is in the other.

I do not fully understand how I can move these containers to the server and link them in CapRover.

Do I have to create a separate application for each container in CapRover? If so, how do I link them so that they work as a single application? Also the question is, what is the easiest way to move docker containers to the appropriate application in CapRover?