Deploying a typical database-backed Ruby on Rails application with Action Cable

Deploying a typical Ruby on Rails application is a basic example of provisioning and administration of a single server Rails application backed by local PostgreSQL and Redis databases.

The demo doesn't expose the database to the outside world but rather depends on SSH tunneling for manual access. A local disk is used for storage.

What you'll learn

  • Setting up a git-pust deployment for Ruby applications
  • Using chruby to automate installing requested Ruby versions
  • Configuring NGINX as a proxy using UNIX sockets
  • Setting up systemd socket activation for graceful restarts
  • Configuring NGINX to serve static assets
  • Configuring NGINX to proxy WebSockets connections for Action Cable
  • Automatic SSL/TLS certificates with Let's Encrypt
  • Redirecting HTTP traffic and subdomains to main domain over HTTPS
  • Running PostgreSQL and Redis on the same server
  • Building custom SELinux module
  • Configuring firewall
  • Setting up automatic weekly system update
  • Setting up log rotation for NGINX and PostgreSQL logs and max limit for system log
  • Doing application backups and restores
  • Creating admin tasks

Configuration options

SERVER Virtual machine IP address
SERVER_NAME Domain name for HTTPS certificates
EMAIL E-mail address for Let's encrypt certificates
SSH_KEY Path to the SSH private key
APP_NAME Application name (without spaces and weird characters)
RAILS_ENV Rails environment
RUBY_VERSION Ruby version to pre-install
Buy for $50
Rated 36x five stars
Gumroad (as of Aug 3, 2023)
I am using some scripts I downloaded from Josef Strzibny's book that are setting up Ruby on Rails deployment and automatically installing a PostgreSQL server. I am also using Dokku, but I like the idea of controlling what is happening on the server.
Lucian Ghinda, Senior Ruby Developer

Code to get you started

A static website

A static website with automatic Let's Encrypt certificates and system updates. A separate configuration and rootless deployment script.

Add server-side analytics and beat the pricing of hosted solutions.

A database-backed Ruby on Rails application
with Action Cable

A single server running a full-featured web application with UNIX sockets, PostgreSQL ident system authentication, Web Sockets, and Let's Encrypt certificates. A git-push deployment with helpful administration scripts for connecting to the server or handeling file and database backups.

Adjust for your application based on the knowledge from the book. Deploy within the same day!

A standalone PostgreSQL server

A self-sufficient PostgreSQL cluster demo with automatic system upgrades, log rotation, and TLS. Scripts for cluster-wide backups and restores.

Run a standalone database when you need more power or to host all your projects' databases in one place.

All demonstrations are scripted in Bash for RHEL 8 compatible systems such as Rocky Linux 8.

You don't need any knowledge of typical configuration management tools. Learn how everything works without abstractions and indirection.