【问题标题】:Heroku deploy from github subfolderHeroku 从 github 子文件夹部署
【发布时间】:2018-02-09 04:23:44
【问题描述】:

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

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

我的 rails 应用程序位于 book_market 文件夹中。起初我使用以下命令从 Heroku CLI 推送

git subtree push --prefix book_market heroku master

一切都很好,除了我每次都必须提交和推动这一事实。

昨天我发现了这个构建路径Heroku Buildpack Subdir,它允许你在一个文件夹中执行一个构建路径,所以我在我的根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

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

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 部署时,它没有这样做。

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

【问题讨论】:

    标签: ruby-on-rails heroku github deployment


    【解决方案1】:

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

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

    【讨论】:

    • 嘿,我也有同样的问题。您提供的链接已不存在。如果您仍然可以访问 builder-pack,介意更新吗?
    • Stack Overflow 在尝试再次编辑时提示建议的编辑队列已满。新链接在旧链接的自述文件中:github.com/timanovsky/subdir-heroku-buildpack - 我们目前正在生产中使用该链接,效果很好。
    猜你喜欢
    • 2017-01-04
    • 2020-02-08
    • 1970-01-01
    • 2017-05-16
    • 1970-01-01
    • 2016-11-20
    • 2021-07-12
    • 2019-02-13
    • 2012-06-17
    相关资源
    最近更新 更多