I'd like to be able to push code to dev.myapp.com
for testing and then to www.myapp.com
for production use. Is this possible with Heroku?
相关问题
- How to specify memcache server to Rack::Session::M
- Connecting Python to a Heroku PostgreSQL DB?
- ClickOnce updates all files. Why?
- rails/heroku migrating from gem to toolbelt
- Using runtime env with React and heroku
相关文章
- Override env values defined in container spec
- Django/Heroku: FATAL: too many connections for rol
- Heroku Web Server Won't Start Locally
- Heroku push issue
- Why does Rake task enhancement differ between my l
- Push rejected, failed to detect set buildpack hero
- What is a good way to deploy a Perl application?
- Email With Rails 3 and Heroku Net::SMTPSyntaxError
Your interface to Heroku is essentially a Git branch. The Heroku gem does some work through their API, but within your Git repository, it's just a new remote branch.
Once you set up multiple applications on Heroku, you should be able to configure your Git repository like this:
I usually work in a 'working' branch, and use Github for my master.
Assuming that's the case for you, your deploy workflow would probably look something like:
This explains everything you need to know if your a newbie like me: http://devcenter.heroku.com/articles/multiple-environments
You should check the heroku_san
It does a pretty good job juggling with environments on heroku.
A key part of the original question is about linking up the staging app to a subdomain (dev.myapp.com) of the main app (www.myapp.com). This hasn't been addressed in any of the answers.
Step 1: Configure both production ('myapp') and staging ('staging-myapp') versions of your app as is indicated in the answer by Luke Bayes
Step 2: In your domain management system (e.g. GoDaddy):
Step 3: Configure Heroku to route dev.myapp.com to staging-myapp:
After the CNAME record has had time to propagate, you will be able to run your staging app at dev.myapp.com.
Things are easier now. Here's how you do it...
Create an app for each environment
This will create named remote repos for each app, which you can see in
.git/config
.You can now use either the --app or --remote switches to target a particular app:
Set Rails environments
For Rails apps, Heroku defaults to the "production" environment. If you want your staging app to run in a staging environment, create the environment in your project and set the corresponding RAILS_ENV and RAKE_ENV environment variables on the app:
Configure environments
If you have other configuration variables you'll need to pass them in for each environment as well.
That's a huge pain though so I just use my snappconfig gem and run
to load my project's YAML config files into Heroku.
Deploy
Now you just push to Heroku like this:
and migrate like this:
(See Managing Multiple Environments for an App | Heroku Dev Center for more info and shortcuts.)