Last active
December 1, 2015 11:21
-
-
Save martinkr/44ad2b5bf5eb098db583 to your computer and use it in GitHub Desktop.
Vagrant: typical front end setup with ngnix / git / node / npm / gulp / bower / phantomjs / karma
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# "./tools/vagrant/bootstrap.sh" | |
echo "Provisioning virtual machine..." | |
echo "Updating packages list" | |
apt-get update | |
# Git | |
echo "Installing Git" | |
apt-get install git -y | |
# Nginx | |
echo "Installing Nginx" | |
apt-get install nginx -y | |
# Nginx Configuration | |
echo "Configuring Nginx" | |
sudo cp /vagrant/tools/vagrant/nginx_vhost /etc/nginx/sites-available/nginx_vhost > /dev/null | |
sudo ln -sf /etc/nginx/sites-available/nginx_vhost /etc/nginx/sites-enabled/ | |
sudo rm -rf /etc/nginx/sites-available/default | |
echo "Restarting Nginx" | |
# Restart Nginx for the config to take effect | |
sudo service nginx restart | |
# Node | |
# https://github.com/nodesource/distributions#debmanual | |
echo "Installing Node" | |
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - | |
sudo apt-get install -y nodejs | |
echo "Updating npm" | |
sudo sh -c "npm install npm -g" | |
echo "Installing Gulp 4 CLI tools globally from 4.0 GitHub branch" | |
sudo npm install gulpjs/gulp-cli#4.0 -g | |
echo "Installing globally: bower" | |
sudo npm install -g bower | |
echo "setup karma" | |
sudo npm install -g karma | |
echo "setup phantomjs" | |
sudo npm install -g phantomjs | |
export PHANTOMJS_BIN=/usr/bin/phantomjs | |
cd /vagrant | |
echo "Install local project dependencies " | |
npm install -y | |
npm install gulpjs/gulp#4.0 -y | |
bower install -y | |
echo "Node:"; node -v; | |
echo "NPM:"; npm -v; | |
echo "bower:"; bower -v; | |
echo "Gulp:"; gulp -v; | |
echo "karma:"; karma -v; | |
echo "Karma:"; karma --version; | |
echo "Phantomjs:"; phantomjs -v; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# "./tools/vagrant/ngnix_vhost" | |
# develop | |
server { | |
listen 8080; | |
listen [::]:8080 ipv6only=on; | |
server_name localhost; | |
root /var/www; | |
index index.html; | |
# Important for VirtualBox | |
sendfile off; | |
# Gzip Settings | |
gzip on; | |
gzip_disable "msie6"; | |
location / { | |
try_files $uri $uri/ =404; | |
autoindex on; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# "./Vagrantfile" | |
Vagrant.configure(2) do |config| | |
config.vm.box = "ubuntu/trusty64" | |
# set ports: according to your ngnix configuration | |
config.vm.network :forwarded_port, guest: 8080, host: 8080 | |
# sync to the ngnix root | |
config.vm.synced_folder "./", "/var/www", create: true, group: "www-data", owner: "www-data" | |
# remove error message | |
config.vm.provision "fix-no-tty", type: "shell" do |s| | |
s.privileged = false | |
s.inline = "sudo sed -i '/tty/!s/mesg n/tty -s \\&\\& mesg n/' /root/.profile" | |
end | |
# use bootrap.sh | |
config.vm.provision "shell", path: "./tools/vagrant/bootstrap.sh" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment