Ever since the Meteor Development Group dropped their free hosting support, things haven’t been the same anymore in the Meteor community. The days when you can simply write
meteor deploy and magically see your app get deployed and available to the world for free were gone. Until
A company called ZEIT has developed a hosting and deployment service that allows developers to deploy any static site or any app (Node, PHP, COBOL, etc.) for free. Simply writing the command
nowin your project folder and the tool will deploy the app and give you a unique URL for the deployment. They call it immutable deployments. Genius!
I’ve been using
nowfor personal React/Node projects for a few months now but never for Meteor app. Well, during one of our weekly Meteor Office Hours in NYC, Justin and myself were answering questions on the options for deploying a Meteor app. I was always talking about
nowand Justin was always tinkering with Docker. After some trial and error, we got a working Meteor app deployed using
now. This gave us the idea for writing a small wrapper tool on top of the
now CLI that specifically deploys Meteor apps. We’re calling it
In this article, we’re going to deploy a standard Meteor app from scratch.
To get started, download and install ZEIT’s
now tool along with our
meteor-now package. You will be using
now CLI tool to manage your Meteor deployments. We recommend it!
$ npm install -g now meteor-now
In your terminal, type:
$ now --login
> Enter your email: <your email>
> Please follow the link sent to <your email> to log in.
> Verify that the provided security code in the email matches Pragmatic Manta Ray.
✔ Confirmed email address!
> Logged in successfully. Token saved in ~/.now.json
Enter your email address and click on the link in the email you receive. That’s it for getting set up. This is a one time step if you have never used
After that, let’s simply create a new meteor app and install the deps:
$ meteor create meteor-test
$ cd meteor-test
$ npm install
Back in the old
meteor deploy days, MDG was kind enough to provide a free MongoDB instance for your Meteor app and automatically link your app to it. Unfortunately, we have to replicate this step as well. Lucky for us, there are some free hosting solutions out there that we can use including mLabs sandbox free tier. This is perfect for demos and MVP’s.
We’re not going to go into how to set up MongoDB, but you will need to get the connection string for your MongoDB instance before you can deploy. Otherwise, your Meteor app will not work.
In order to deploy, Meteor usually needs two environment variables,
ROOT_URL. However, in our case since its the barebones Meteor app, there is no backend so just
ROOT_URL is fine. To have those variables be available to your Meteor app, pass them as arguments with the
-e flag to
meteor-now. This follows the exact format as described here.
$ meteor-now -e ROOT_URL=http://meteor-test.com
What happens under the hood is that the Meteor app will be bundled using
meteor build. Then we prepare a Dockerfile that has the appropriate instructions and steps to run our Meteor app. From there,
now takes over by uploading, building, and deploying the docker container for our app.
After a minute or so, your Meteor app should be deployed and ready. Check the console output for a unique link to your app.
Every time you deploy,
now will generate a unique URL for your deployment. And as a bonus, every deployment comes with full SSL and HTTP/2 support!
You can use
now alias to change the URL to something more memorable. Check out this blog post on how to do that.
That’s it! This is a very early project. From idea to product it took us a weekend. There is a lot more to do and improve. We would love contributions if you are interesting in helping out.
Hope you enjoy using it!
Edit: Simplified and removed unnecessary steps.