在Heroku上部署带有Bower的Golang应用程序。

huangapple go评论81阅读模式
英文:

Deploying Golang app with Bower on Heroku

问题

我在根目录下有一个bower.json文件,但它不能运行"bower install"命令。否则我的Go应用程序可以正常工作,但没有Bootstrap和其他依赖项。但是,当我添加一个正确格式的package.json文件时,Heroku错误地尝试将我的应用程序部署为Node.js应用程序并失败。是否有可能在Heroku部署中使Golang和Bower协同工作?

英文:

I have a bower.json file in my root directory, but it doesn't run "bower install." Otherwise my Go app works, but without Bootstrap and other dependencies. But when I add a package.json file and format it correctly, Heroku incorrectly tries to deploy my app as a Node.js app and fails. Is it possible to get Golang and Bower to play nice on a Heroku deployment?

答案1

得分: 2

你可以在你的应用中使用多个构建包:

heroku buildpacks:set https://github.com/heroku/heroku-buildpack-go.git
heroku buildpacks:add https://github.com/heroku/heroku-buildpack-nodejs

执行这两个命令后,你的应用将首先被编译为 Go 应用,然后再编译为 Node 应用。
你的 Go 应用将被编译并可启动。你的 npm 依赖也将被安装,并且 package.json 中的脚本命令将可执行,允许你安装 bower 依赖。

请参阅 https://devcenter.heroku.com/articles/using-multiple-buildpacks-for-an-app
https://devcenter.heroku.com/articles/nodejs-support#customizing-the-build-process

英文:

You can use several buildpacks in your app:

heroku buildpacks:set https://github.com/heroku/heroku-buildpack-go.git
heroku buildpacks:add https://github.com/heroku/heroku-buildpack-nodejs

Once these two commands are executed, your app will first be compiled as a Go one, then as a Node one.
Your Go app will then be compiled and launchable. Your npm dependencies will also be installed, and the script command in package.json be executable allowing you to install bower dependencies.

See https://devcenter.heroku.com/articles/using-multiple-buildpacks-for-an-app
And https://devcenter.heroku.com/articles/nodejs-support#customizing-the-build-process

huangapple
  • 本文由 发表于 2015年10月28日 08:59:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/33381155.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定