Ruby HTML JavaScript CoffeeScript CSS
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
bin
config
db
lib
log
public
test
tmp
vendor
.babelrc
.gitignore
.ruby-gemset
.ruby-version
Gemfile
Gemfile.lock
MIT-LICENSE.md
Procfile
README.md
Rakefile
config.ru
package.json
yarn.lock

README.md

Deploy.RB / Rails 5 App

This is a part of the Deploy.RB project.

Deploy.RB consists of:

  1. Rails 5 App (You are here)
  2. Server Installation Script & Manual
  3. Deployment Tool

Please, visit Deploy.RB page to get more information.

Rails 5 App

Simple Rails 5 App for deploy.rb project

With this App we demonstrate how basic Rails 5 can be configurated for deployment process

The app uses the following tools:

  • PostgreSQL (as main DB Storage)
  • Devise (Authentication)
  • Redis (Cache store and store for SideKiq)
  • SideKiq (Delayed jobs)
  • Thinking Sphinx (Full-text search)
  • mysql2 adapter to work with Thinking Sphinx
  • foreman to start/stop services
  • WebSockets (ActionCable)
  • Whenever (Cron tasks)
  • kaminari for pagination

How to run on local machine

System requirements

[open ▾] How to check required software?
$ which rvm
/Users/$HOME/.rvm/bin/rvm

$ which node
/usr/local/bin/node

$ which redis-server
/usr/local/bin/redis-server

$ which searchd
/usr/local/bin/searchd

$ which psql
/usr/local/bin/psql

$ which mysql
/usr/local/bin/mysql

1. Clone & install

git clone https://github.com/DeployRB/Rails5App.git
cd Rails5App

gem install bundler
bundle install

2. Create a folder for config files for your environment

cp -av config/ENV/production.example config/ENV/development

3. Edit files in folders were copied

  1. Edit files were copied and replace /ABS/PATH/TO with real absolute path to your Rails5App app path

    For example, /ABS/PATH/TO/Rails5App => /Users/the-teacher/rails/Rails5App

  2. Edit files were copied and replace production.example with a name of your environment

For example:

  sed -i '' 's/production.example/development/g' config/ENV/development/services/*

4. Setup database.yml

cp config/database.yml.example config/database.yml

Edit file and set required parameters.

[open ▾] How to create PQSL user?
createuser rails5app -sW
> qwerty
psql -U postgres

CREATE USER "rails5app" WITH PASSWORD 'qwerty';
ALTER ROLE "rails5app" SUPERUSER CREATEDB;

\q

5. Initialize your App

bundle exec rake app:init

6. Build Search index

bundle exec rake ts:configure ts:index

7. Start services

Start cron tasks

[open ▾] CRON. Notes
  • tasks list crontab -l
  • remove all tasks crontab -r
bundle exec whenever --clear-crontab Rails5App
bundle exec whenever --update-crontab \
  -i Rails5App \
  --load-file config/ENV/development/services/schedule.rb \
  --set 'environment=development'

Start services with foreman

bundle exec foreman start

8. Start Rails server

bundle exec puma -b tcp://localhost -p 3000

or just

bundle exec rails s

Finally App is ready to use

http://localhost:3000

Async tasks

http://localhost:3000/async/tasks
login: admin
password: qwerty