英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论