zhongrj
2025-11-25 b89962006164a462404b79a738bee8cbb6d7fe7e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Vagrant.configure(2) do |config|
  config.vm.box = "ubuntu/trusty64"
  config.vm.network :forwarded_port, guest: 4567, host: 4567
 
  config.vm.provision "bootstrap",
    type: "shell",
    privileged: false,
    inline: <<-SHELL
      sudo apt-get update
      sudo apt-get install -yq git gcc build-essential libreadline-dev zlib1g-dev pkg-config nodejs libxml2-dev libxslt-dev
      sudo apt-get install -yq libssl-dev
      sudo apt-get autoremove -yq
      git clone https://github.com/sstephenson/rbenv.git /home/vagrant/.rbenv
      echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> /home/vagrant/.bash_profile
      echo 'eval "$(rbenv init -)"' >> /home/vagrant/.bash_profile
      source /home/vagrant/.bash_profile
      git clone https://github.com/sstephenson/ruby-build.git /home/vagrant/.rbenv/plugins/ruby-build
      cd /home/vagrant
      rbenv install 2.4.7
      rbenv global 2.4.7
      gem install --no-ri --no-rdoc bundler
    SHELL
 
  # add the local user git config to the vm
  config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig"
 
  config.vm.provision "install",
    type: "shell",
    privileged: false,
    inline: <<-SHELL
      echo "=============================================="
      echo "Installing app dependencies"
      cd /vagrant
      bundle config build.nokogiri --use-system-libraries
      bundle install
    SHELL
 
  config.vm.provision "run",
    type: "shell",
    privileged: false,
    run: "always",
    inline: <<-SHELL
      echo "=============================================="
      echo "Starting up middleman at http://localhost:4567"
      echo "If it does not come up, check the ~/middleman.log file for any error messages"
      cd /vagrant
      bundle exec middleman server --watcher-force-polling --watcher_latency=1 &> ~/middleman.log &
    SHELL
end