Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samuelluis/69267d7310cbec6843b1bae1c1f54dfa to your computer and use it in GitHub Desktop.
Save samuelluis/69267d7310cbec6843b1bae1c1f54dfa to your computer and use it in GitHub Desktop.

Tutorial: Meteor on Windows using Vagrant

Requirements

Before doing anything else, install those:

Steps on Windows command-line:

Open cmd: Start > type cmd > ENTER

  1. cd C:\path\to\your\app\or\workspace\folder
  2. set PATH=%PATH%;C:\Program Files (x86)\Git\bin (Append git binaries to path so vagrant can run ssh - you should add git to your PATH environmental variable permanently so you don't have to run this everytime)
  3. vagrant init ubuntu/trusty64 (Ubuntu 14.04 64bit - use ubuntu/trusty32 for x86)
  4. Edit the Vagrantfile and add the following inside the Vagrant.configure(...) block:
    config.vm.synced_folder '.', '/home/vagrant/<your-app-or-workspace-name>'
    
    config.vm.network :public_network
    config.vm.network :forwarded_port, guest: 3000, host: 3000
    
    config.vm.provider "virtualbox" do |vb|
        vb.gui = false
        vb.memory = 2048
        vb.cpus = 2
        vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
    end
    
  5. vagrant up
  6. vagrant ssh

Now that you are inside the VM command-line:

Steps on Ubuntu command-line:

  1. sudo apt-get install curl git
  2. curl https://install.meteor.com | sh

Creating an app

This also applies when you clone an app from git. The idea is to move the .meteor folder out of the shared directory and link it back in. MongoDB cannot run in the shared folder because of permission problems. Create all apps in ~/<your-app-or-workspace-folder> to make their code available to the Windows host.

  1. cd ~/<your-app-or-workspace-folder>
  2. meteor create <your-app-name> (if doesn't exist)
  3. cd <your-app-name>
  4. mkdir -p ~/mock/<your-app-name>
  5. mv .meteor ~/mock/<your-app-name>
  6. mkdir .meteor
  7. sudo mount --bind /home/vagrant/mock/<your-app-name>/.meteor .meteor
  8. meteor (finally!)

Go to http://localhost:3000 in Windows browser!

Hints:

  • Make sure you do version control (git, svn, etc.) INSIDE THE VM, so the software can follow the mounted .meteor directory.
  • If your version controll tool find changes in all files for mode change you can do git config core.filemode false to ignore it.
  • You can automate the mount the .meteor directory (step 7 above) by adding to ~/.bashrc this line: sudo mount --bind /home/vagrant/mock/<your-app-name>/.meteor <your-app-path>/.meteor. Otherwise you will have to remount the .meteor directory on every vagrant restart. Mount the directory before you do any version control!
  • To halt a vagrant VM: vagrant halt
  • To backup or snapshot vagrant plugin install vagrant-vbox-snapshot (documentation), then you can do vagrant snapshot take <your-snapshot-name> (better after a vagrant halt)
  • To destroy a VM: vagrant destroy (WARNING! you will lose all your previous configuration)
  • You might want to run sudo apt-get update in the VM to install the latest Ubuntu security updates

Original tutorial by @gabrielsapo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment