-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVagrantfile
71 lines (66 loc) · 2.71 KB
/
Vagrantfile
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# frozen_string_literal: true
# -*- mode: ruby -*-
# vi: set ft=ruby :
RUBY_V = File.read('./.ruby-version').chomp
Vagrant.configure('2') do |config|
config.vm.box = 'bento/debian-10'
config.vm.network 'forwarded_port', guest: 3000, host: 3001, host_ip: 'localhost'
# change to 'virtualbox' if you use it in place of vmware
config.vm.provider 'vmware_desktop' do |vb|
vb.memory = '1024'
vb.gui = true
end
config.vm.provision 'shell', inline: <<-SHELL
# for nodejs repository
# see https://github.com/nodesource/distributions#debian-and-ubuntu-based-distributions
sudo apt-get install -y ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
NODE_MAJOR=20
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee cd /vagrant
# for yarn repository
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
# update the apt repositories
sudo apt-get update
# update the system
sudo apt-get -y dist-upgrade
# install ruby prerequisite
sudo apt-get install -y git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev \
libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev \
libcurl4-openssl-dev libffi-dev \
nodejs yarn
# cleanup
sudo apt-get autoremove -y
sudo apt-get clean -y
SHELL
config.vm.provision :shell, privileged: false, inline: <<~SCRIPT
if [ ! -d ~/.rbenv ]; then
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
fi
git -C /home/vagrant/.rbenv pull
if [ ! -d ~/.rbenv/plugins/ruby-build ]; then
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
fi
git -C /home/vagrant/.rbenv/plugins/ruby-build pull
export PATH="$HOME/.rbenv/bin:$PATH"
export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
eval "$(rbenv init -)"
if [ ! -e .rbenv/versions/#{RUBY_V} ]; then
rbenv install #{RUBY_V}
rbenv global #{RUBY_V}
gem update --system --no-doc
rbenv rehash
fi
cd /vagrant
# if [ ! -e /home/vagrant/.rbenv/shims/bundle ]; then
gem update --system --no-doc
rbenv rehash
# fi
bundle install
yarn --no-bin-links
SCRIPT
end