Skip to content

Instantly share code, notes, and snippets.

@xxjapp
Created August 12, 2018 09:10
Show Gist options
  • Save xxjapp/e5c15d6cb244bed005ad8a1a8a74f96d to your computer and use it in GitHub Desktop.
Save xxjapp/e5c15d6cb244bed005ad8a1a8a74f96d to your computer and use it in GitHub Desktop.

Run a Rails App in Production Locally

Steps

  • export SECRET_KEY_BASE

    export SECRET_KEY_BASE=`rake secret`
  • create db

    # rm -f db/production.sqlite3   # remove old production db if necessary
    RAILS_ENV=production rake db:create db:migrate db:seed
  • precompile your assets by the following command, which will create a folder public/assets that contains all of your assets.

    # rake assets:clobber           # clobber old assets if necessary
    RAILS_ENV=production rake assets:precompile
  • to serve static assets, export RAILS_SERVE_STATIC_FILES

    export RAILS_SERVE_STATIC_FILES=true
  • run server in production environment.

    RAILS_ENV=production rails s -b 'ssl://localhost:3000?key=/usr/local/certs/localhost.key&cert=/usr/local/certs/localhost.crt'

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment