Skip to content

Instantly share code, notes, and snippets.

@leemour
Last active December 16, 2015 11:18
Show Gist options
  • Save leemour/5426147 to your computer and use it in GitHub Desktop.
Save leemour/5426147 to your computer and use it in GitHub Desktop.
Creating Rails with MongoDB and deploying to Heroku from scratch
rails new app -T --skip-active-record
cd app
# пофиксить sed -i "s/# config.time_zone = 'Central Time (US & Canada)'/config.time_zone = 'Europe/Moscow'/" config/application.rb
sed -i 's/# config.i18n.default_locale = :de/config.i18n.default_locale = :ru/' config/application.rb
echo -e "gem 'mongoid'\n" >> Gemfile
echo -e "group :production do\n gem 'unicorn'\n gem 'newrelic_rpm'\nend\n" >> Gemfile
bundle install
#echo 'web: bundle exec unicorn -p $PORT -E $RACK_ENV' >> Procfile
'web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb' >> Procfile
echo -e 'preload_app true\ntimeout 15' >> config/unicorn.rb
rails g mongoid:config
echo -e "production:\n # config for Heroku - https://devcenter.heroku.com/articles/mongohq\n sessions:\n default:\n uri: <%= ENV['MONGOHQ_URL'] %>\n options:\n skip_version_check: true\n safe: true" >> config/mongoid.yml
sed -i '/end$/{N; s/\s\send\nend/ config.sass.preferred_syntax = :sass\n end\nend/}' config/application.rb
sed -i '/end$/{N; s/\s\send\nend/ config.assets.initialize_on_precompile = false\n end\nend/}' config/application.rb
sed -i '/end$/{N; s/\s\send\nend/ config.serve_static_assets = true\n end\nend/}' config/application.rb
git init
git add github [email protected]:user/app.git
heroku create app
heroku addons:add newrelic:standard
heroku addons:add mongoqh
curl https://raw.github.com/gist/2253296/newrelic.yml > config/newrelic.yml
# setup newrelic for unicorn
git add .
git ci -m "Initial commit"
git push heroku master
git push -u github master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment