Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.
/ ruby-on-dreamhost Public archive

A starter pack for ruby / sqlite3 / sinatra apps on Dreamhost shared hosting

Notifications You must be signed in to change notification settings

g-re-g/ruby-on-dreamhost

Repository files navigation

Dreamhost ruby / sqlite3 / sinatra

A starter project for building sqlite3 backed sinatra apps hosted on Dreamhost's shared hosting plans.

Why?

  • Dreamhost supports ruby on it's shared hosting. 💎🚀
  • They only support ruby 2.5.1. 🤦
  • A quick way to make sure everything works.
  • A quick way to start a new sqlite3 / sinatra project on Dreamhost.
  • There's some boiler plate to get things to play nice with passenger.
  • Sinatra expects things to be in certain places by default.
  • Gems are expected to be in a certain place to work.

How to use?

I find the easiest way to get started is to:

  • Set up a domain or subdomain through the dreamhost panel.
  • Make sure that the user that owns hosing for that domain has ssh access.
  • ssh in as that user and delete the main directory for the new domain or subdomain.
    • eg: rm -r my_new_subdomain.example.com
  • clone this repo naming it the same as that folder you just removed.
    • eg: git clone https://github.com/g-re-g/ruby-on-dreamhost my_new_subdomain.example.com
  • run cd my_new_subdomain.example.com to enter the projects directory.
  • run touch tmp/restart.txt to restart passenger.
  • visit your site (eg: my_new_subdomain.example.com) and confirm everything is working.

Adding more gems

  • Add them to Gemfile
  • Always specify an exact version, not a version range. E.g. gem 'sinatra', '2.2.4'
  • Make sure your gem supports ruby 2.5 or earlier.
  • Run bundle install --path vendor/bundle

What's in this starter project?

main.rb

This file is the main entry point for your a application. It has some boiler plate to help with setting things up:

  • requiring the exact versions of gems that support Dreamhost's ruby version
  • creating and migrating a test database
  • a basic get / route so you can check everything is working.

config.ru

This is the script used by rack / passenger to launch you application. You shouldn't need to change anything in this file unless you move main.rb somewhere.

Gemfile

Specifies the exact versions of sinatra and sqlite3 that I believe are the most recent releases that will wok with Dreamhost's shared hosting ruby version.

Gemfile.lock

An autogenerated file that shouldn't need to be touched.

public/

This is where to put public files like images, css, and javascripts. There's a test image in there just to make sure everything is working.

views/

This is where to put templates like erb templates. These a simple index template in there just to make sure everything is working.

vendor/

This is where the gems are actually stored. Anytime you want to add another gem you should put it in Gemfile with an exact version and run bundle install --path vendor/bundle. Since there's no real upgrading of the ruby version on Dreamhost's shared hosting your gem versions aren't likely to change much and having them cached protects you from anything changing in the future that would break your gem installs.

tmp/

In here is restart.txt updating this file restarts passenger, aka reloads all the code for your application. Any time you update anything in here that would require a server restart you should touch tmp/restart.txt.

.bundle/

Contains some small configuration for bundler. Tells bundler that the gems are installed in vendor/bundle.

.tool-versions and .ruby-version

Version managers use these files to choose which version of ruby to make available in the current shell session. You should always use ruby version 2.5.1 when developing for Dreamhost shared hosting and these files tell your tools to use that version or warn you if you don't have it installed.

More reading

About

A starter pack for ruby / sqlite3 / sinatra apps on Dreamhost shared hosting

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published