Upgrading from Heroku Bamboo stack to a Cedar stack - ruby-on-rails-3.1

I am upgrading my app from Rails 3.0 to Rails 3.1. To do this I need to upgrade my Heroku stack to Cedar rather than Bamboo which is currently on.
I am going through the following tutorial
and am getting stuck at the part where I deploy git push heroku master. When I run this git assumes I am pushing to my Bamboo app, when I really want to deploy to my new Cedar stack.
PhotoRambler tonybeninate$ heroku apps
photoramblr
young-river-1492
young-river-1492 is my new Cedar app, but I have no idea how to deploy to it. Can anyone advise? Thanks.
Or do I need to delete my Bamboo stack first?

No, your .git/config still thinks heroku is your old application. If you crack open that file and edit the heroku remote then it will start pushing to the right place.

have you tried checking how you added your heroku repo for the new app? ie
git remote remove heroku #to remove the link to photoramblr
git remote add heroku git#heroku.com:young-river-1492.git # to add the new one
and then
git push heroku master
You might also want to remove your bamboo app once the new once is up, otherwise you'll need to specify what app for heroku commands ie:
#instead of
heroku rake db:migrate
#you'll have to do
heroku rake db:migrate --app young-river-1492

Check out this tutorial on migrating to the Cedar stack - specifically the part on creating a new Cedar app and deploying. You're on the right track - you just need to specify which app git should push to, since you now have more than once to choose from.
Find out what the remote is called for your new app
>git remote
Push to the new remote
>git push young-river-1492-heroku young-river-1492
You can also rename your remote with git remote rename.
If you prefer, you could edit your config file instead, ala Neil's answer, or edit the config after you've successfully pushed once with the long form to make sure it works.

Related

heroku finds an old project that i ave deleted on my heroku homepages

When I try to disable static files on Heroku it keeps linking to a previous project. However, I deleted all my Heroku projects so there are none in my account.
How is this possible and how do I fix it? The heroku CLI seems to be trying to find vast-depths-55781 but the project I just created is immense-ridge-40969:
Heroku determines which app it should use based on your configured Git remotes.
Run git remote -v to see which ones you have set up; I suspect you'll see one pointing to vast-depths-59781. Remove it by its name, e.g.
git remote remove heroku
You could manually add a remote for your new app (or have just changed the previous one's URL), but Heroku provides a dedicated command for setting this up:
heroku git:remote --app immense-ridge-40969
Now heroku commands should default to the new app in that folder. (You can always provide the --app argument to tell heroku to operate against a different app if you wish.)

Redeploy Heroku app without code changes

I would like to deploy a Heroku app which will be done ideally using git push -u heroku master. However this will only work if there are any pending commits to be pushed to master.
How can I redeploy the app while there is nothing to push ? I tried git push -u heroku master -f and still get the same below
Branch master set up to track remote branch master from heroku.
Everything up-to-date
PS: I also want to retain the existing app, which means I cannot make use of this answer https://stackoverflow.com/a/22043184/968442
Normally setting a config var causes your application to be restarted. In most situations there should be no need to redeploy after doing this.
If you really do need to trigger a new deployment you can add a new empty commit, then push to Heroku again:
git commit --allow-empty -m "Trigger Heroku deploy after enabling collectstatic"
git push heroku master
The new empty commit is a regular commit. It has a hash, an author, a timestamp, etc. It will have the same tree as its parent. This should cause Heroku to build your app slug again using the same code as the previous commit.
It's a bit awkward, but it works.
You can do it from UI as well!
Login to your Heroku dashboard and go to deploy section
Find Manual deploy option
Hit Deploy Branch button!
Note: you must have your app connected to GitHub for this option to be available (see comment from Derek below).
There is now also a plugin for the Heroku command-line that allows you to re-release the most recently deployed slug.
See https://www.npmjs.com/package/heroku-releases-retry
It turns out there is a neat plugin for Heroku called heroku release retry that lets you retry the last deploy without resorting to adding bad commits to your repository.
// install plugin
heroku plugins:install heroku-releases-retry
// retry release
heroku releases:retry --app {your-app}
Source: https://www.darraghoriordan.com/2019/03/02/heroku-push-failed-force-rebuild
You can run heroku restart --app app_name and you are good to go.
This worked for me, it did an actual build and release without any commit, contrary to one other post that only does a release:
heroku plugins:install heroku-builds
heroku builds:create --source-url https://user:token#api.github.com/repos/<username>/<repo name>/tarball/master/ --app <app-name>
Source: https://help.heroku.com/I3E6QPQN/how-do-i-force-a-new-deploy-without-adding-a-commit-to-my-github-repo
For stop the heroku app uses :
$ heroku ps:scale web=0
And for start it uses :
$ heroku ps:scale web=1

How can I deploy a shiny app to Heroku

I have a shiny app and want to deploy it to Heroku. I tried to follow the steps as mentioned in:
https://github.com/btubbs/heroku-buildpack-shiny
I created a git Git repository and put the R files into it. Then, I created an app in heroku and tell Heroku to use a custom buildpack for my app. But, I was not be able to enable Heroku websockets support.
Error is:
Couldn't find that feature.
I can't figure out how to deal with this problem. Is there any other way to deploy the shiny app to Heroku?
Have you seen https://github.com/virtualstaticvoid/heroku-docker-r?
Check out the example shiny app too. To specify additional dependencies, you can still use init.R.
To deploy using Docker, you might have to move your current Heroku app to a container stack. This can be done with the heroku stack:set CLI command:
$ heroku stack:set container
Here's a minimal example. Basically:
Create run.R file with the following
library(shiny)
port <- Sys.getenv('PORT')
shiny::runApp(
appDir = getwd(),
host = '0.0.0.0',
port = as.numeric(port)
)
Commit to git
Create a new heroku app with
heroku create --buildpack https://github.com/virtualstaticvoid/heroku-buildpack-r.git
git push heroku master
That's all there is to it.
Another way would be to deploy using Docker. I am not an expert, but it took me a couple of days to deploy an app using this soluation. Many tutorials exist and could bring you to achieving this.

Deploying Angular-fullstack app on Heroku using Codeship

I'm trying to deploy a website via CodeShip unto Heroku. The site is built with Yeoman's Angular-Fullstack generator, which is pushed to GitHub. Codeship detects the push, builds the entire thing and then the trouble start.
Angular-Fullstack is set up so that the dist/ folder contains the entire Heroku app, so blindly deploying everything will not work on Heroku.
Locally, I can use the Heroku toolbelt to login, add a remote inside the dist folder, and then use grunt buildcontrol to deploy the entire thing unto Heroku.
But in Codeship there are a few caveats:
* I cannot install the Heroku toolbelt with wget because it needs sudo and Codeship doesn't support that
* If I could, I couldn't login to Heroku using the CLI because I cannot interact with the shell in Codeship
* I cannot go into the dist/ folder and after adding the remote, simply push to Heroku because I need to enter my credentials.
Is there a way that I missed here? I'd like to let Codeship handle everything from building to deployment to Heroku (only on the master branch).
Figured it out!
I skipped the step where I was trying to install the Heroku Toolbelt, and just added the repo on Heroku as remote:
git remote add heroku ssh://git#heroku.com/[your-heroku-app-name].git
Codeship has public keys available for every build. So, I added that publick key to my Heroku account.
Then I noticed that Git was still trying to push using HTTPS instead of SSH, so I added this to the deployment script:
git config --global url.ssh://git#heroku.com/.insteadOf https://git.heroku.com/
This made sure that Git uses the SSH url for Heroku. I then let Codeship build the entire project and push it with grunt buildcontrol:heroku.

How can I pull an existing heroku app to new location for development?

I currently have the latest version of my code on another computer that I want to develop from (Home computer and laptop for when I'm out and about) I set up heroku for my app on my laptop. Now I need to associate my code on my desktop so that I can push to heroku from there as well.
This is what I get from my desktop:
desktop:~/NetBeansProjects/onlinescheduler$ git pull heroku master
fatal: 'heroku' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
I can't do heroku create because that will create a separate app. How do I associated the existing code with (or pull down a brand new version from) heroku?
Whats the command to do this?
Also, If you've never used heroku before on the other machine, you'll need to do a few more things first:
$ gem install heroku
$ heroku login
[then enter your credentials]
$ heroku keys:add [path to keyfile]
Now you can clone the remote repository:
$ git clone git#heroku.com:<heroku_app>.git <local_directory>
First of all, you'll want to follow the Quick Start instructions for Heroku, which you can get straight from the horse's mouth, right here: https://devcenter.heroku.com/articles/quickstart
Once you've gotten through step 3, come back here.
Then, you can type this into the command line:
heroku git:clone -a myapp
This is described here:
https://devcenter.heroku.com/articles/git-clone-heroku-app
Then, if you want to grab the database too, here are some options.
Newer Heroku instructions on import/export:
https://devcenter.heroku.com/articles/heroku-postgres-import-export
Older heroku instructions on push and pull: https://blog.heroku.com/archives/2009/3/18/push_and_pull_databases_to_and_from_heroku
If you are using mongo, this is a useful tool to sync your mongo database: https://github.com/pedro/heroku-mongo-sync#readme
If you first need to get the app from Heroku, clone your app.
To do that, write in your Terminal:
heroku git:clone -a your_app_name
If you already have the app and the remote to heroku follow the next steps. If not, you can check instructions here https://devcenter.heroku.com/articles/git
Find the name of your database
Write in your Terminal:
heroku pg:info -a your_app_name
it will look something like this:
HEROKU_POSTGRESQL_MAROON_URL
Find the name of your local database
In your Rails app go to config/database.yml
it will look something like this:
your_app_name_development
Clone your production database (PostgreSQL)
Write in your Terminal with your own database names:
heroku pg:pull HEROKU_POSTGRESQL_MAROON_URL your_app_name_development -a your_app_name
HEROKU_POSTGRESQL_MAROON_URL is an example of how could be the name of your production database (in Heroku):
my_app_name_development is the name of your development database (locally)
the_name_of_my_app is the name of your app in Heroku
Don't forget to finish this with bundle install...
If you already have your code base ready and have heroku setup, use:
$ heroku git:remote -a your_heroku_app
This will allow you to deploy from your new location.
Reference: https://devcenter.heroku.com/articles/git#creating-a-heroku-remote
Once you create a key in a new computer, you have to upload your new SSH key by typing heroku keys:add.

Resources