-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathVagrantfile
97 lines (71 loc) · 3.26 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
85
86
87
88
89
90
91
92
93
94
95
96
97
# -*- mode: ruby -*-
# vi: set ft=ruby :
# If you are looking at this script to set up your computer for developing
# the GovTrack website, skip ahead to "START HERE". Thanks!
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.network "forwarded_port", guest: 8000, host: 8000
config.vm.provision "shell", inline: <<-SHELL
set -euo pipefail # stop script if any command fails
# Create a fake manage.py file in ~ so 'vagrant ssh' can find it easily.
ln -sf /vagrant/build/vagrant_manage.py manage.py
cd /vagrant
###############
# Start here! #
###############
# These instructions are for Ubuntu 18.04. Where the instructions
# differ for OS X, we'll note those differences.
# Install system packages
#########################
# (Ubuntu only)
echo Installing system packages...
sudo apt-get update
# on a new system you might also want to run: sudo apt-get upgrade
sudo apt install -y -q \
git python3-pip virtualenv unzip \
libcap-dev libcairo-dev
# on production I also needed:
# sudo apt-get install memcached libmysqlclient-dev poppler-utils s3cmd mysql-client
# On OS X...
# ----------
# export CFLAGS=-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2
# pip3 install virtualenv lxml python-openid python-oauth2 iso-8601 numpy scipy
# Install Python packages
#########################
# If you're following these instructions manually, you should create
# a "virtualenv" for Python that will hold additional Python packages.
# With Vagrant, it's not necessary, so it's commented out. But you
# should run these two commands:
#
# virtualenv -ppython3 .venv
# source .venv/bin/activate
# Install Xapian: (skip in production, where we use Solr)
wget https://raw.githubusercontent.com/notanumber/xapian-haystack/master/install_xapian.sh
bash install_xapian.sh 1.4.22
# Install Python packages.
# In production, xapian-haystack should be skipped.
pip3 install --upgrade -r requirements.txt xapian-haystack
# on production I needed: pip install mysqlclient pylibmc django-mysql
# On OS X, install bcrypt:
# http://stackoverflow.com/questions/22875270/error-installing-bcrypt-with-pip-on-os-x-cant-find-ffi-h-libffi-is-installed
# Initialize the database.
./manage.py migrate --noinput
# Fetch other dependencies
##########################
./fetch-external-assets.sh
# Load some legislative data
############################
# Get our latest database dump of legislators, committees, and subject areas.
echo Downloading a partial database dump from GovTrack...
wget -q -N -P /tmp http://www.govtrack.us/data/db/django-fixture-{people,committees,billterms}.json
# And load them.
echo Loading data...
./manage.py loaddata /tmp/django-fixture-people.json
./manage.py loaddata /tmp/django-fixture-committees.json
./manage.py loaddata /tmp/django-fixture-billterms.json
# Bills and votes are harder to fetch. See the README.
# Update search indexes.
echo "Initializing search indexes (this part takes a long while)..."
./manage.py update_index
SHELL
end