Heroku: How do you push to specific app if you have multiple apps in heroku?
You will need to setup different git remote end points for each application at Heroku so you can push to either application from the one local repo.
Get the GIT URLs for your apps on Heroku via the dashboard (it will look something similar to this: https://git@heroku.com:your_app_name.git
) and do:
git remote add test-app1 https://git@heroku.com:test-app1.git
git remote add test-app2 https://git@heroku.com:test-app2.git
git remote add test-app3 https://git@heroku.com:test-app3.git
Then you will be able to push to any specific app like this:
git push test-app1 master
git push test-app2 master
git push test-app3 master
Deploy two separate heroku apps from same git repo
My understanding of your question is that you have one Git repository, that contains two entirely separate programs: one API server, and one web server.
With this assumption in mind, here's what you'll want to do, step-by-step:
- Go into your project folder.
- Define a
Procfile
at the root of your project. This will tell Heroku how to run your web server and your API server.
Here's how you might want your Procfile
to look (an example):
web: node web/index.js
api: node api/index.js
In my example above: I'm defining two types of Heroku dynos -- one called web
and one called api
. For each one, you'll need to tell Heroku what command to run to start the appropriate server. In this example, I would run node web/index.js
to start up my website, and node api/index.js
to start up my API service.
Create two new Heroku applications. You can do this by running
heroku create <desired-app-name> --remote <desired-app-name>
multiple times. NOTE: The--remote
flag will tell Heroku to create a Git remote for each of your applications in the same repo.Next, you'll need to tell Heroku to run your actual web application on one Heroku app, and your API service on another Heroku app. You can do this by using the Heroku CLI:
$ heroku ps:scale web=1 --remote webserver-app-name
$ heroku ps:scale api=1 --remote apiserver-app-name
These commands will:
- Run a single web dyno for your webserver Heroku app.
- Run a single API dyno for your apiserver Heroku app.
As you can see above, using the ps:scale
command you can control what types of commands Heroku will run from your Procfile
, and how many instances of each you'd like to have.
Hopefully this helps!
Heroku - push subtrees to different apps
Following @bouteillebleu's suggestion, I was able to handle this like so...
First, I needed to add Heroku endpoints for the two apps in the parent directory -
$ git remote add phoenix-heroku-app https://git.heroku.com/phoenix-heroku-app.git
$ git remote add react-heroku-app https://git.heroku.com/react-heroku-app.git
Then I just needed to run
$ git subtree push --prefix Phoenix phoenix-heroku-app master
$ git subtree push --prefix React react-heroku-app master
and it was good to go.
Heroku, multiple heroku apps in same directory, how to remove all but one?
Can you check your git remote -v
output: if it still refers the wrong URL, you can change it with:
git remote set-url origin https://git.heroku.com/workoutcalendar.git
Then try and push again.
Getting a list of multiple apps with heroku open
If you're trying to push to your heroku
server, do:
git push heroku master
If you're trying to push to your heroku-stagin
server:
git push heroku-stagin master
If your still-falls-46284
branch is also a heroku app and you're trying to push it to that one, do:
git push still-falls-46284 master
How do I push different branches to different heroku apps?
You should add another remote for my-app-prod named prod-heroku (replace GIT_URL with the Git URL that you can find in the settings page of my-app-prod in heroku):
git remote add prod-heroku GIT_URL
git push prod-heroku production:master
This will push your local branch production to the remote branch master in prod-heroku so my-app-prod will get deployed with the code in production branch.
Deploying 2 different heroku apps with same code and git repository
You will need to setup different git remote end points for each application at Heroku so you can push to either application from the one local repo. I don't use the 'heroku' name as my remote though (not that it really matters) I use production and staging mapped to different Heroku applications. So I can do:
git push production master
or
git push staging staging:master
Check your remote endpoints via git remote -v
in the projects root. It will show the default heroku mapped to your application.
Get the URLs for your apps on Heroku via the dashboard and do
git remote add production <gitrepo for production app here>
git remote add staging <gitrepo for staging app here>
However, from the the error you've posted it looks like you're not a collaborator on the app1 application.
Git pushes to wrong heroku app
Indeed, you should understand what is a remote repository.
You can for example type git remote -v
and see the result to clearly see where you are pushing.
from there, git remote rm heroku
allows you to remove the remote repository.
And git remote add heroku {address}
allows you to add a remote repository whose address you should specify.
The address of the corresponding remote is provided by heroku. Go on the app details on the heroku website and copy paste it from there. After that, the git push heroku master should push to the good repository.
When you copy pasted, the project, you also copy pasted the .git directory of the project so all the old settings of git for it. I think that a git clone
would have been a better approach
Related Topics
Positive Lookahead Doesn't Stop at First Occurrence
(New to Rails) Rails Server Error: Cannot Load Such File -- Bootsnap/Setup (Loaderror)
Getting Current Line of Code in Ruby
Automatic Associations in Ruby on Rails Fixtures
How to Run "Bundle Exec Jekyll New ."
How to Stub a Method of an Included Module with Rspec
Is Ruby's Stdlib Logger Class Thread-Safe
Returning True or Error Message in Ruby
Lion Osx: How to Install Libfreetype.6.Dylib
Why Is Bigdecimal Returning a Weird Value
Many: 'Require': Cannot Load Such File -- "Gem_Name" (Loaderror) After Upgrade of Ruby/Rails
Why Is Throw and Catch Hardly Ever Used in Ruby
Find Case-Insensitive Word Matches in a Line
How to Add a Single Backslash Character to a String in Ruby
How to Use Activesupport::Configurable with Rails Engine
Why Is Ruby String.Hash Inconsistent Across MAChines
How to Specify a Read Timeout for a Net::Http::Post.New Request in Ruby 2