Textual description of firstImageUrl

Guide to Meteor environment with Vagrant



Sometimes working with Meteor, one may want to move development environment across different machines or want to create consistent environment across machines. This is where Vagrant comes in.

Though the steps below refer specifically about meteor, but can easily tuned for other environments.
Ideas is to run meteor and relevant code inside meteor-box and access to all changes in GUI would run on host machine browser.
I find it convenient but there could differences of opinions.
(The next steps I wanted to try is to mount git repo inside meteor-box to shared location on host machine, but I was facing some issues. May be I could post the same some other time)

In order to use Vagrant, we need to create VagrantFile.
Below is the sample VagrantFile used,

meteor-box TechSutram$ cat VagrantFile
# Settings need update as per user environment
# https://app.vagrantup.com/ubuntu/boxes/xenial64
OS_BOX = 'ubuntu/xenial64'
BOX_NAME = 'meteor-box'
BOX_USER = 'vagrant'
USER_NAME = 'mandar.pise'
HOST_PATH = '/Users/' + USER_NAME + '/VMs/' + BOX_NAME
HOST_GIT_PATH = '/Users/' + USER_NAME + '/VMs/' + BOX_NAME + '/git'
GUEST_PATH = '/home/ubuntu/'+ BOX_NAME
GUEST_GIT_PATH = '/home/ubuntu/git'
METEOR_PATH = '/home/ubuntu/git/meteor'
VM_PORT = 8282

### Below settings need not be changed but there is scope for fine tuning
Vagrant.configure(2) do |config|
  config.vm.box = OS_BOX
  config.vm.hostname = BOX_NAME

  # Set VM name in Virtualbox
  config.vm.provider "virtualbox" do |v|
    v.name = BOX_NAME
    v.memory = 2048
  end

  # sets up default port forwarding from meteor server port 3000 to host 8080
  config.vm.network "forwarded_port", guest: 3000, host: VM_PORT

  # Host path to share inside guest and mount the same
  config.vm.synced_folder HOST_PATH, GUEST_PATH
  #config.vm.synced_folder HOST_GIT_PATH, GUEST_GIT_PATH
  config.vm.synced_folder '.', '/home/'+BOX_USER+'', disabled: true

  # Install curl,git,meteor
  # Add commands as required for your configuration
  # METEOR_PATH did not resolve in inline script
  # need to look at it, meanwhile lets hard-code path
  config.vm.provision "shell", inline: <<-script br="">    apt-get update
    apt-get install curl
    apt-get install git
    mkdir -p /home/ubuntu/git/meteor
    cd /home/ubuntu/git/meteor
    curl https://install.meteor.com/ | /bin/sh
    apt-get upgrade -y
    apt-get autoremove -y
  SCRIPT
end
meteor-box TechSutram$
meteor-box TechSutram$ vagrant up

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/xenial64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/xenial64' is up to date...
==> default: Setting the name of the VM: meteor-box
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 3000 (guest) => 8282 (host) (adapter 1)
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: ubuntu
    default: SSH auth method: password
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Authentication failure. Retrying...
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 5.0.40
    default: VirtualBox Version: 5.1
==> default: Setting hostname...
==> default: Mounting shared folders...
    default: /home/ubuntu/meteor-box => /Users/TechSutram/VMs/meteor-box
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: Hit:1 http://archive.ubuntu.com/ubuntu xenial InRelease
==> default: Get:2 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
==> default: Get:3 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
==> default: Get:4 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
==> default: Get:5 http://security.ubuntu.com/ubuntu xenial-security/main Sources [86.4 kB]
==> default: Get:6 http://security.ubuntu.com/ubuntu xenial-security/restricted Sources [2,604 B]
==> default: Get:7 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [37.8 kB]
==> default: Get:8 http://security.ubuntu.com/ubuntu xenial-security/multiverse Sources [1,144 B]
==> default: Get:9 http://archive.ubuntu.com/ubuntu xenial/main Sources [868 kB]
==> default: Get:10 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [341 kB]
==> default: Get:11 http://archive.ubuntu.com/ubuntu xenial/restricted Sources [4,808 B]
==> default: Get:12 http://archive.ubuntu.com/ubuntu xenial/universe Sources [7,728 kB]
==> default: Get:13 http://security.ubuntu.com/ubuntu xenial-security/main Translation-en [144 kB]
==> default: Get:14 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [154 kB]
==> default: Get:15 http://security.ubuntu.com/ubuntu xenial-security/universe Translation-en [79.0 kB]
==> default: Get:16 http://archive.ubuntu.com/ubuntu xenial/multiverse Sources [179 kB]
==> default: Get:17 http://archive.ubuntu.com/ubuntu xenial-updates/main Sources [269 kB]
==> default: Get:18 http://archive.ubuntu.com/ubuntu xenial-updates/restricted Sources [3,012 B]
==> default: Get:19 http://archive.ubuntu.com/ubuntu xenial-updates/universe Sources [167 kB]
==> default: Get:20 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse Sources [7,232 B]
==> default: Get:21 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [616 kB]
==> default: Get:22 http://archive.ubuntu.com/ubuntu xenial-updates/main Translation-en [249 kB]
==> default: Get:23 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [515 kB]
==> default: Get:24 http://archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [201 kB]
==> default: Get:25 http://archive.ubuntu.com/ubuntu xenial-backports/main Sources [3,312 B]
==> default: Get:26 http://archive.ubuntu.com/ubuntu xenial-backports/universe Sources [4,404 B]
==> default: Fetched 12.0 MB in 30s (389 kB/s)
==> default: Reading package lists...
==> default: Reading package lists...
==> default: Building dependency tree...
==> default:
==> default: Reading state information...
==> default: curl is already the newest version (7.47.0-1ubuntu2.2).
==> default: 0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
==> default: Reading package lists...
==> default: Building dependency tree...
==> default:
==> default: Reading state information...
==> default: Suggested packages:
==> default:   git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk
==> default:   gitweb git-arch git-cvs git-mediawiki git-svn
==> default: The following packages will be upgraded:
==> default:   git
==> default: 1 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
==> default: Need to get 3,163 kB of archives.
==> default: After this operation, 12.3 kB of additional disk space will be used.
==> default: Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 git amd64 1:2.7.4-0ubuntu1.2 [3,163 kB]
==> default: dpkg-preconfigure: unable to re-open stdin: No such file or directory
==> default: Fetched 3,163 kB in 7s (409 kB/s)
==> default: (Reading database ...
(Reading database ... 10%abase ... 5%
==> default: (Reading database ... 15%
(Reading database ... 50%abase ... 20%
(Reading database ... 60%abase ... 55%
==> default: (Reading database ... 65%
==> default: (Reading database ... 70%
==> default: (Reading database ... 75%
==> default: (Reading database ... 80%
==> default: (Reading database ... 85%
==> default: (Reading database ... 90%
==> default: (Reading database ... 95%
(Reading database ... database ... 100%
==> default: 53902 files and directories currently installed.)
==> default: Preparing to unpack .../git_1%3a2.7.4-0ubuntu1.2_amd64.deb ...
==> default: Unpacking git (1:2.7.4-0ubuntu1.2) over (1:2.7.4-0ubuntu1.1) ...
==> default: Setting up git (1:2.7.4-0ubuntu1.2) ...
==> default:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
==> default:                                  Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0
==> default:  0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100  7784    0  7784    0     0   4178      0 --:--:--  0:00:01 --:--:--  4178
==> default: Downloading Meteor distribution
==> default:
==> default: Meteor 1.5.1 has been installed in your home directory (~/.meteor).
==> default: Writing a launcher script to /usr/local/bin/meteor for your convenience.
==> default:
==> default: To get started fast:
==> default:
==> default:   $ meteor create ~/my_cool_app
==> default:   $ cd ~/my_cool_app
==> default:   $ meteor
==> default:
==> default: Or see the docs at:
==> default:
==> default:   docs.meteor.com
==> default: Reading package lists...
==> default: Building dependency tree...
==> default:
==> default: Reading state information...
==> default: Calculating upgrade...
==> default: The following packages will be upgraded:
==> default:   git-man
==> default: 1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
==> default: Need to get 736 kB of archives.
==> default: After this operation, 0 B of additional disk space will be used.
==> default: Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 git-man all 1:2.7.4-0ubuntu1.2 [736 kB]
==> default: dpkg-preconfigure: unable to re-open stdin: No such file or directory
==> default: Fetched 736 kB in 9s (77.5 kB/s)
==> default: (Reading database ...
(Reading database ... 60%abase ... 5%
==> default: (Reading database ... 65%
==> default: (Reading database ... 70%
==> default: (Reading database ... 75%
==> default: (Reading database ... 80%
==> default: (Reading database ... 85%
==> default: (Reading database ... 90%
==> default: (Reading database ... 95%
(Reading database ... 53903 files and directories currently installed.)
==> default: Preparing to unpack .../git-man_1%3a2.7.4-0ubuntu1.2_all.deb ...
==> default: Unpacking git-man (1:2.7.4-0ubuntu1.2) over (1:2.7.4-0ubuntu1.1) ...
==> default: Processing triggers for man-db (2.7.5-1) ...
==> default: Setting up git-man (1:2.7.4-0ubuntu1.2) ...
==> default: Reading package lists...
==> default: Building dependency tree...
==> default:
==> default: Reading state information...
==> default: 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
meteor-box TechSutram$

Now log in to our meteor-box using vagrant cli,

meteor-box techsutram$ vagrant ssh
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-91-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

0 packages can be updated.
0 updates are security updates.

ubuntu@meteor-box:~$ mount | grep -i meteor-box
home_ubuntu_meteor-box on /home/ubuntu/meteor-box type vboxsf (rw,nodev,relatime)
ubuntu@meteor-box:~$

Now any application that is started inside meteor-box, can be accessed from host machine browser using http://localhost:8181 URL

By Mandar Pise

Opinions expressed by techsutram contributors are their own.

No comments:

Post a Comment

    Your valuable comments are welcome. (Moderated)


Instagram