dsj8086
dsj8086
2019-02-15 09:24

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

已采纳

I am trying to deploy an app https://github.com/valasek/timesheet on Heroku using a docker image. App has a go backend (negroni/gorilla) and Vue.js/Vuetify.js on the frontend and is using PostgreSQL persistence.

I am stuck on deployment. I do not know how to debug, how to show the command line output, what is failing ... and any help highly appreciated.

Relevant Dockerfile - https://github.com/valasek/timesheet/blob/master/Dockerfile

Here are the steps I am doing:

> 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-cloud
Releasing images timesheet to timesheet-cloud... done

> heroku ps -a timesheet-cloud
Free 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

No dynos on ⬢ timesheet-cloud

> heroku logs --app timesheet-cloud
2019-02-15T08:33:49.373221+00:00 app[api]: Deployed timesheet (709022e100f9) by user <email-reducted>@gmail.com
2019-02-15T08:33:49.373221+00:00 app[api]: Release v20 created by user <email-reducted>@gmail.com
2019-02-15T08:34:43.901070+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=timesheet-cloud.herokuapp.com request_id=4c21eb79-5344-4d40-b341-8977128c873f fwd="195.250.152.42" dyno= connect= service= status=503 bytes= protocol=https
2019-02-15T08:34:44.842322+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=timesheet-cloud.herokuapp.com request_id=b66caaee-880a-46a0-918b-e778a49334f4 fwd="195.250.152.42" dyno= connect= service= status=503 bytes= protocol=https
2019-02-15T08:34:54.865321+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=timesheet-cloud.herokuapp.com request_id=d5af6aa7-0279-4f0e-a4cc-0f9e8682ec2f fwd="195.250.152.42" dyno= connect= service= status=503 bytes= protocol=https
2019-02-15T08:34:55.158317+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=timesheet-cloud.herokuapp.com request_id=2d69f4b5-9015-48de-9314-c493703818d1 fwd="195.250.152.42" dyno= connect= service= status=503 bytes= protocol=https
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • duanqinqian5299 duanqinqian5299 2年前

    This is likely to happen because Heroku does not detect any endpoint for your application (binded on port 3000 by default).

    Heroku attributes your app a dynamic port, and put the port value on the env variable named $PORT.

    Your app have to use the value specified by Heroku in this variable and listen for incoming connections on it, because that is where Heroku will forward connections.

    The variable has to be read when the app starts: https://help.heroku.com/PPBPA231/how-do-i-use-the-port-environment-variable-in-container-based-apps

    You can check current env variables on your app using heroku run printenv

    (I see you are using Viper, that should handle env variables. However they say in their documentation that when from env, it is case sensitive, maybe that could explain why it does not work for you: https://github.com/spf13/viper#working-with-environment-variables)

    点赞 评论 复制链接分享
  • dongle19863 dongle19863 2年前

    Thank you @Jonathan Muller. Solved! GUI is running on https://timesheet-cloud.herokuapp.com.

    1. On Heroku DB connection and PORT string should be read from the environment variables

    Updated was file timesheet.yaml.

    1. BaseUrl in Axios is set to '' so Axios is using relative API URLs, which works. Fixed in file axiosSettings.js.

    Before the command heroku run printenv returned:

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

    Now I am getting:

    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
    
    点赞 评论 复制链接分享