Skip to content

Setup DuckRails natively

Lazarus Lazaridis edited this page Nov 15, 2017 · 1 revision

DuckRails is a Rails application but even if you are not familiar with the framework or the language, follow the guides below and you'll see it's pretty easy to setup it.

I assume you have ruby installed on your machine (version 2.4.2). If not, install it preferably via RVM.

Command line o'Clock.

Clone the repository locally

Use the following git command to fetch the latest version of DuckRails:

git clone https://github.com/iridakos/duckrails

Navigate to the newly created directory with:

cd duckrails

Install gems

Make sure bundler is installed:

bundle --version

If not, then use this command to install it:

gem install bundler

Use the following command to install the gems required by the application:

bundle install

If bundle command fails, check the error log to find possible reasons (like missing libraries etc).

Configure database

Copy the sample database configuration file (config/database.yml.sample) under config/database.yml:

cp config/database.yml.sample config/database.yml

By default, DuckRails is configured to use the SQLite database engine. Is you are ok with this then you don't need to do anything more. But if you need to customize the database settings then you have to edit the config/database.yml and change it as you see fit.

Important note: If you change the database adapter, make sure you include the appropriate gem in your Gemfile (ex. for mysql gem 'mysql2') and "rebundle" to fetch & install the new gem.

Development environment

If you plan to run the application in development mode, setup the database with:

bundle exec rake db:setup

Production environment

If you plan to run the application in production mode you have an additional step.

Configure the secret key

To generate one, use:

bundle exec rake secret

Copy the output and export it as an environment variable:

export SECRET_KEY_BASE="your_secret_key_base_here"

Setup the database

Execute the following command to setup the database:

RAILS_ENV=production bundle exec rake db:setup

Start the server

Development mode

To start the application at the default port (3000) use:

bundle exec rails server

To start the server listening to another port, use:

bundle exec rails server -p <new_port>

The previous command will start the default Rails server, webrick. You can start another server which supports concurrency & parallelism, Puma with:

bundle exec puma -t 8:16 -w 3

The command above instructs puma to start 3 workers each of whom will be serving from 8 to 16 threads.

Requesting http://localhost:3000 (or your custom port) from a browser should render DuckRails' home page.

Production mode

Before the starting the server in production mode, you must first compile the assets with:

RAILS_ENV=production rake assets:precompile

Then, you may start the default server with:

bundle exec rails s -e production

The previous command will start the default Rails server, webrick. You can start another server which supports concurrency & parallelism, Puma with:

RAILS_ENV=production bundle exec puma -t 8:16 -w 3

The command above instructs puma to start 3 workers each of whom will be serving from 8 to 16 threads.

Requesting http://localhost:3000 (or your custom port) from a browser should render DuckRails' home page.