On this page

Deploy Meteor.js applications

Overview

Clever Cloud allows you to deploy any Meteor.js application. This page will explain how to set up your application to run it on our services.

Be sure your .meteor folder is in your git repository.

Create an application on Clever Cloud

via the web console

  1. Create a new app by clicking on the Add an Application button, in the sidebar.
  2. Select a brand new instance (or a repository from GitHub if your account is linked).
  3. Then select Meteor.js in the platform list.
  4. Configure your scaling options.
  5. Enter your application’s name and description and click “Next”. You can also select the region you want (North America or Europe).

Refer to https://www.clever-cloud.com/doc/getting-started/ for more details on application creation via the console.

via the Clever Tools CLI

  1. Make sure you have clever-tools installed locally. Report to https://www.clever-cloud.com/doc/reference/clever-tools/getting_started/
  2. In your code folder, do clever create --type <type> <app-name> --region <zone> --org <org> where type is the type of technology you rely on, app-name the name you want for your application, zone deployment zone (par for Paris and mtl for Montreal), and org the organization ID the application will be created under.

Refer to https://www.clever-cloud.com/doc/reference/clever-tools/create/ for more details on application creation with Clever Tools.

Setting up environment variables on Clever Cloud

With the Clever Cloud console

  1. Go to the Clever Cloud console, and find the app you want to fine tune under it’s organization.
  2. Find the Environment variables menu and select it.
  3. In this menu, you will see a form with VARIABLE_NAME and variable value fields. Fill them with the desired values then select Create.

With the Clever Tools CLI

  1. Make sure you have clever-tools installed locally. Report to https://www.clever-cloud.com/doc/reference/clever-tools/getting_started/
  2. In your code folder, do clever env set <variable-name> <variable-value>

Refer to https://www.clever-cloud.com/doc/reference/reference-environment-variables/ for more details on available environment variables on Clever Cloud. You can of course create custom ones with the interface we just demonstrated, they will be available for your application.

Configure your Meteor.js based application

Mandatory configuration

Set up environment variables

To run your Meteor.js application you need a few mandatory environment variables:

  • MONGO_URL: this is the mongo uri you can find in your mongodb’s dashboard, it has to start with mongodb://
  • ROOT_URL: this is your application’s root url. It has to start with http:// or https://
  • PORT: keep the current value of 8080
Optional Meteor settings as environment variable

Some application require a settings.json file to store api keys and other various private and public Meteor variables. You can declare a METEOR_SETTINGS environment variable and past the content of the json file as the value of this key.

Specify required Node.js version

Since building with the latest version of Node.js might fail, you should specify in the package.json file of the application the version needed for your Meteor application ; as shown in Deploying Node.js apps documentation. To find out which version is required by your application type the following command meteor node -v inside root folder.

Currently with Meteor 1.8.3 the Node.js version is 8.17.0 so you should add the following inside the package.json file.

  ...
  "engines": {
    "node": "8.17.0"
  },
  ...

You may change the node version value according to the application requirements.

Activate the dedicated build

Meteor.js uses a lot of memory during the build. You most likely will need to activate the dedicated build feature and set your vertical scaling size at least to M.

If your build still fails after you enabled the feature, please contact us on the support so we can set you a bigger scaler.

Automatic HTTPS redirection

You can use the force-ssl atmosphere package to redirect your users to the HTTPS version of your application.

Custom start parameters

If you want to set custom start parameters, the main entry point of built meteor applications is: .build/bundle/main.js. Add in the scripts.start field of the package.json: node .build/bundle/main.js <parameters>

Deployment process on Clever Cloud

At each deployment, the needed Meteor.js version will be read from .meteor/release and installed. Your application will then be built using meteor build --server-only and deployed from the files created by this command.

Environment injection

Clever Cloud injects environment variables from your application settings as mentioned in setting up environment variables and is also injecting in your application production environment, those from your linked add-ons.

Git Deployment on Clever Cloud

You need git on your computer to deploy via this tool. Here is the official website of Git to get more information: git-scm.com

Setting up your remotes

  1. The “Information” page of your app gives you your git deployment URL. It looks like this: git+ssh://git@push.clever-cloud.com/<your_app_id>.git. Copy it in your clipboard.

  2. Locally, under your code folder, type in git init to set up a new git repository or skip this step if you already have one.

  3. Add the deploy URL with git remote add <name> <your-git-deployment-url>.

  4. Add your files via git add <files path> and commit them via git commit -m <your commit message>.

  5. Now push your application on Clever Cloud with git push <name> master

Refer to https://www.clever-cloud.com/doc/getting-started/quickstart/ for more details on git deployments.

Linking a database or any other add-on to your application

By linking an application to an add-on, the application has the add-on environment variables in its own environment by default.

On add-on creation

Many add-ons do exist on Clever Cloud, please refer to the full list and check add-ons dedicated pages for full instructions.

During add-on creation, you will see Applications screen, with a list of your applications. You can toggle the button to Link and click next. If you finish the process of add-on creation, the application will automatically be linked to it.

Add-on already exists

In the Clever Cloud console, under the Service Dependencies menu of your application, you can use the Link addons dropdown menu to select the name of the add-on you want to link and use the add button to finish the process.

You can also link another application from the same page in the Clever Cloud console, using the Link applications dropdown menu.

Oplog Tailing

Oplog tailing is supported on dedicated databases (starting from Hazelnut size). Contact the support to enable oplog. Once enabled, set the following environment variable:

  • MONGO_OPLOG_URL: mongodb://[…]mongodb.services.clever-cloud.com:{DB_PORT}/local?authSource={DB_NAME}

Migrate from a Node.js instance

If you want to migrate from your classic node.js app to a meteor application, contact our support in the console or at support@clever-cloud.com with the application id.

More configuration

Need more configuration? To run a script at the end of your deployment? To add your private SSH key to access private dependencies? Go check the Common configuration page.

You may want to have an advanced usage of your application, in which case we recommend you to read the Administrate documentation section.

If you can’t find something or have a specific need like using a non supported version of a particular software, please reach out to the support.