Deployment Guide
This guide is written to get your Vulcan app deployed and running on a remote server.
Deploying a Vulcan app is much like deploying a Meteor app. If something isn’t addressed here, it might be in the official documentation.
Meteor Up
The recommended way to deploy Vulcan is by using Meteor Up.
Configuration
You should have a Linux server online, for instance a Digital Ocean droplet running with Ubuntu.
Here’s a guide to a good initial server setup.
On your local development machine, install the latest Meteor Up release.
1 | npm install -g mup |
Create Meteor Up configuration files in your project directory with mup init
. In the example below, the configuration files are created in a .deploy
directory at the root of your app.
1 | cd my-app-folder |
This will create two files:
1 | mup.js - Meteor Up configuration file |
Then, replace the content of the newly created settings.json
with your own settings (you can use the content of sample_settings.json
as a starter).
To quickly get up and running, copy/paste the following configuration and edit it to reflect your environment:
Please refer to the official Meteor Up starting guide for more in-depth instructions.
The official mup.js configuration examples and the possible options are found here.
1 | module.exports = { |
You do not have to edit the mongo settings unless you are using a custom database setup.
Setup your server
From the ./deploy
folder, you can now set up the remote servers you have specified in your config.
It will take around 2-5 minutes depending on the server’s performance and network availability.
1 | mup setup |
Deploy your app
Still in the ./deploy
folder, to deploy your app with your settings file:
1 | mup deploy --settings settings.json |
This will bundle the Meteor project locally and deploy it to the remote server(s). The bundling process is the same as what meteor deploy does.
If you are using the two-repo install you must specify the path to your package directory:
1 | METEOR_PACKAGE_DIRS="/Users/sacha/Vulcan/packages" mup deploy --settings settings.json |
(Taking care to adapt the /Users/sacha/Vulcan/packages
path to point to your Vulcan core repo’s /packages
directory)
Utility Commands
mup reconfig
- reconfigures app with new environment variables, Meteor settings, and it updates the start script. This is also the last step of mup deploy.mup stop
- stop the appmup start
- start the appmup restart
- restart the appmup logs [-f --tail=50]
- view the app’s logs. Supports all of the flags fromdocker logs
.
Troubleshooting
Official docs on deploying with Meteor Up
- Troubleshooting docs
- Common problems
meteor npm install --save bcrypt
.- Increase
deployCheckWaitTime
.
Meteor Now
Another simple option to get your app live for no cost is by using Meteor Now.
Meteor-now is a tool to let you instantly deploy your Meteor apps with one command using ZEIT’s ▲now service.
Configuration
Install the now
and meteor-now
packages:
1 | npm install -g now meteor-now |
Create now account
1 | $ now --login |
Deploy
Now on your root folder, run the following command:
1 | meteor-now -d -e ROOT_URL=https://mydomain.now.sh -e NODE_ENV=production` |
Change mydomain
with your custom domain name. meteor-now
will automatically look for a file named production.settings.json
at the root of your application. For a staging deployment, you can also set NODE_ENV=development
, meteor-now
will then look for development.settings.json
instead.
You can also add -e MONGO_URL=mongodb://<username>:<pass>@....
for persistance storage of data. We recommend you using a service like mlab.
If you are using the two-repo install you must specify the path to your package directory:
1 | METEOR_PACKAGE_DIRS="/Users/sacha/Vulcan/packages" meteor-now ... |
(Taking care to adapt the /Users/sacha/Vulcan/packages
path to point to your Vulcan core repo’s /packages
directory)
Note that the METEOR_PACKAGE_DIRS
variable is only used locally by the machine that runsmeteor-now
during build, you must not send it to the server with the -e
option, contrary to other variables.
After your deployment is done, create an alias to the domain you just specified. Just copy the hashed link provided by the now deployment. It should be copied to your clipboad. It usually follows this format: https://xxxxxxxxx.now.sh
.
1 | now alias set https://xxxxxxxxx.now.sh https://mydomain.now.sh |
That’s it! now visit https://mydomain.now.sh
.
For more info, for how to get a custom domain name run now -h
. You may need a premium now account.
PM2
Contributed by adalidda.
Deploy Vulcan GraphQL/Apollo version with PM2
Server Setup
On Ubuntu 14 or better.
Install nvm
Run the following command
1 | sudo apt-get update |
Check that node 4.7.3 is your default node version, with the command nvm ls
.
Install PM2
1 | sudo npm i -g pm2 |
Check that your PM2 is working with the following commands:
pm2 list
=> list the process under PM2pm2 -v
=> list PM2 version
Install nginx for the management of your host server
1 | sudo apt-get install nginx |
Note: I suggest to use the docker version of nginx
Development Setup
Install pm2-meteor on your Development computer
1 | npm i pm2-meteor -g |
Create a deployment folder with mkdir deploy
1 | Cd deploy |
Type the following command to init the default deployment file: pm2-meteor init
.
pm2-meteor will then create a file pm2-meteor.json
.
Edit your pm2-meteor.json
with your own parameters.
Below is my pm2-meteor.json given as reference.
You note that I use the nvm
command in my pm2-meteor.json
, because without using the nvm command, pm2 will use Node version on your server that may be not compatible with the one required by Vulcan GraphQL/Apollo (which is node version 4.7.0 or 4.7.3) and in this case pm2 will generate high use of your CPU around 100% !
1 | { |
Deploy your app to the host server
Type the following command
1 | cd deploy |
Useful Commands
Type the following command to check the status of your app on the serverpm2 list
To Stop your App, typepm2 stop myappname
To restart your App, typepm2 restart myappname
To delete your App, typepm2 delete myappname
References
- How to deploy Meteor Apps with pm2-meteor
- pm2 2.3.1-next
- How To Install Node.js on Ubuntu 16.04
- Heroku deployment instructions