Skip to content

Instantly share code, notes, and snippets.

@swasher
Last active July 30, 2016 13:22
Show Gist options
  • Save swasher/964ca4f16dcbc12d913b to your computer and use it in GitHub Desktop.
Save swasher/964ca4f16dcbc12d913b to your computer and use it in GitHub Desktop.
Vagrantfile for setting up Django's Vagrant container
# -*- mode: ruby -*-
# vi: set ft=ruby :
internal_ip = "172.28.128.4"
project_name = "blog"
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/xenial64"
# bridged network with dhcp
config.vm.network "private_network", ip: internal_ip
config.vm.hostname = project_name
# allocate 1gb ram
config.vm.provider :virtualbox do |v|
v.name = project_name
v.memory = 1024
v.gui = false
end
# for supress "stdin: is not a tty error"
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
# mount project in /home/user instead /vagrant and tuneup permission
config.vm.synced_folder ".", "/home/vagrant" + project_name,
id: "vagrant-root",
owner: "vagrant",
group: "vagrant",
mount_options: ["dmode=775,fmode=664"]
config.vm.provision "shell", inline: <<-SHELL
apt-get update -q
apt-get autoremove -y
apt-get install mc npm -y
apt-get install python3-venv python3-dev -y
SHELL
config.vm.provision "shell", privileged: false, inline: <<-SHELL
wget -q https://raw.githubusercontent.com/django/django/master/extras/django_bash_completion -O django_bash_completion
echo "source django_bash_completion" >> ~/.bashrc
pyvenv virtualenvironment
source /home/vagrant/virtualenvironment/bin/activate && pip install -r requirement.txt
pip completion --bash >> ~/.profile
SHELL
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment