forked from nyu-devops/lab-travis-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
78 lines (66 loc) · 2.99 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
72
73
74
75
76
77
78
# -*- mode: ruby -*-
# vi: set ft=ruby :
# This file requires Vagrant 2.0.2 or later
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
config.vm.box = "ubuntu/bionic64"
config.vm.hostname = "travis"
config.vm.network "forwarded_port", guest: 5000, host: 5000, host_ip: "127.0.0.1"
config.vm.network "private_network", ip: "192.168.33.10"
# Windows users need to change the permissions explicitly so that Windows doesn't
# set the execute bit on all of your files which messes with GitHub users on Mac and Linux
config.vm.synced_folder "./", "/vagrant", owner: "vagrant", mount_options: ["dmode=775,fmode=664"]
# Example for VirtualBox:
config.vm.provider "virtualbox" do |vb|
# Customize the amount of memory on the VM:
vb.memory = "512"
vb.cpus = 1
# Fixes some DNS issues on some networks
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end
# Copy your .gitconfig file so that your git credentials are correct
if File.exists?(File.expand_path("~/.gitconfig"))
config.vm.provision "file", source: "~/.gitconfig", destination: "~/.gitconfig"
end
# Copy the ssh keys into the vm for git access
if File.exists?(File.expand_path("~/.ssh/id_rsa"))
config.vm.provision "file", source: "~/.ssh/id_rsa", destination: "~/.ssh/id_rsa"
end
if File.exists?(File.expand_path("~/.ssh/id_rsa.pub"))
config.vm.provision "file", source: "~/.ssh/id_rsa.pub", destination: "~/.ssh/id_rsa.pub"
end
# Copy your .vimrc file so that your vi looks like you expect
if File.exists?(File.expand_path("~/.vimrc"))
config.vm.provision "file", source: "~/.vimrc", destination: "~/.vimrc"
end
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y git python3 python3-pip python3-venv
apt-get -y autoremove
# Install app dependencies
echo "\n******************************"
echo " Installing App Dependencies"
echo "******************************\n"
pip3 install -r /vagrant/requirements.txt
SHELL
######################################################################
# Add Redis docker container
######################################################################
config.vm.provision "shell", inline: <<-SHELL
# Prepare Redis data share
mkdir -p /var/lib/redis/data
chown vagrant:vagrant /var/lib/redis/data
SHELL
# Add Redis docker container
config.vm.provision "docker" do |d|
d.pull_images "redis:alpine"
d.run "redis:alpine",
args: "--restart=always -d --name redis -h redis -p 6379:6379 -v /var/lib/redis/data:/data"
end
end