Initialize your application
$ rails new my-app # # It creates files and run 'bundle install' # $ git init $ git add . $ git commit -m "Base rails application"
Create your application on Scalingo
$ scalingo create my-app Git repository detected: remote scalingo added → 'git push scalingo master' to deploy your app
Provision and configure your database
- Go on the dashboard of your application.
- Select the Addons category
- Choose the database you want to use
Add the gem
pg to your
Add the gem
mysql to your
gem 'mysql2', '~> v0.3.18'
Then set the following environment variable:
DATABASE_URL→ Copy the value of
SCALINGO_MYSQL_URLand replace ‘mysql://’ by ‘mysql2://’
To use a MongoDB database your need to add the gem
mongoid to your
Please refer to this guide.
Setup your application logging
By default, Rails applications don’t write their logs to STDOUT but in a custom file. We expect your application to write all its logging entries to STDOUT and STDERR according to their nature, in accordance to the 12-factor.
Why writing the logs to the standard output?
It is a requirement to let the platform aggregate them and let you browse your application logs in the dashboard or with Scalingo’s command line interface.
Rails 5 and later
You’ve nothing to do, everything is handled by the platform
Rails 4 and before
- Add the following gem in your
rails_12factor gem includes two gems, one of them is
rails_stdout_logging. Thanks to it, the application won’t write the logs to
log/production.log file but directly on the standard output.
Serving static assets
In a more traditional way to host a Ruby on Rails application, assets would not be served by the application server, but by a proxy web server (Apache/Nginx for instance), but you don’t need that on Scalingo.
Rails 4.2 and later
You’ve nothing to do, everything is handled by the platform.
Rails 4.1 and before
- As for the logging: add the following gem in your
gem "rails_12factor". It includes a middleware provided by
sprocketto serve static files located in the
/publicdirectory of your project.
Finalize and deploy
$ bundle install $ git add . $ git commit -m "Configure application for Scalingo" $ git push scalingo master
Access your application
… Waiting for your application to boot... <-- https://my-app.osc-fr1.scalingo.io -->
A new application will render a 404 error
The page you were looking for doesn't exist.,
but it’s expected. There is nothing in the project, it’s time to build your product!
Specifying a custom Node.js runtime
Latest version of Rails application also use Node.js in case ExecJS or Webpacker is detected. The Node.js version built inside the Ruby buildpack is frozen. It is 10.15.3 at the time of writing.
If you ever need to specify a different version of Node.js, you need to setup
the multi buildpacks), in order to use both the Node.js and the Ruby buildpack. The content of your
.buildpacks file must respect the following order between the buildpacks:
You also need to remove the file
bin/yarn if it already exists.
You eventually need to specify the Node.js version in your