-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathVagrantfile.template
75 lines (62 loc) · 2.28 KB
/
Vagrantfile.template
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
72
73
74
75
# encoding: utf-8
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Box / OS
VAGRANT_BOX = '#BOX#'
# Memorable name for your VM
VM_NAME = '#PROJECT_NAME#-vm-vagrant'
# VM User — 'vagrant' by default
VM_USER = 'vagrant'
# Username on your Mac
MAC_USER = '#MAC_USER#'
# Host folder to sync
HOST_PATH = '#HOST_PATH#'
# Where to sync to on Guest — 'vagrant' is the default user name
GUEST_PATH = '/opt/#PROJECT_NAME#'
# # VM Port — uncomment this to use NAT instead of DHCP
# VM_PORT = 8080
Vagrant.configure(2) do |config|
# Vagrant box from Hashicorp
config.vm.box = VAGRANT_BOX
# Actual machine name
config.vm.hostname = VM_NAME
# Set VM name in Virtualbox
config.vm.provider "virtualbox" do |v|
v.name = VM_NAME
v.memory = #MEMORY#
v.cpus = #CPUS#
end
#DHCP — comment this out if planning on using NAT instead
#config.vm.network "private_network", type: "dhcp"
config.vm.network :forwarded_port, guest: 80, host: 80
# # Port forwarding — uncomment this to use NAT instead of DHCP
# config.vm.network "forwarded_port", guest: 80, host: VM_PORT
# Sync folder
config.vm.synced_folder HOST_PATH, GUEST_PATH
# Disable default Vagrant folder, use a unique path per project
config.vm.synced_folder '.', '/home/'+VM_USER+'', disabled: true
#Install package for your VM
config.vm.provision "shell", inline: <<-SHELL
apt-get update -y
apt-get install -y git
apt-get install -y apt-transport-https
apt-get install -y build-essential
apt-get install -y curl
apt-get install -y gnupg-agent
apt-get install -y software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get update -y
apt-get install -y docker-ce docker-ce-cli containerd.io
curl -L "https://github.com/docker/compose/releases/download/#DOCKER_COMPOSE_VERSION#/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
usermod -aG docker vagrant
newgrp docker
echo "cd /opt/#PROJECT_NAME#" >> /home/vagrant/.bashrc
SHELL
end