简体   繁体   English

可以在不使用Heroku Toolbelt的情况下部署Rails应用程序吗? 如果是这样,怎么样?

[英]Can a Rails app be deployed without using Heroku Toolbelt? If so, how?

I want to deploy rails app without using Heroku ToolBelt. 我想在不使用Heroku ToolBelt的情况下部署rails app。 Is it possible? 可能吗? If so, how? 如果是这样,怎么样? I'm only allowed to use Heroku dashboard; 我只允许使用Heroku仪表板; I'm not allowed to use any other cloud service :( 我不允许使用任何其他云服务:(

I have to run PostgreSQL commands, adding add-ons and setting configuration variables and possibly other tasks for which we have Heroku Toolbelt to deploy a application in production environment. 我必须运行PostgreSQL命令,添加附加组件并设置配置变量以及可能的其他任务,我们有Heroku Toolbelt在生产环境中部署应用程序。

Error: 错误:

user@xx ~/Desktop/github/blog (master)
$ git push git@heroku.com:herokugui.git master
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I don't want to use Heroku Toolbelt. 我不想使用Heroku Toolbelt。 That's why I am using Git commands to deploy code on Heroku. 这就是我使用Git命令在Heroku上部署代码的原因。 I am not able to push code to Heroku using Git commands. 我无法使用Git命令将代码推送到Heroku。 Is it possible to do this task without the toolbelt? 没有工具带可以完成这项任务吗?

Another question I have is: is there any way to run PostgreSQL commands on Heroku GUI? 我的另一个问题是:有没有办法在Heroku GUI上运行PostgreSQL命令? If so, how? 如果是这样,怎么样?

It's not easy (as with Heroku toolbelt), but it's possible. 这并不容易(与Heroku工具带一样),但它是可能的。 It involves hanging around your Heroku dashboard at least, so make sure you can access it. 它涉及到至少悬挂在Heroku仪表板周围,因此请确保您可以访问它。

First off, you need a key. 首先,你需要一把钥匙。 If you're on a Linux machine (as me), then in your home directory you should have a folder named .ssh (it may be hidden, hit Ctrl+H to reveal, again, if Linux) and a file id_rsa.pub in there. 如果你在Linux机器上(就像我一样),那么在你的主目录中你应该有一个名为.ssh的文件夹(它可能是隐藏的, Ctrl+H显示,再次,如果Linux)和文件id_rsa.pub在那里。 If not, you need to generate your SSH key first. 如果没有,则需要先生成SSH密钥。

ssh-keygen -t rsa

That will prompt you for a folder, default is fine, just hit Enter , then enter the passphrase (twice) to protect your key from being accessed by anyone else on your computer: without a passphrase it's unencrypted and free for anyone to take and use from that machine. 这将提示你输入一个文件夹,默认是好的,只需Enter ,然后输入密码 (两次)以保护你的密钥不被你电脑上的任何人访问:没有密码,它是未加密的,任何人都可以免费使用从那台机器。

Once that is done, locate your public key file: id_rsa.pub . 完成后,找到您的公钥文件: id_rsa.pub Note : not id_rsa , it's a private key, you may not want to give it to anyone, it's much like your future Heroku password, except for it's insanely large for a password. 注意 :不是id_rsa ,它是私钥,你可能不想把它交给任何人,这很像你未来的Heroku密码,除了它对于密码来说太疯狂了。 Open id_rsa.pub , you should see stuff like: 打开id_rsa.pub ,您应该看到以下内容:

ssh-rsa aWhOLELotofUnreadABLEGibbERishWHiCHiSactUALLyYourPubLIcKeY...

You need to enter that line into your account settings in Heroku dashboard, under SSH Keys . 您需要在Herkeys仪表板的SSH密钥下输入该行到您的帐户设置中。 You can find more info on keys here, in Heroku docs . 您可以在Heroku docs中找到关于键的更多信息。 Make sure Heroku actually recognizes you by issuing this: 确保Heroku通过发出以下内容实际识别您:

ssh -v git@heroku.com

It should state you're authenticated. 它应该声明您已通过身份验证。

Now for the git address. 现在为git地址。 I assume you know your way around git , so I'll keep it short: you'll need to derive your repository address from your app name. 我假设您了解git ,所以我会保持简短:您需要从您的应用名称中获取您的存储库地址。 Heroku usually generates weird (yet somewhat poetic) names like falling-wind-1624 or shielded-fjord-1858 . Heroku通常会产生奇怪的(但有些诗意的)名字,如falling-wind-1624shielded-fjord-1858 I'll take the first one as an example, this is how you add its address as a git remote: 我将以第一个为例,这是你如何将其地址添加为git远程:

git remote add heroku git@heroku.com:falling-wind-1624.git

I'll explain a bit of it below. 我将在下面解释一下。 So what the toolbelt does here, is to use your app name only, it just builds the URL the same way by adding a path to Heroku server. 那么工具带在这里做的是仅使用您的应用程序名称,它只是通过添加Heroku服务器的路径以相同的方式构建URL。 Once that's done, you should be able to push your code: 一旦完成,您应该能够推送您的代码:

git push heroku master

I've named a Heroku remote heroku , above, that's why I'm using heroku name here, you can name it whatever you want and use this afterwards. 我在上面命名了一个Heroku远程heroku ,这就是为什么我在这里使用heroku名称,你可以随意命名,然后使用它。 Once you've pushed the code, the rest is up to you. 一旦你推动了代码,剩下的就由你决定了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM