Deploy Meteor and MongoDB in Heroku

I am trying to deploy my project in Heroku after a specific guide (http://bytesofpi.com/post/20898722298/push-your-meteor-project-to-heroku)

One of the steps indicates that

var mongo_url = process.env.MONGOHQ_URL; 

You need to replace "MONGO_URL" with server / server.js.

The problem is that I cannot find this variable at all, the only mention of this variable is in the following code

  // check for a valid MongoDB URL right away if (!process.env.MONGO_URL) throw new Error("MONGO_URL must be set in environment"); 

Does anyone have experience with this or know where to find "MONGO_URL" to change it?

+4
source share
3 answers

I would suggest that instead of using the article you mentioned as a guide, you do the following:

Use Meteorite to create and run local Meteor projects:

 https://github.com/oortcloud/meteorite 

Instructions are on this page.

Then use this buildpack:

 https://github.com/oortcloud/heroku-buildpack-meteorite 

Again, README has how to build your Heroku app (single line)

A NOTE at the bottom of this README means that you need to verify your Heroku account with a payment card so that you can add the free mongohq add-on to your application. After checking:

 heroku addons:add mongohq:sandbox 

To add db to Heroku.

Then another step will be to set ROOT_URL for your application, enter it in the local directory of the application after the application is executed (only for the first time):

 heroku config:set ROOT_URL=<<domain of your app>> 

If you do not use a custom name <> there will be something like

 http://appname.herokuapp.com 

If you then run:

 heroku config 

you will see that MONGOHQ_URL is set next to BUILDPACK_URL and ROOT_URL.

+14
source

Oortcloud buildpack is the best Heroku builder I've used.

Speaking of this, Heroku is a dead end because he does not support the proximity of the session. At least you can get your application and run it on Heroku, but you can never scale it with a few dinosaurs unless Heroku people decide to replace all of their balancing devices. FYI. Dead end.

CloudBees looks like the best Meteor hosting platform ... https://github.com/CloudBees-community/meteor-clickstart

0
source

I searched this title many times, trying to find a modern solution for deploying my local Meteor Mongo db in Heroku. So I am posting this answer here for those who do the same, although the question really is to set MONGO_URL.

Here is an updated solution (Meteor 1.3.2.4) for pushing the local Meteor Mongo database in Heroku with (free) mLabs. My application did not use a meteorite, and it used a buildpack horse.

1. make a dump of your local mongo db

In the terminal (NOT mongo shell) in the folder of your application,

 mongodump --port=3001 -o ../dump 

2. move the db files from "dump / your-db-name" to "dump"

In my local meteor instance, the / dump folder was placed in a folder above my application, so the "dump" was in the same directory as my application folder. The "dump" contains a folder with the name after my database ("dump / my-database-name /"). This causes the following script to fail with the mongorestore error, "I don’t know what to do with" my-database-name ". To prevent the error, move all the files in the" my-database-name "folder to" dump ", then delete the folder" my-database-name ".

By default, your database name is "meteorite", so if you have not changed it, look for "dump / meteor /".

3. in mLabs, if you have not already done so, create a user with administrator rights. For me, the default user assigned during setup did not work.

4. Push your resettable database onto mLabs for your Heroku application. . It is assumed that you added the mLabs plugin to your Heroku application and set "MONGO_URL" to the Heroku application configuration. If this is not done, they must be performed first.

In the terminal (and not in the mongo shell), go from the application directory to the directory where the dump directory is located. In my case, it was just "cd ../".

Get your default β€œimport” script by going to the mLabs plugin for your Heroku application and going to the β€œTools” tab. This script did not work for me, but it might work for you. If this is not the case, paste this script, while the variables replace the brackets (also replace the brackets).

 mongorestore -h [your mLabs value] -d [your mLabs default user name] -u [your mLabs created user name] -p [your mLabs created user password] 

After running the script, you can refresh the mLabs Collections tab and view your details.

Good luck :) Hope this helps someone!

0
source

Source: https://habr.com/ru/post/1443165/


All Articles