A starter project for building sqlite3 backed sinatra apps hosted on Dreamhost's shared hosting plans.
- 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.
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
- eg:
- 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
- eg:
- run
cd my_new_subdomain.example.comto enter the projects directory. - run
touch tmp/restart.txtto restart passenger. - visit your site (eg:
my_new_subdomain.example.com) and confirm everything is working.
- 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
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.
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.
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.
An autogenerated file that shouldn't need to be touched.
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.
This is where to put templates like erb templates. These a simple index template in there just to make sure everything is working.
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.
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.
Contains some small configuration for bundler. Tells bundler that the gems are installed in
vendor/bundle.
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.