Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create dashboard demo app on Heroku #305

Merged
merged 1 commit into from
Jul 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
release: bin/test_app_rake heroku:release
web: bin/test_app server
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ end

require 'dotenv/load'
require_relative "lib/good_job/version"
Rake.load_rakefile 'spec/test_app/Rakefile'

require 'rdoc/task'

Expand Down
34 changes: 34 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "Day of the Shirt",
"description": "Daily pop-culture t-shirt sales",
"website": "https://dayoftheshirt.com/",
"repository": "https://github.com/bensheldon/dayoftheshirt-rails",
"env": {
"BUNDLE_WITHOUT": {
"description": "Install all Ruby gems, including dev dependencies",
"value": "_blank"
},
"RACK_ENV": {
"value": "production"
},
"RAILS_ENV": {
"value": "demo"
},
"SECRET_KEY_BASE": {
"generator": "secret"
}
},
"buildpacks": [
{
"url": "heroku/ruby"
}
],
"addons": [
{
"plan": "heroku-postgresql"
}
],
"scripts": {
"postdeploy": "bin/test_app_rake heroku:postdeploy"
}
}
5 changes: 5 additions & 0 deletions bin/test_app_rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../spec/test_app/config/application', __dir__)
ARGV << '-f' << File.expand_path('../spec/test_app/Rakefile', __dir__)
require_relative '../spec/test_app/config/boot'
require 'rails/commands'
18 changes: 18 additions & 0 deletions spec/test_app/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,21 @@
require_relative 'config/application'

Rails.application.load_tasks

namespace :heroku do
desc 'Heroku release tasks (runs on every code push, before postdeploy task on review app creation)'
task release: :environment do
unless ActiveRecord::SchemaMigration.table_exists?
Rails.logger.info "Database not initialized, skipping release tasks..."
next
end

Rake::Task['db:migrate'].invoke
end

desc 'Heroku postdeploy tasks (runs only on review app creation, after release task)'
task postdeploy: :environment do
Rake::Task['db:schema:load'].invoke
Rake::Task['db:seed'].invoke
end
end
5 changes: 5 additions & 0 deletions spec/test_app/config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,8 @@ test:
production:
<<: *default
database: <%= ENV["CI"] ? "good_job_test" : "good_job_development" %>

demo:
<<: *default
database: "good_job_demo"
url: <%= ENV['DATABASE_URL'] %>
10 changes: 10 additions & 0 deletions spec/test_app/config/environments/demo.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require_relative 'production'

GoodJob.preserve_job_records = true
GoodJob.retry_on_unhandled_error = false

Rails.application.configure do
config.active_job.queue_adapter = :good_job
config.good_job.execution_mode = :async_server
config.good_job.poll_interval = 30
end
2 changes: 1 addition & 1 deletion spec/test_app/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
root to: redirect('/good_job')
mount GoodJob::Engine => "/good_job"

get :create_job, to: 'application#create_job'
Expand Down