-
Notifications
You must be signed in to change notification settings - Fork 25
/
Vagrantfile
84 lines (71 loc) · 3.5 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
79
80
81
82
83
84
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "bento/ubuntu-20.04"
config.vm.hostname = "ubuntu"
# accessing "localhost:8080" will access port 80 on the guest machine.
config.vm.network "forwarded_port", guest: 8000, host: 8000, host_ip: "127.0.0.1"
config.vm.network "private_network", ip: "192.168.56.10"
# Mac users can comment this next line out but
# Windows users need to change the permission of files and directories
# so that nosetests runs without extra arguments.
config.vm.synced_folder ".", "/vagrant", mount_options: ["dmode=755,fmode=644"]
############################################################
# Provider for VirtuaBox on Intel
############################################################
config.vm.provider "virtualbox" do |vb|
# Customize the amount of memory on the VM:
vb.memory = "2048"
vb.cpus = 2
# Fixes some DNS issues on some networks
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end
######################################################################
# Copy files to personalize the environment
######################################################################
# 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
# 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
######################################################################
# Create a Python 3 development environment
######################################################################
config.vm.provision "shell", inline: <<-SHELL
echo "****************************************"
echo " INSTALLING PYTHON 3.8 ENVIRONMENT..."
echo "****************************************"
# Install Python 3 and dev tools
apt-get update
apt-get install -y python3.8 python3.8-venv python3-pip sqlite3 git zip tree curl wget jq
apt-get -y autoremove
# Create a Python3 Virtual Environment and Activate it in .profile
sudo -H -u vagrant sh -c 'python3 -m venv ~/venv'
sudo -H -u vagrant sh -c 'echo ". ~/venv/bin/activate" >> ~/.profile'
# Install app dependencies in virtual environment as vagrant user
sudo -H -u vagrant sh -c '. ~/venv/bin/activate && \
pip install -U pip wheel setuptools==59.8.0 && \
cd /vagrant && \
pip install docker-compose'
SHELL
######################################################################
# Add Python 3.8 docker image from Red Hat for docker build
######################################################################
config.vm.provision :docker do |d|
d.pull_images "registry.access.redhat.com/ubi8/python-38"
end
end