为了账号安全,请及时绑定邮箱和手机立即绑定

使用 docker 镜像在 Heroku 上部署 Go App + Vue.js

使用 docker 镜像在 Heroku 上部署 Go App + Vue.js

Go
忽然笑 2023-06-05 19:31:12
我正在尝试使用 docker 图像在 Heroku 上部署应用程序https://github.com/valasek/timesheet 。应用程序在前端有一个 go 后端 (negroni/gorilla) 和 Vue.js/Vuetify.js,并且正在使用 PostgreSQL 持久性。我坚持部署。我不知道如何调试,如何显示命令行输出,什么是失败的......以及任何帮助非常感谢。相关 Dockerfile - https://github.com/valasek/timesheet/blob/master/Dockerfile以下是我正在执行的步骤:> docker build --rm -f "Dockerfile" -t timesheet:latest .Successfully tagged timesheet:latest...> heroku container:push timesheet:latest --app timesheet-cloud...The push refers to repository [registry.heroku.com/timesheet-cloud/timesheet]...Your image has been successfully pushed. You can now release it with the 'container:release' command.> heroku container:release timesheet --app timesheet-cloudReleasing images timesheet to timesheet-cloud... done> heroku ps -a timesheet-cloudFree dyno hours quota remaining this month: 971h 8m (97%)Free dyno usage for this app: 0h 0m (0%)For more information on dyno sleeping and how to upgrade, see:https://devcenter.heroku.com/articles/dyno-sleeping
查看完整描述

2 回答

?
慕容3067478

TA贡献1773条经验 获得超3个赞

这很可能会发生,因为 Heroku 没有检测到您的应用程序的任何端点(默认情况下绑定在端口 3000 上)。

Heroku 将您的应用程序归为一个动态端口,并将端口值放在名为 的环境变量中$PORT

您的应用程序必须使用 Heroku 在此变量中指定的值并侦听其上的传入连接,因为这是 Heroku 转发连接的地方。

您可以使用检查应用程序上的当前环境变量heroku run printenv

(我看到你正在使用 Viper,它应该处理 env 变量。


查看完整回答
反对 回复 2023-06-05
?
杨魅力

TA贡献1811条经验 获得超5个赞

  1. 在 Heroku DB 连接和 PORT 字符串应该从环境变量中读取

  • 数据库网址

  • 港口

更新的是文件timesheet.yaml。

  1. Axios 中的 BaseUrl 设置为 '' 因此 Axios 使用相对 API URL,这是有效的。修复在文件axiosSettings.js中。

在命令heroku run printenv返回之前:

panic: dial tcp 127.0.0.1:5432: connect: connection refused

现在我得到:

Running printenv on ⬢ timesheet-cloud... up, run.1962 (Free)
Feb 15 16:22:34.186 [INFO] config file /timesheet.yaml
Feb 15 16:22:34.197 [INFO] connecting to DB postgres://user:hash@ec2-54-235-68-3.compute-1.amazonaws.com:5432/dbname
Feb 15 16:22:34.246 [INFO] connected to DB postgres://user:hash@ec2-54-235-68-3.compute-1.amazonaws.com:5432/dbname


查看完整回答
反对 回复 2023-06-05
  • 2 回答
  • 0 关注
  • 109 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信