You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Heroku发布阶段无错误日志却执行失败求助

Docker化Rails项目部署Heroku发布失败及快速测试需求

背景

我正在给一个旧项目添加Docker支持,准备将Docker化版本部署到Heroku。本地Docker和docker-compose运行正常,但推送到Heroku时遇到了瓶颈。

当前heroku.yml配置

setup:
  addons:
    - plan: heroku-postgresql
      as: DATABASE
build:
  docker:
    web: Dockerfile
  config:
    RAILS_ENV: production
release:
  image: web
  command:
    - bundle exec rails db:migrate
run:
  web: bundle exec rails s -b 0.0.0.0

错误现象

每次推送到Heroku时,构建成功但发布失败,日志显示:

remote: Verifying deploy... done.
remote: Running release command...
remote:
remote: Waiting for release.... failed.

而且Heroku的发布日志始终为空,找不到具体失败原因。

尝试过的调整

我曾把发布命令移到单独的脚本文件中执行,修改后的heroku.yml相关配置:

release:
  image: web
  command:
    - ./deployment-tasks.sh

对应的deployment-tasks.sh内容:

#!/bin/sh

rails db:migrate

但问题依旧没有解决。

相关环境信息

  • Docker基础镜像:ruby:2.7-alpine3.14
  • Rails版本:6.0.6.1

database.yml配置

default: &default
  adapter: postgresql
  encoding: unicode
  # For details on connection pooling, see Rails configuration guide
  # https://guides.rubyonrails.org/configuring.html#database-pooling
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  # On docker, host must match service name in docker-compose
  host: database

development:
  <<: *default
  database: portfolio_development
  username: <some_username>
  password: <some_password>

test:
  <<: *default
  database: portfolio_test
  username: <some_username>
  password: <some_password>

production:
  <<: *default
  database: portfolio_production
  username: <some_username>
  password: <%= ENV['PORTFOLIO_DATABASE_PASSWORD'] %>
  host: localhost

需要解决的问题

  1. 为什么发布阶段执行db:migrate会失败,且没有日志输出?如何修复这个问题?
  2. 有没有办法不用每次推送都重新构建应用,快速迭代测试heroku.yml的修改?现在每次推送都要等5-10分钟,效率太低了。

内容的提问来源于stack exchange,提问作者Umar Ghouse

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 09:33:31