Deploying a Rails + React app on neetoDeploy

We'll be going through the general steps you need to follow in order to deploy your Rails + React application to neetoDeploy in this doc. We will be using shakacode/react-webpack-rails-tutorial for this tutorial.

Video tutorial

Install pg gem

If the application is not already using PostgreSQL, we need to update it so that it uses the pg gem instead of sqlite3. neetoDeploy currently only supports PostgreSQL (Other databases like MySQL will soon be released).

Update your Gemfile to use pg

gem 'sqlite3', '~> 1.4', :group => [:development, :test]

gem 'pg', :group => [:production]

Update engines in package.json

We need to specify the versions of node, npm and yarn that is used by our application in the package.json file.

"engines": {
  "node": "18.12",
  "npm": "9.x",
  "yarn": "1.22.x"
}

Create the neeto-deploy.json file

The neeto-deploy.json file is used to configure the environment variables, buildpacks and the addons. Read more about how neeto-deploy.json works in the reference here

Example neeto-deploy.json file

{
  "name": "your-app-name",
  "scripts": {},
  "stack": "heroku-22",
  "env": {
    "RESET_DATABASE_WITH_SAMPLE_DATA": {
      "required": true,
      "value": "true"
    },
    "RACK_ENV": {
      "value": "heroku"
    },
    "RAILS_ENV": {
      "value": "heroku"
    },
    "HEROKU_APP_NAME": {
      "required": true
    },
    "LOG_LEVEL": {
      "value": "DEBUG"
    },
    "YARN_PRODUCTION": {
      "value": "true"
    },
    "NODE_MODULES_CACHE": {
      "value": "true"
    },
    "YARN_CACHE": {
      "value": "true"
    },
    "DEFAULT_SUBDOMAIN": {
      "value": "app"
    }
  },
  "addons": [
    {
      "plan": "heroku-postgresql",
      "options": {
        "version": "14"
      }
    },
    {
      "plan": "heroku-redis:hobby-dev",
      "options": {
        "version": "6"
      }
    }
  ],
  "buildpacks": [
    {
      "url": "heroku/nodejs"
    },
    {
      "url": "heroku/ruby"
    }
  ]
}

Creating Procfile

The Procfile defines the different dynos that runs when you app is deployed. By default we need the release and web dynos. The web dyno would be exposed with the live url, while the release dyno includes tasks like database migrations that we need to run after the application is deployed.

Create the Procfile like so:

release: bundle exec rake db:migrate
web: bundle exec puma -C config/puma.rb

If your application has other components like a sidekiq worker or a kafka server, we can add additional entries to the Procfile with the commands required to run these processes.

Can't find what you're looking for?