-
Notifications
You must be signed in to change notification settings - Fork 3
Deployment
This section includes two main sub-sections, one is for deploying the app on a new Ubuntu machine 'deployment from scratch', and the other one is for deploying a new release on production
As indicated above, this guide assumes that your server runs Ubuntu 14.04, you can modify the steps to match your distro .
This guide follows the latest deployment approach that we are using and should be updated whenever we are using a new strategy .
It's assumed that you have root privileges on the server
Bundling the app using meteor build
and running as a node app
-
Boot up your machine and update your packages
$ apt-get update && apt-get upgrade
-
Install build-essentials
$ apt-get install build-essentials
-
$ apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 $ echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.2.list $ apt-get update $ apt-get install -y mongodb-org $ service mongod start
-
Install node (Here we are using NVM)
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
reset your terminal or
source
your.bashrc
We are going to install node 0.10.40, that's pretty old, but it's due to dependency problems here and there
$ nvm install 0.10.40 $ nvm use 0.10.40 $ nvm alias default 0.10.40
-
We will use forever to monitor and keep our node app running
$ npm install -g forever
-
Prepare the
start.sh, server.sh, stop.sh
scripts which can be found in the repo underbash-scripts/
-
server.sh
runs your node app and sets the properenv variables
-
start.sh
runs yourserver.sh
with forever -
stop.sh
stops your nodeapp and forever tasks - Make your scripts executable
$ chmod +x server.sh start.sh stop.sh
-
-
Install Nginx as we will use it as a reverse proxy
$ apt-get install nginx
- Create your nginx config file under
/etc/nginx/sites-enabled
- Restart nginx service
service nginx restart
- Create your nginx config file under
-
Go to your Local Machine and run
meteor build .
to create the tarball containing the packageWe are avoiding creating the bundle on the server because of it's high resources usage, however you can install and run meteor on the server
-
Remove the old bundle directory
-
Copy your tarball to the server, you can do this using
scp
but that would be super slow$ scp local/path/to/tarball server:~/
Instead you can upload the file to Google Drive into a public folder
-
Grab the sharable link
-
Visit it in a window that doesn't have an active session of your Google account (Incognito for example)
-
Click download and copy the download link
-
On the server download the file using
wget
for example$ wget http://google.drive.download.link
-
Rename the downloaded link to a tarball and unpack it
$ mv downloaded-file-name something.tar.gz $ tar -xzvf something.tar.gz
-
-
cd
into the bundle directory and install modules$ cd ~/bundle/programs/server $ npm install $ cd ~/bundle
-
If
forever
didn't watch the change, you may want to restart it manually by runningstop.sh
andstart.sh