Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Meteor deployment


May 09, 2021 Meteor


Table of contents


Deployment

Some people like to work undisturbed until the project is perfect enough to be released, while others can't wait to show you their project.

If you're the first person who would rather develop locally now, you can skip this chapter decisively. Conversely, if you prefer to spend time learning how to deploy Your Meteor apps online, here are some ways to do it.

We'll learn a few different ways to deploy a Meteor app. W hether you're developing Microscope or any other Meteor app, you're free to pick one of them at any stage of your development process. Let's get started!

Introduction of appendixes

This is an Appendix section. Unlike other books, the appendix to this book gives us more information about Meteor.

Now if you prefer to continue building Microscope, you can now ignore this chapter and wait until you're free to come back and see it.

Deployed in Meteor

The first and simplest step is to deploy to Meteor's sub-domain name http://myapp.meteor.com which is the first thing we need to learn. Early in the project, this was useful for showing your app and setting up a test server quickly.

And deploying in Meteor is very simple. Open the terminal, locate the directory of your Meteor app, and enter:

meteor deploy myapp.meteor.com

Of course, you want to replace "myapp" with the name you want, preferably one that is not used. I f your name is already in use, Meteor will prompt you to enter your password. If this happens, simply cancel the current operation with ctrl+c and try again with a different name.

If the deployment is successful, you'll be able http://myapp.meteor.com on your app in a few seconds.

You can refer to the official documentation to learn more about how to access the database under your domain name directly, or set up a custom domain name for your app, and more.

Deployed in Modulus

Modulus is a great choice for .js Node applications. This is one of the few providers of PaaS (platform-as-a-service as a service) and has officially supported Meteor, and there are already many people on it to build the Meteor app.

You can learn more about Modulus by reading their Deployment Meteor app guide.

Meteor Up

While new cloud solutions come out every day, they often have their own problems and limitations. C urrently, deploying Meteor apps on your own servers is the best way to do this. The trouble is, however, that deploying to your own servers isn't that easy, especially if you focus on the quality of your product deployment.

Meteor Up is mup way to help you resolve installation and deployment issues with command-line actions. So let's look at how to deploy Microscope with Meteor Up.

Before that, we needed a server to publish. We recommend using Digital Ocean (minimum $5 per month), or AWS (which is free for small instances, if you just want to play Meteor Up).

Whichever service you choose, you should address three things: your server's IP address, login account root ubuntu and login password. Keep them safe and we'll use them soon.

The initialization of Meteor Up

First, we need to install Meteor Up via npm

npm install -g mup

We'll then create a separate directory that provides a specific deployment environment for our Meteor Up. We use a separate directory for two reasons: First, it's good to avoid including any hidden files from your Git repository, especially if you're operating in a public code base.

Second, by using multiple separate directories, we were able to manage and configure multiple Meteor Ups in parallel. This will be used for the deployment of actual products and the deployment of segmented instances.

So let's create this new directory and use it to initialize a new Meteor Up project:

mkdir ~/microscope-deploy
cd ~/microscope-deploy
mup init

Share via Dropbox

A good way to make sure that you and your team use the same deployment settings is to put your Meteor Up configuration folder on your Dropbox, or any similar service.

The configuration of Meteor Up

When a new project is initialized, Meteor Up creates two files: mup.json and settings.json

mup.json all the settings we settings.json all the settings for the app (OAuth token, Analytics token, etc.).

The next step is to configure your mup.json file. mup.json generated by default mup init is executed, and all you have to do is fill in the blanks:

{
  //server authentication info
  "servers": [{
    "host": "hostname",
    "username": "root",
    "password": "password"
    //or pem file (ssh based authentication)
    //"pem": "~/.ssh/id_rsa"
  }],

  //install MongoDB in the server
  "setupMongo": true,

  //location of app (local directory)
  "app": "/path/to/the/app",

  //configure environmental
  "env": {
    "ROOT_URL": "http://supersite.com"
  }
}

Let's take a look at these settings.

Server authentication

You'll notice that Meteor Up provides password-based and private key-based (PEM) authentication, so it can be used by virtually any cloud provider.

Important: If you choose to use password-based authentication, make sure you have sshpass before then.

MongoDB configuration

The next step is to configure the MongoDB database for your app. We recommend using Compose or other providers that provide MongoDB in the cloud because they provide professional support and better management tools.

If you decide to use Compose, setupMongo false and MONGO_URL environment variables to the env module in mup.json env If you decide to access MongoDB through Meteor Up, you just need setupMongo true and Meteor Up will do the rest.

Meteor app path

Because Meteor Up is configured in different directories, we need to app property to bring Meteor Up back to the app. Just set your full local path, and when you're in your app catalog, you can pwd command to get it.

Environment variables

You can specify all the environment variables for your app in the env module ROOT_URL MAIL_URL MONGO_URL etc.)

Set up and deploy

Before we can deploy, we also need to set up a server to host meteor applications. Meteor Up encapsulates this complex process in a simple command!

mup setup

It may take a few minutes, depending on the performance of the server and the speed of the network connection. After the setup is successful, you can finally deploy our app:

mup deploy

This will package our Meteor app and deploy it to the server we just set up.

The log information is displayed

Logs are also very important, and Meteor Up provides a very simple way to handle it by tail -f command and entering:

mup logs -f

This section provides an overview of the use of Meteor Up. To learn more about it, we recommend that you take a look at Meteor Up's details on GitHub

These three ways of deploying Meteor apps should be sufficient for most cases. O f course, we know that some people would like to go further and control and set up their Meteor servers. But this will be another subject, or another book!