From eec74249c9075f2553c06ed4d393e2909f4f1cf6 Mon Sep 17 00:00:00 2001 From: Darren Thompson Date: Wed, 21 Sep 2016 18:51:27 -0400 Subject: [PATCH] Created frontend provisioning script This script handles pulling in all of the frontend's dependencies. It also creates a symlink from the node_modules directory inside the shared /vagrant folder to the Vagrant VM's home folder. This fixes issues in windows where npm install tries to create symlinks in a NTFS backed file system. It also speeds up the npm install process as Virtual Box's shared folder engine is significantly slower than a native file system, especially with npm's large number of small files. Former-commit-id: 105990329953be04150e93adf9498c1cae8000d4 --- README.md | 2 +- Vagrantfile | 5 +++++ vagrant/frontend.sh | 21 +++++++++++++++++++++ vagrant/native_deps.sh | 4 ---- 4 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 vagrant/frontend.sh diff --git a/README.md b/README.md index 198113bb..5205a556 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ $ cd /vagrant && cargo run -- scrape To install dependencies for the front-end development server and run it: ``` -$ cd /vagrant/front && npm install && bower install +$ cd /vagrant/front $ ember server --proxy=http://localhost:8080 ``` diff --git a/Vagrantfile b/Vagrantfile index 72a10780..cb97e4eb 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -9,6 +9,11 @@ Vagrant.configure("2") do |config| path: "vagrant/native_deps.sh", keep_color: true) + config.vm.provision("frontend", + type: "shell", + path: "vagrant/frontend.sh", + keep_color: true) + config.vm.provision("postgres", type: "shell", path: "vagrant/postgres.sh", diff --git a/vagrant/frontend.sh b/vagrant/frontend.sh new file mode 100644 index 00000000..e1ccc521 --- /dev/null +++ b/vagrant/frontend.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -e + +# global deps +npm install -g ember-cli +npm install -g bower + +# keep node modules in VM file system to speedup npm install and fix it on Windows/Linux machines +mkdir -p /home/vagrant/local_front/node_modules +rm -f /vagrant/front/node_modules || true +ln -s /home/vagrant/local_front/node_modules /vagrant/front/ +chown -R vagrant:vagrant /home/vagrant/local_front +chown -R vagrant:vagrant /vagrant/front/node_modules + +# install local deps +su vagrant <<'EOF' +cd /vagrant/front +npm install +bower install +EOF diff --git a/vagrant/native_deps.sh b/vagrant/native_deps.sh index 403763f2..997316cd 100755 --- a/vagrant/native_deps.sh +++ b/vagrant/native_deps.sh @@ -16,7 +16,3 @@ locale-gen en_US.UTF-8 apt-get update apt-get install -y postgresql libpq-dev npm nodejs curl git ln -s /usr/bin/nodejs /usr/bin/node - -# frontend deps -npm install -g ember-cli -npm install -g bower