Leonardo
Leonardo

Reputation: 539

Heroku deploy from github subfolder

I created a Rails application on Heroku and I decided to deploy it from github. Since my github folder has the following structure, if I choose on heroku to deploy from github, it doesn't recognize that I'm using ruby on rails because of the subfolder.

*\.git
*\otherfiles
*\book-market
*****\app
*****\bin
*****\config
...ecc

I've got my rails application in book_market folder. At first I push from Heroku CLI using the following command

git subtree push --prefix book_market heroku master

and everything works great, execpt for the fact that I have to commit and push every time.

Yesterday I found this buildpath Heroku Buildpack Subdir that allows you to execute a buildpath within a folder, so I created a .buildpacks in my root git directory with the following line

book_market=https://github.com/heroku/heroku-buildpack-ruby.git

And I created also a Procfile in the root directory

 web: book_market/bin/bundle exec rails server -p $PORT -e $RAILS_ENV 

The deploy from github works great, it compiles everything but it can't start the server and the logs says

heroku[web.1]: Starting process with command `book_market/bin/bundle exec rails server -p 59500 -e production
heroku[web.1]: Process exited with status 1
heroku[web.1]: State changed from starting to crashed
app[web.1]: /usr/lib/ruby/2.3.0/rubygems.rb:241:in `bin_path': can't find gem bundler (>= 0) (Gem::GemNotFoundException)
app[web.1]:     from book_market/bin/bundle:3:in `<main>'

this is my gemfile

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end

gem 'bundler'

gem 'aws-sdk'

gem 'bcrypt', '3.1.11'

gem 'bootstrap-sass', '3.3.7'

gem 'bootstrap-will_paginate', '1.0.0'

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'

gem 'faker', '1.7.3'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'

gem 'jquery-slick-rails'
# Use jquery as the JavaScript library
gem 'jquery-rails'

gem 'meta-tags'

gem 'omniauth-google-oauth2'

gem 'omniauth-facebook', '4.0.0'

gem 'paperclip', '~> 5.0.0'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.3'

gem 'rails-controller-testing', '1.0.2'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'

gem 'select2-rails', '4.0.3'
# Use sqlite3 as the database for Active Record
gem 'pg'

# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

gem 'unicorn', '5.3.0'

gem 'vacuum'

gem 'will_paginate', '3.1.6'

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'listen', '~> 3.0.5'
  gem 'web-console', '>= 3.3.0'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end
group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
end

I also noticed that when I create the app and push it with the subtree command it creates different Environments variables

[email protected]: Set LANG, RACK_ENV, RAILS_ENV, RAILS_LOG_TO_STDOUT, RAILS_SERVE_STATIC_FILES, SECRET_KEY_BASE config vars

and attached the db

[email protected]: Attach DATABASE (@ref:postgresql-solid-35310)

And when I deployed from github it didn't do this.

How can I solve this problems? Thanks

Upvotes: 1

Views: 1143

Answers (1)

Leonardo
Leonardo

Reputation: 539

I solved this issue. First of all I changed to this builder-pack and according to their instruction I moved the Procfile in my subdirectory.

Regarding the database question, I simply added the postgresql addon on heroku and it configure everything

Upvotes: 1

Related Questions