jkrup / meteor-hero

Instantly deploy your Meteor apps with `meteor-hero`
39 stars 3 forks source link

build fails to deploy at mlab/mongolab (mongoDB) add-on #2

Open alimgafar opened 5 years ago

alimgafar commented 5 years ago

If the account does not have a credit card on file, the build crashes and fails to deploy when it adds the mongoDB database through mLab.

alimgafar commented 5 years ago

This is by design. Heroku offers mongoDB through mLab (formerly mongoLab) as an integrated “add on” feature. A free tier is provided, which includes an instance with very limited storage. This convenience allows developers to build and connect applications to a mongoDB database directly from the heroku dashboard or cli. meteor-hero takes advantage of this free instance when a database is not specified.

The meteor framework bakes mongoDB in as its native persistence layer. When you install meteor, a local copy of mongoDB comes bundled. This makes it easy to start developing storage-dependent applications without having to install and configure a database server separately. You can find it in the application’s .meteor/local/db folder.

However, when you run the build process over your application, meteor doesn’t include that mongoDB instance. If your application requires mongoDB, you are required to provide a connection string to an instance via a MONGO_URL environment variable.

When the user doesn’t supply a MONGO_URL, meteor-hero defaults to creating a database in mLab and setting that environment variable with a connection string to this newly-created instance.

The documentation should be updated to reflect these two pre-conditions: (1) a valid credit card must be on file with your heroku account if your application requires a database for its build and doesn’t already have one, and (b) enviroment variable MONGO_URL set with a valid connection string and passed in a configuration file if the application does have an existing, externally-accessible mongoDB instance or cluster (self-hosted, cloud-based, Atlas, etc.).

alimgafar commented 5 years ago

Regarding the oplog, which meteor uses for reactive updating: it is not available in Heroku’s free (sandbox) tier. It is, however, available in its Shared tier (assuming using environment variable MONGO_OPLOG_URL); Dedicated tier users are required to use mongoDB Share Streams instead. Visit https://docs.mlab.com/oplog/ for more information.

rikkiprince commented 4 years ago

@alimgafar Are you saying that meteor-hero needs a credit card on file with Heroku, even if a MONGO_URL is supplied? I'm running:

meteor-hero -e MONGO_URL="mongodb://etc...

And it is failing because of the lack of credit card. That said, it also says "No MONGO_URL set so creating one on Heroku..." in its output, and I don't understand why!

alimgafar commented 4 years ago

@rikkiprince meteor-hero doesn't require the credit card; Heroku does. meteor-hero uses Heroku APIs to facilitate the setup.

Heroku uses the concept of a verified account before allowing you to use an add-on, whether it is from the UI or by the API. Verification requires adding a valid credit card to your billing info in Heroku. (See https://devcenter.heroku.com/articles/account-verification and see section When is verification required?)

The free MongoDB sandbox from mLab is an add-on.

rikkiprince commented 4 years ago

Ok, yep, I understand all of that. But I don't understand why meteor-hero is still trying to create the MongoDB sandbox add-on when I supply -e MONGO_URL="..." in the command line.

This seems like a bug. I perused the source code a little, but couldn't figure out why it might not be detecting the command line argument.

The only way I could get it to recognise the MONGO_URL variable was to use a prod.env file.

But even then once it deployed the container it didn't work, presumably because the node docker image that meteor-hero uses is so out of date? I couldn't debug further because I'm not sure how to get the logs out of a container in Heroku. So it was easier to just use the meteor-buildpack-horse to get my app onto Heroku.