Heroku从github子文件夹部署

时间:2017-08-31 09:09:53

标签: ruby-on-rails heroku github deployment

我在Heroku上创建了一个Rails应用程序,我决定从github部署它。由于我的github文件夹具有以下结构,如果我选择在heroku上从github部署,它不会识别我因为子文件夹而在rails上使用ruby。

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

我在book_market文件夹中找到了我的rails应用程序。首先,我使用以下命令从Heroku CLI推送

git subtree push --prefix book_market heroku master

并且一切都很好,因为每次都必须提交和推送这一事实。

昨天我发现这个buildpath Heroku Buildpack Subdir允许你在一个文件夹中执行一个buildpath,所以我在我的根git目录中用以下行创建了一个.buildpacks

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

我在根目录

中也创建了Procfile
 web: book_market/bin/bundle exec rails server -p $PORT -e $RAILS_ENV 

github的部署工作得很好,它可以编译所有内容,但它无法启动服务器并且日志显示

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>'

这是我的宝石文件

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

我还注意到,当我创建应用程序并使用子树命令推送它时,它会创建不同的环境变量

tiziocaio@gmail.com: Set LANG, RACK_ENV, RAILS_ENV, RAILS_LOG_TO_STDOUT, RAILS_SERVE_STATIC_FILES, SECRET_KEY_BASE config vars

并附上了数据库

tiziocaio@gmail.com: Attach DATABASE (@ref:postgresql-solid-35310)

当我从github部署时,它没有做到这一点。

我该如何解决这个问题?感谢

1 个答案:

答案 0 :(得分:0)

我解决了这个问题。首先,我更改为this builder-pack,并根据他们的指示将Procfile移动到我的子目录中。

关于数据库问题,我只是在heroku上添加了postgresql插件并配置了所有内容