📜 ⬆️ ⬇️

Easy to deploy Meteor applications to your own server

You can do everything you need with Meteor, and you can do it easily. This approach inspired the developers to add the meteor deploy command, which should magically close all application deployment needs. But not closed.

meteor deploy only works if you use Galaxy cloud solution (from $ 0.035 per hour) or free hosting on Meteor.com (which is already closing on March 25).

You can launch the application on your server: you need to build it under the selected platform, send it to the server and start it as an ordinary Node.js application. True, error messages will sprinkle instead of running. For everything to go well, it is important to use the correct version of Node.js. Here is a guaranteed instruction.
')

Server Tuning


You will need a server with Ubuntu 14.04 LTS. For example, a droplet in DigitalOcean . Configure ssh access with a key without a password and install Node.js 0.10.x.
 curl -sL https://deb.nodesource.com/setup_0.10 | sudo bash - apt-get install nodejs 

Install Mongo from the repository.
 apt-get install mongodb-server 

Install Forever to restart the application in case of problems.
 npm install -g forever 

If you need a spiderable package, install PhantomJS.
 apt-get install phantomjs 


Application deployment


Build the application on your local machine.
 meteor build --architecture os.linux.x86_64 

Copy meteor.tar.gz to the server (for example, in / home / meteor).
 scp /tmp/meteor.tar.gz sashagrey:/home/meteor 

Unpack the tarball on the server and install all the necessary packages.
 tar -xf meteor.tar.gz cd /home/meteor/bundle/programs/server && npm install 

Set up environment variables.
 export PORT=80 export MONGO_URL=mongodb://localhost:27017/meteor export ROOT_URL=http://example.com 

Run the application.
 forever start /home/meteor/bundle/main.js 


United team


Usually, I store the entire meteor code in a separate meteor folder inside the project. In package.json, I add a script that performs all the steps described above and runs the application on the server (it is assumed that you can access your server with the ssh sashagrey ).
 { "scripts": { "deploy": "cd meteor && meteor build /tmp --architecture os.linux.x86_64 && scp /tmp/meteor.tar.gz sashagrey:/home/meteor && rm /tmp/meteor.tar.gz && ssh sashagrey 'forever stopall && cd /home/meteor && tar -xf meteor.tar.gz && rm meteor.tar.gz && cd /home/meteor/bundle/programs/server && npm install && export PORT=80 && export MONGO_URL=mongodb://localhost:27017/meteor && export ROOT_URL=http://example.com && forever start /home/meteor/bundle/main.js'", } } 

Is done. Now, to send the application to your own server and run it there, one command is enough.
 npm run deploy 

Source: https://habr.com/ru/post/279103/


All Articles