Skip to content

Commit

Permalink
Enable heroku review apps (#36)
Browse files Browse the repository at this point in the history
* Remove sqlite3 gem as it isn't supported on Heroku

* Add staging environment to database.yml

* Fix: Not a git repository (or any parent up to mount point /app)

* Copy example database.yml.postgresql before running db:setup

* The "db:setup" setup task isn't supported

It causes following errors as the "db:reset" subtask cannot be run on Heroku.

FATAL:  permission denied for database "postgres"
DETAIL:  User does not have CONNECT privilege.

* Fix: Missing  for 'staging' environment

* Don't force SSL in staging environment

* Add staging environment config in "config/webpacker.yml"

* Try 'webpacker:compile' task in postdeploy hook

* Changes in config/webpacker.yml

* Add 'nodejs' buildback (Ref: rails/webpacker#739)

* Cleanup
  • Loading branch information
Vishal Telangre authored Nov 30, 2017
1 parent 555785d commit 063ee4c
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 54 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal
/config/database.yml

# Ignore all logfiles and tempfiles.
/log/*
Expand Down
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ end

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.4'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'

# Use Puma as the app server
gem 'puma', '~> 3.7'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
Expand Down
2 changes: 0 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
temple (0.8.0)
thor (0.20.0)
thread_safe (0.3.6)
Expand Down Expand Up @@ -202,7 +201,6 @@ DEPENDENCIES
rails (~> 5.1.4)
rest-client
selenium-webdriver
sqlite3
tzinfo-data
web-console (>= 3.3.0)
webpacker
Expand Down
4 changes: 2 additions & 2 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
rails: rails server -p 3333
webpack: ./bin/webpack-dev-server
release: bin/rails db:migrate
web: bin/rails server -p $PORT -e $RAILS_ENV
2 changes: 2 additions & 0 deletions Procfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rails: rails server -p 3333
webpack: ./bin/webpack-dev-server
27 changes: 17 additions & 10 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
{
"name": "elmsanity",
"description": "",
"scripts": {
"postdeploy": "bundle exec rails db:setup"
},
"scripts": {},
"env": {
"SECRET_KEY_BASE": {
"generator": "secret"
},
"RACK_ENV": "staging",
"RAILS_ENV": "staging",
"LOG_LEVEL": "DEBUG",
"HEROKU": "true"
}
},
"formation": {
"web": {
"quantity": 1
}
},
"addons": [

{
"plan": "heroku-postgresql",
"options": {
"version": "9.5"
}
}
],
"buildpacks": [

{
"url": "heroku/nodejs"
},
{
"url": "heroku/ruby"
}
]
}
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ class ApplicationController < ActionController::Base
force_ssl if: :ssl_configured?

def ssl_configured?
!(Rails.env.development? || Rails.env.test?)
!(Rails.env.development? || Rails.env.staging? || Rails.env.test?)
end
end
20 changes: 0 additions & 20 deletions config/database.yml

This file was deleted.

26 changes: 15 additions & 11 deletions config/database.yml.postgresql
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<% branch_name = `git symbolic-ref HEAD 2>/dev/null`.chomp.sub('refs/heads/', '') %>
<% repository_name = `git rev-parse --show-toplevel`.split('/').last.strip %>

development:
adapter: postgresql
encoding: unicode
database: <%= repository_name %>_development
database: elmsanity_development
host: localhost
pool: 5

staging:
adapter: postgresql
database: elmsanity_staging
pool: 5
timeout: 5000

production:
adapter: postgresql
database: elmsanity_production
pool: 5
username: postgres
password:
timeout: 5000

test:
adapter: postgresql
encoding: unicode
database: <%= repository_name %>_test
database: elmsanity_test
pool: 5
username: postgres
password:
6 changes: 6 additions & 0 deletions lib/tasks/assets.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace :assets do
desc "Compile assets"
task precompile: [:environment] do
Rake::Task["webpacker:compile"].invoke
end
end
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1722,8 +1722,8 @@ error-ex@^1.2.0:
is-arrayish "^0.2.1"

es-abstract@^1.7.0:
version "1.9.0"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.9.0.tgz#690829a07cae36b222e7fd9b75c0d0573eb25227"
version "1.10.0"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.10.0.tgz#1ecb36c197842a00d8ee4c2dfd8646bb97d60864"
dependencies:
es-to-primitive "^1.1.1"
function-bind "^1.1.1"
Expand Down Expand Up @@ -1887,7 +1887,7 @@ expand-range@^1.8.1:
dependencies:
fill-range "^2.1.0"

express@^4.13.3:
express@^4.16.2:
version "4.16.2"
resolved "https://registry.yarnpkg.com/express/-/express-4.16.2.tgz#e35c6dfe2d64b7dca0a5cd4f21781be3299e076c"
dependencies:
Expand Down Expand Up @@ -5397,8 +5397,8 @@ webpack-dev-middleware@^1.11.0:
time-stamp "^2.0.0"

webpack-dev-server@^2.9.4:
version "2.9.4"
resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-2.9.4.tgz#7883e61759c6a4b33e9b19ec4037bd4ab61428d1"
version "2.9.5"
resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-2.9.5.tgz#79336fba0087a66ae491f4869f6545775b18daa8"
dependencies:
ansi-html "0.0.7"
array-includes "^3.0.3"
Expand All @@ -5408,7 +5408,7 @@ webpack-dev-server@^2.9.4:
connect-history-api-fallback "^1.3.0"
debug "^3.1.0"
del "^3.0.0"
express "^4.13.3"
express "^4.16.2"
html-entities "^1.2.0"
http-proxy-middleware "~0.17.4"
import-local "^0.1.1"
Expand Down

0 comments on commit 063ee4c

Please sign in to comment.