Deploying Server and Client to Azure VM - Plateful/plateful-mobile GitHub Wiki

This guide will walk you through setting up your server on an Azure virtual machine. We will also cover how to deploy updates to the app.

##Creating a Virtual Machine

  1. Login to the Azure management portal.
  2. Select VMs / New / From Gallery
  3. Select a Ubuntu server image (Ubuntu Server 14.04 LTS)
  4. Specify a vm_name and username and check the box to specify a password. You can uncheck the SSH Key box.
    IMPORTANT: You will need to remember these items.
  5. Your virtual machine will be created, this can take a few minutes to complete.

##Configuring Your Virtual Machine

  1. Once your VM has been created login to it form the command line (these are the items you specified above - [email protected] in our case):
    ssh <username>@<vm_name>.cloudapp.net

  2. You'll be prompted for the password you created above. Enter it and you'll have access to your VM.

  3. Follow this guide to install homebrew on your VM. This package will also install some utilities like git on your VM. IMPORTANT: Make sure to navigate to the .bashrc and enter the specified lines (brew will not be a recognized command until you do this). You will need to reboot the VM once you've completed these steps: sudo reboot.

  4. Intall node: brew install node

  5. Clone your project repo: https://github.com/Plateful/plateful-mobile.git

  6. Navigate to your project directory and run the following commands to install your dependencies:

    npm install
    sudo npm install -g bower    // Install bower command line utility
    sudo npm install -g gulp     // Install gulp command line utility
    sudo npm install -g cordova  // Install cordova command line utility
    cordova plugin add org.apache.cordova.camera  //Installs cordova plugins
    cordova plugin add org.apache.cordova.device
    cordova plugin add org.apache.cordova.file
    cordova plugin add org.apache.cordova.file-transfer
    cordova plugin add org.apache.cordova.geolocation
    cordova plugin add org.transistorsoft.cordova.background-geolocation
    gulp  // Builds app, runs bower install, server and static server.
    

Once this process is complete your app should be up and running.

  1. Next you need to install forever, so you can continuously run your server and client:

    sudo npm install forever
    forever start server/app.js
    forever start server/staticServer.js
    

To view a list of forever tasks running: forever list
To stop a task (use the index number of the task to stop): forever stop 0

  1. Your VM is configured. Go ahead and log out. The last thing you'll need to configure is your ports, so you can access your server and app:

    azure vm endpoint create-multiple <vm_name> 9000:9000   // Set-up server port
    azure vm endpoint create-multiple <vm_name> 4400:4400   // Set-up client port
    

##Deploying Updates

  1. Once the project master is production-grade and ready for deployment, login to your VM.

  2. From your project directory pull down the changes: git pull --rebase origin master

  3. Stop your forever processes: forever stopall

  4. Run the following commands to install new dependencies and build your app:

    npm install
    gulp
    
  5. Finally restart your forever server:

    forever start server/app.js
    forever start server/staticServer.js
    
⚠️ **GitHub.com Fallback** ⚠️