Rails & PostgreSQL with CapRover on DigitalOcean Droplet (Part I)

Robert Guiscard
3 min readDec 24, 2019

--

I use Heroku for a long time, but only on free plan. It is a very nice solution for quick deployment and personal project. But the cost is high for both paid dyno and managed PostgreSQL. I did try Amazon AWS, but I feel it is for professional developers with lots of options and settings. Then I stumbled on CapRover which might be a good choice. It is an open source project, renamed from CaptainDuckDuck. It uses docker underneath. Therefore, if it is not available anymore, I can still convert back to general docker containers for my project.

I am more familiar with Rails and PostgreSQL, but not Docker and Nginx. CapRover gives an easy start for me to become familiar with all those components. It is even easier to start with DigitalOcean with CapRover pre-installed. You can get $100 credits (expired in 2 months) with referral: https://m.do.co/c/601a6b67f619. I suggest you to use it so that you can create multiple droplets to play with. Within two months of time, you can decide the best configuration and reduce the cost by deleting unnecessary droplets.

After you sign up for DigitalOcean, create a droplet with CapRover from marketplace. Find the CapRover image first.

It is fine that the version of CapRover here is not the latest. You can upgrade through CapRover web interface directly. Then select the size of droplet with $5 per month the cheapest (or more) and the datacenter region. Upload the SSH public key of yours. Then click the “Create Droplet” button.

You can also watch a short and long YouTube videos for those steps.

Once the droplet is created and an IP address is obtained, point a DNS A record to that IP address with a host name like ‘*.caprover’. It uses two subdomains intentionally to minimize the chance that hackers will discover your CapRover domain. After the new domain record becomes effective, follow step 3 of “Getting started” guide to install CapRover CLI and set up server. I happened to mistype the password and had to quite the process by Ctrl-C, but it is fine. Just go to captain.caprover.yourdomain with default password captain42 and change password to a better one. If everything goes smooth, you can process to the Dashboard of your CapRover web interface. With a few clicks on “Enable HTTPS” with your email address and “Force HTTPS”, the SSL/TLS setting is done! Surely I can later learn how to do so with plain docker container, but this is a much easier way for a beginner.

In the “Settings” section of CapRover web interface, you have chance to upgrade the CapRover to the latest 1.6.0 at the time of this writing. Also you have chance to remove unused image in this page. Use “Get List” at the bottom of “Settings” section to list all images. If you upgrade CapRover to 1.6.0, the old 1.4.0 image is not used and can be removed.

You can also turn on monitoring with NetData through CapRover web interface. How nice it is.

CapRover offers popular applications and database with one-click installation. Go to “Apps” section.

To find a suitable docker image of PostgreSQL, you can go to https://hub.docker.com/r/library/postgres/tags/. Postgresql-alpine has much smaller size than the regular one. Thus, you can use ‘9.6-alpine’ as ‘Postgres Version’. Give it a proper name and password, then deploy ! Now you have a PostgreSQL database running.

In the next part, I will try to deploy a Rails project to it.

--

--

No responses yet