$cd /path/to/project/vagrant
$vagrant up
$startx
(Starts a Gnome UI)$which npm
(/opt/node-v6.4.0-linux-x64/bin)$sudo visudo
(Requires basic knowledge of Vi/Vim)$npm install npm -g
$npm install aurelia-cli -g
$cd /path/to/project/vagrant
(If you're not already in the directory with the Vagrantfile)$vagrant halt
(Keeps all files, closes GUI, shuts down VM)$vagrant up
(Restart VM, login via GUI when it's ready)$vagrant destroy
(Will need to download everything again, your local files will be deleted. Use this to start from scratch.)Now you're ready to start building your website using Aurelia CLI!
Vagrantfile
Vagrant.configure("2") do |config| config.vm.box = "centos/7" config.vm.hostname = "dev" config.vm.provider "virtualbox" do |vb| vb.gui = true vb.cpus = "4" vb.memory = "3092" end # Networking config.vm.network "private_network", ip: "192.168.0.3" config.vm.network :forwarded_port, guest: 80, host: 80 # nginx config.vm.network :forwarded_port, guest: 9000, host: 9000 # au run config.vm.network :forwarded_port, guest: 3001, host:3001 # BrowserSynch # Shares config.vm.synced_folder "../provision", "/home/vagrant/provision" # Provision config.vm.provision "shell", path: "provision.sh" end
provision.sh
HOME=/home/vagrant NODE=node-v6.4.0-linux-x64 EPEL=epel-release-latest-7.noarch.rpm ATOM=atom.x86_64 echo "************************************" echo "Provisioning virtual machine..." echo "************************************" sudo cd $HOME echo "***********************" echo "Updating yum..." echo "***********************" sudo yum clean all sudo yum -y install deltarpm yum-utils sudo yum -y update --exclude=kernel* echo "***********************" echo "Updating yum, installing Dev Tools..." echo "***********************" sudo yum -y groupinstall "Base" sudo yum -y groupinstall "GNOME Desktop" sudo yum -y groupinstall "Development Tools" echo "***********************" echo "Installing tools..." echo "***********************" sudo yum install -y git tar gcc vim unzip wget curl tree nginx if [ -d "/opt/$NODE" ] then echo "**********************************" echo "Node already installed..." echo "**********************************" else echo "**********************************" echo "Installing Node and update npm..." echo "**********************************" sudo cp /home/vagrant/provision/packages/$NODE.tar.xz /opt sudo tar -xpf /opt/$NODE.tar.xz -C /opt sudo echo "export PATH=\"$PATH:/opt/$NODE/bin\"" >> $HOME/.bash_profile sudo echo "export PATH=\"$PATH:/opt/$NODE/bin\"" >> /root/.bash_profile sudo source $HOME/.bash_profile fi echo "**********************************" echo "Installing Atom..." echo "**********************************" sudo rpm -ivh /home/vagrant/provision/packages/$ATOM.rpm echo "******************************" echo "Installing EPEL..." echo "******************************" wget -P /etc/yum.repos.d http://dl.fedoraproject.org/pub/epel/$EPEL sudo rpm -ivh /etc/yum.repos.d/$EPEL echo "***********************" echo "Git setup..." echo "***********************" git config --global user.email "[email protected]" git config --global user.name "Your Name" git config --global github.user "Username" echo "***********************" echo "Don't forget to:" echo "sudo visudo" echo "Append npm path to secure_path: /opt/$NODE/bin" echo "sudo npm install npm -g" echo "sudo npm install aurelia-cli -g" echo "***********************" echo "*********************************" echo "VM Provisioning Complete!" echo "*********************************"
This Example assumes you setup as explained in Example: Setting Up Environment for aurelia-cli Explained of this document.
Creating a new project
In main host os, open terminal (Mac OS in my case)
$cd /path/to/project/vagrant
$vagrant up
(Launches VM GUI)
Log into VM via UI
$startx
$cd /home/vagrant
$au new
(starts a series of prompts to setup project)
$[aurelia-app]> MyProject
(Press Enter) (This will be the name of project main directory)$[Default ESNext] > 3
(Press Enter) (Custom options)$[Babel] >
(Press Enter) (Lets use Bable to transpile our ESNext to ES5)$[none] > 3
(If you want to use Sass for your css)$[Yes] > 2
(Lets not setup testing for simplicity)$[Visual Studio Code] > 2
(Atom, if you followed setup for this document)$[Yes] > 1
(Press Enter)$[Yes] > 1
(Press Enter)Creates directory structure and downloads all the dependencies via npm.
You're now done and ready to start building!
Basic Project directory structure
Development cycle on the VM
$au run --watch
(Builds app, starts BrowserSynch web server)Environment
This Example assumes you setup as explained in Example: Setting Up Environment for Aurelia-cli Explained of this document.
Summary of setup:
$cd /path/to/project/vagrant
$vagrant up
$cd /home/vagrant/MyProject
(Where you setup your Aurelia project as described in "Aurelia Cli Basics Explained" above.)Basic Project directory structure
Build your App
$au build
(Creates bundled files in projects /scripts directory)Setting up Nginx
$sudo yum install nginx
$sudo nginx
$sudo nginx -s reload
Copy files from Aurelia project to server
$sudo cp /home/vagrant/MyProject/index.html /var/www/html/
$sudo cp -R /home/vagrant/MyProject/scripts /var/www/html/
$sudo cp mkdir /var/www/src/
$sudo cp -R /home/vagrant/MyProject/src/resources /var/www/src/
/etc/nginx/nginx.conf
# For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. server { listen 80 default_server; listen [::]:80 default_server; server_name _; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; root /var/www/html/; location /src/resources { root /var/www/; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } }