diff --git a/README.md b/README.md index 92b3b52..e7e6721 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,12 @@ A script to painlessly set up a Vagrant environment for development of Wagtail. Features -------- +* An Ubuntu 17.10 (Artful Aardvark) base image * Checkouts of Wagtail, bakerydemo, django-modelcluster and Willow ready to develop against * Node.js / npm toolchain for front-end asset building -* Optional packages installed (PostgreSQL, ElasticSearch, Embedly, Sphinx...) -* Virtualenv for Python 3 +* Elasticsearch 5 installed (but disabled by default to make the VM less resource-heavy) +* Optional packages installed (PostgreSQL, Embedly, Sphinx...) +* Virtualenv for Python 3.6 This script currently uses a `wagtail-2.0` branch of bakerydemo to test breaking changes in Wagtail 2.0. diff --git a/Vagrantfile b/Vagrantfile index 9552314..13a27cd 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -12,8 +12,8 @@ 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 = "torchbox/wagtail" - config.vm.box_version = "~> 1.0" + config.vm.box = "ubuntu/artful32" + config.vm.box_version = "~> 20180718.0.0" # Disable automatic box update checking. If you disable this, then # boxes will only be checked for updates when the user runs diff --git a/vagrant/provision.sh b/vagrant/provision.sh index 3e8e6e4..bb7b2b1 100644 --- a/vagrant/provision.sh +++ b/vagrant/provision.sh @@ -9,16 +9,41 @@ VIRTUALENV_DIR=/home/vagrant/.virtualenvs/bakerydemo PYTHON=$VIRTUALENV_DIR/bin/python PIP=$VIRTUALENV_DIR/bin/pip -# bring up a PostgreSQL-enabled bakerydemo instance using the current release version of wagtail -PROJECT_DIR=$BAKERYDEMO_ROOT USE_POSTGRESQL=1 $BAKERYDEMO_ROOT/vagrant/provision.sh bakerydemo +# silence "dpkg-preconfigure: unable to re-open stdin" warnings +export DEBIAN_FRONTEND=noninteractive + +# Update APT database +apt-get update -y + +# useful tools +apt-get install -y vim git curl gettext build-essential +# Python 3 +apt-get install -y python3 python3-dev python3-pip python3-venv +# PIL dependencies +apt-get install -y libjpeg-dev libtiff-dev zlib1g-dev libfreetype6-dev liblcms2-dev +# Redis and PostgreSQL +apt-get install -y redis-server postgresql libpq-dev +# libenchant (spellcheck library for docs) +apt-get install -y libenchant-dev +# Java for Elasticsearch +apt-get install -y openjdk-8-jre-headless + +# Create pgsql superuser +su - postgres -c "createuser -s vagrant" + +pip3 install -U pip +pip install virtualenvwrapper -# install system-wide developer dependencies -apt-get update -apt-get install -y libenchant-dev ruby2.0 -gem2.0 install scss_lint +# Set up virtualenvwrapper in .bashrc +cat << EOF >> /home/vagrant/.bashrc +export WORKON_HOME=/home/vagrant/.virtualenvs +export VIRTUALENVWRAPPER_PYTHON=python3 +source /usr/local/bin/virtualenvwrapper.sh +EOF -#Update pip -su - vagrant -c "$PIP install -U pip" + +# bring up a PostgreSQL-enabled bakerydemo instance using the current release version of wagtail +PROJECT_DIR=$BAKERYDEMO_ROOT DEV_USER=vagrant USE_POSTGRESQL=1 $BAKERYDEMO_ROOT/vagrant/provision.sh bakerydemo # install additional dependencies (including developer-specific ones) # of wagtail master @@ -26,7 +51,7 @@ su - vagrant -c "$PIP install -U pip" su - vagrant -c "cd $WAGTAIL_ROOT && $PIP install -e .[testing,docs] -U" # install optional packages (so that the full test suite runs) -su - vagrant -c "$PIP install embedly elasticsearch django-sendfile" +su - vagrant -c "$PIP install embedly \"elasticsearch>=5.0,<6.0\" django-sendfile" # install Node.js (for front-end asset building) # as per instructions on https://github.com/nodesource/distributions @@ -43,3 +68,16 @@ su - vagrant -c "cd $WAGTAIL_ROOT && npm install && npm run build" # run additional migrations in wagtail master su - vagrant -c "$PYTHON $BAKERYDEMO_ROOT/manage.py migrate --noinput" + +# Elasticsearch (disabled by default, as it's a resource hog) +echo "Downloading Elasticsearch..." +wget -q https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.3.3.deb +dpkg -i elasticsearch-5.3.3.deb +rm elasticsearch-5.3.3.deb +# reduce JVM heap size from 2g to 512m +sed -i 's/^\(-Xm[sx]\)2g$/\1512m/g' /etc/elasticsearch/jvm.options +# to enable: +# systemctl enable elasticsearch +# systemctl start elasticsearch + +echo "Vagrant setup complete. You can now log in with: vagrant ssh"