Meteor on Scalingo
Meteor is a complete open source platform for building web and mobile apps in pure JavaScript. It focuses problematics around real time web to emphasize the most fluent experience possible.
Getting Started Tutorial
Deploy your first Meteor application: follow the guide
Deploy an existing application like Telescope: follow the guide
Meteor App Detection
The directory .meteor
should be present at the root of your project
Meteor Dependencies Installation
- Using Meteor embedded dependency management (with
meteor add
andmeteor update
) - Using
npm
package manager (withmeteor npm <command>
)
Node and npm Versions
If defined, Node.js version and npm version are read from the engines
section of the package.json
file. If no version is defined, we’ll install the latest stable version compatible with your Meteor application.
{
"name": "myapp",
"engines": {
"node": "4.8.x",
"npm": "3.x"
}
}
Meteor | Node.js | npm | yarn |
---|---|---|---|
>= 2.3 | 14.17.x | 6.x | 1.x |
2.2 | 12.22.x | 6.x | 1.x |
2.1 | 12.22.x | 6.x | 1.x |
2.0 | 12.20.x | 6.x | 1.x |
1.12 | 12.16.x | 6.x | 1.x |
1.10 | 12.16.x | 6.x | 1.x |
1.8 | 8.16.x | 6.x | 1.x |
1.6 | 8.8.x | 5.x | 1.x |
1.5 | 4.8.x | 4.6.x | n/a |
1.4 | 4.8.x | 4.6.x | n/a |
<= 1.3 | 0.10.x | 3.x | n/a |
Meteor App Startup
A script named .start-meteor-app
is automatically generated after the build of your application. Its role is to start correctly your application.
Generated .start-meteor-app
:
cd .app-build/bundle/programs/server
exec node boot.js program.json
The buildpack also generates a .release
file
default_process_types:
web: ./.start-meteor-app
If no Procfile
exists, the web type of the .release
will be executed by
default. If your wish to write your own Procfile
don’t forget to keep this
line for your web
process, otherwise your application may not boot.
Configuration
Meteor Settings
If you have a settings.json
or a config/settings.json
file that you usually
run with meteor --settings settings.json
, you have nothing to do. It will be
handled by our deployment system, but this method is deprecated.
Storing configuration data like credentials in a file present in your Git
repository is not recommended. We advise you to use the environment variable
METEOR_SETTINGS
, the variable is automatically read by Meteor and it stays
out of your code repository. You have to set the content of this environment
variable (with our CLI or through
your web dashboard) to match the content of your settings.json
file.
Furthermore, using this method allows you to manage easily multiple environment
of the same app.
If you’re using a settings.json
file, here is the method to migrate to an environment-based
setup:
$ echo 'settings.json' >> .gitignore
$ git rm --cached settings.json
$ git add .gitignore
$ git commit -m "Add settings file to gitignore to avoid having credentials in code"
$ scalingo env-set METEOR_SETTINGS="$(cat settings.json)"
$ git push scalingo master
Custom Timezone
The default timezone of your containers is UTC. You can set it to a different value by setting the
environment variable TZ
with the desired timezone:
scalingo --app my-app env-set TZ=Europe/Paris
A list of existing timezones is available here.
Built-In Mobile Integration
If you need to use your application as a backend for your Android or iOS
application, don’t worry. It is done by default by the platform. You need
to use Meteor ≥ 1.3, if that’s the case, the flag
--server-only
will be used to build your app. Finally, your mobile apps will be able to communicate
with it without any problem.
Debug Build
By default, Meteor minify all your assets to stand in one single JavaScript file, if you want to make a ‘debug’ build (assets un-minified), please define the following environment variable:
scalingo env-set METEOR_DEBUG_BUILD=true
How to Scale Meteor
As a real time framework, the number of scaling constraints is higher than another more classical framework. Each instance is keeping some stateful information and each instance has to be able to get instantly the most up-to-date data. To achieve that, the two common processes used are the sticky sessions and the oplog feature of MongoDB®.
Oplog
Oplog is a MongoDB® feature which logs all the operations achieved on a MongoDB® cluster. Meteor uses this feature to sync different instances of an application.
It can be enabled from the addon database dashboard. When activated it will automatically add the
MONGO_OPLOG_URL
in your application. This variable name is the standard name to configure
Meteor. Restart your application for this variable to be taken into account.
Sticky Sessions
Session affinity is the process of saving on which instance a given user has been routed, in order to use this route again for a given time. Our load balancers have sticky sessions enabled automatically for Meteor apps. A user will keep using the same route during 1 hour.
You have nothing to do except increasing the amount of containers you are using. To do so, open the dashboard of your application, and in the containers tab increase the amount of needed containers. Click on scale and the amount of instances will be scaled instantly.
Basic Authentication
If you want to setup basic authentication in front of your app, you can use the kit:basic-auth package.
Buildpack
The deployment of Meteor application is handled by our Node.js Buildpack which has been modified to manage particularly Meteor application.
- It detects Meteor application
- Choose the good Node.js version
- Install Meteor runtime
- Build project
- Prepare runtime environment