diff --git a/CHANGELOG.md b/CHANGELOG.md
index 524d9c8..4b3c838 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,14 @@
# Changelog
+## 0.13.0 (2015-06-18)
+
+- Split install scripts into two pieces: prerequisites installation (optional) and actual box installation.
+- Automatic installation is now supported on Windows!
+- vhost-proxy service - adds ability to use a single shared IP address for multiple web projects running concurently.
+- VirtualBox network adapters performance adjustments (using `virtio` on the NAT interface). Resolves #12.
+- Added bash to avoid shell script compatibility issues and updated all shell scripts to use `#/bin/bash` header. Resolves #17.
+- Documentation updates.
+
## 0.12.1 (2015-06-06)
- Minor fixes in the setup.sh script for Mac
diff --git a/README.md b/README.md
index 5f9a438..78f93f9 100644
--- a/README.md
+++ b/README.md
@@ -2,48 +2,60 @@
Boot2docker Vagrant box for optimized Docker and Docker Compose use on Mac and Windows.
## What is this?
-This is a temporary solution to achive better performance with synced folders and docker data volumes on Mac and Windows.
+This is a temporary solution to achieve better performance with synced folders and docker data volumes on Mac and Windows.
The stock boot2docker currently mounts host volumes via the default VirtualBox Guest Additions (vboxfs) mode, which is terribly slow. Much better performance can be achieved with NFS, SMB or rsync.
-## Requirements
+## Prerequisites
1. [VirtualBox](https://www.virtualbox.org/) 4.3.20+
2. [Vagrant](https://www.vagrantup.com/) 1.6.3+
3. [Git](http://git-scm.com/)
+Proceed to [Setup and usage](#setup) if you already have all prerequisites installed or prefer to install some/all manually.
+Automatic installation of prerequisites is available via the following one-liners.
+
+**Mac**
+
+On Mac prerequisites are installed using **brew/cask** (brew and cask will be installed if missing).
+
+ curl -s https://raw.githubusercontent.com/blinkreaction/boot2docker-vagrant/master/presetup-mac.sh | bash
+
+**Windows**
+
+On Windows prerequisites are installed using **chocolatey** (chocolatey will be installed if missing).
+
+1. Run Command Prompt as administrator
+2. Copy and and paste there the code from [presetup-win.cmd](https://raw.githubusercontent.com/blinkreaction/boot2docker-vagrant/master/presetup-win.cmd)
+
## Setup and usage
-### Automatic installation (Mac only)
+### Automatic installation (Mac and Windows)
-The following tools will be installed: brew, cask, virtualbox, vagrant, docker, docker-compose.
-In case you already have some of these installed (virtualbox, vagrant), it may be best (though not required) to either follow the manual install process or uninstall them before proceeding.
+**On Windows** Git Bash is the recommended option to run console commands.
+If you are having any issues, please check if they can be reproduced in Git Bash.
Run the following command within your `` (shared boo2docker VM for multiple projects, recommended) or `` (dedicated boot2docker VM) directory:
curl -s https://raw.githubusercontent.com/blinkreaction/boot2docker-vagrant/master/setup.sh | bash
-### Manual installation (Windows)
-
-**On Windows** Git Bash is the recommended option to run console commands.
-If you are having any issues, please check if they can be reproduced in Git Bash.
+### Manual installation (Mac and Windows)
1. Copy `Vagrantfile` and `vagrant.yml.dist` files from this repo into your `` (shared boo2docker VM for multiple projects, recommended) or `` (dedicated boot2docker VM) directory.
2. Rename `vagrant.yml.dist` to `vagrant.yml`
-3. Launch Git Bash
-4. cd to ``, start the VM and log into it
+3. Launch Terminal (Mac) or Git Bash (Windows)
+4. cd to ``, start the VM
```
cd
vagrant up
- vagrant ssh
```
-5. Verify installation (you are in the boot2docker VM at this point)
+5. Verify installation
```
docker version
- docker-compose --version
+ vagrant ssh -c 'docker-compose --version'
```
@@ -64,6 +76,8 @@ In addition to the stock SMB synced folders option this box provides an experime
With the **SMB2** option you will receive several "elevated command prompt" prompts which you accept.
No need to enter usernames and passwords unlike the stock SMB option Vagrant ships with.
+If you use rsync, you'll have to run `vagrant rsync-auto` in a separate terminal to keep the files in sync as you make changes.
+
### Mac
@@ -115,6 +129,7 @@ To use rsync on Windows:
2. Choose `rsync` as the sync type in the `vagrant.yml` file.
3. Provide an explicit list of folders to sync in the `vagrant.yml` file (`folders` sequence).
4. Reload the VM: `vagrant reload`
+5. Run `vagrant rsync-auto` to keep the files in sync as you make changes.
## VirtualBox VM settings
@@ -142,6 +157,45 @@ hosts:
Project specific `:` mapping for containers is done in via docker-compose in `docker-compose.yml`
+# vhost-proxy
+
+As an alternative to using dedicated IPs for different projects a built-in vhost-proxy container can be used.
+It binds to `192.168.10.10:80` (the default box IP address) and routes web requests based on the `Host` header.
+
+### How to use
+- Set `vhost_proxy: true` in your vagrant.yml file and do a 'vagrant reload'
+- Set the `VIRTUAL_HOST` environment variable for the web container in your setup (e.g. `VIRTUAL_HOST=example.com`)
+- Add an entry in your hosts file (e.g. `/etc/hosts`) to point the domain to the default box IP (`192.168.10.10`)
+
+Example docker run
+
+```
+docker run --name nginx -d -e "VIRTUAL_HOST=example.com" nginx:latest
+```
+
+Example docker-compose.yml entry
+
+```
+# Web node
+web:
+ image: nginx:latest
+ ports:
+ - "80"
+ environment:
+ - VIRTUAL_HOST=example.com
+```
+
+Example hosts file entry
+
+```
+192.168.10.10 example.com
+```
+
+It is completely fine to use both the vhost-proxy approach and the dedicated IPs approach concurently:
+ - `"80"` - expose port "80", docker will randomly pick an available port on the Docker Host
+ - `"192.168.10.11:80:80"` - dedicated IP:port mapping
+
+
## Tips
### Automate DOCKER_HOST variable export
diff --git a/VERSION b/VERSION
index aac2dac..51de330 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.12.1
\ No newline at end of file
+0.13.0
\ No newline at end of file
diff --git a/Vagrantfile b/Vagrantfile
index 800e2ca..69a8c98 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -99,8 +99,9 @@ Vagrant.configure("2") do |config|
# The default box private network IP is 192.168.10.10
# Configure additional IP addresses in vagrant.yml
+ # Using Intel PRO/1000 MT Server [82545EM] network adapter - shows slightly better performance compared to "virtio".
$vconfig['hosts'].each do |host|
- config.vm.network "private_network", ip: host['ip']
+ config.vm.network "private_network", ip: host['ip'], nic_type: "82545EM"
end unless $vconfig['hosts'].nil?
####################################################################
@@ -175,6 +176,11 @@ Vagrant.configure("2") do |config|
v.name = vagrant_folder_name + "_boot2docker" # VirtualBox VM name.
v.cpus = $vconfig['v.cpus'] # CPU settings. VirtualBox works much better with a single CPU.
v.memory = $vconfig['v.memory'] # Memory settings.
+
+ # Switch the base box NAT network adapters from "82545EM" to "virtio".
+ # Default Intel adapters do not work well with docker...
+ # See https://github.com/blinkreaction/boot2docker-vagrant/issues/13 for details.
+ v.customize ["modifyvm", :id, "--nictype1", "virtio"]
end
## Provisioning scripts ##
@@ -183,15 +189,26 @@ Vagrant.configure("2") do |config|
# https://github.com/deis/deis/issues/2230#issuecomment-72701992
config.vm.provision "shell" do |s|
s.inline = <<-SCRIPT
+ echo 'Disabling DOCKER_TLS...'
echo 'DOCKER_TLS=no' >> /var/lib/boot2docker/profile
/etc/init.d/docker restart
SCRIPT
end
+ # Install bash for compatibility with "#!/bin/bash" scripts.
+ config.vm.provision "shell", run: "always", privileged: false do |s|
+ s.inline = <<-SCRIPT
+ echo 'Installing bash...'
+ tce-load -wi bash.tcz > /dev/null 2>&1
+ SCRIPT
+ end
+
# Make docker-compose available inside boot2docker via a container.
# https://github.com/docker/compose/issues/598#issuecomment-67762456
config.vm.provision "shell", run: "always" do |s|
s.inline = <<-SCRIPT
+ echo 'Making docker-compose available inside boot2docker...'
+
DC_SCRIPT='
#/bin/sh
@@ -251,11 +268,25 @@ Vagrant.configure("2") do |config|
SCRIPT
end
+ # Start system-wide services.
+ # vhost-proxy: https://github.com/jwilder/nginx-proxy
+ # Containers must define a "VIRTUAL_HOST" environment variable to be recognized and routed by the vhost-proxy.
+ if $vconfig['vhost_proxy']
+ config.vm.provision "shell", run: "always", privileged: false do |s|
+ s.inline = <<-SCRIPT
+ echo "Starting system-wide HTTP reverse proxy bound to 192.168.10.10:80... "
+ docker rm -f vhost-proxy > /dev/null 2>&1 || true
+ docker run -d --name vhost-proxy -p 192.168.10.10:80:80 -p 192.168.10.10:443:443 -v /var/run/docker.sock:/tmp/docker.sock jwilder/nginx-proxy > /dev/null
+ SCRIPT
+ end
+ end
+
# Automatically start containers if docker-compose.yml is present in the current directory.
# See "autostart" property in vagrant.yml.
if File.file?('./docker-compose.yml') && $vconfig['compose_autostart']
config.vm.provision "shell", run: "always", privileged: false do |s|
s.inline = <<-SCRIPT
+ echo "Found docker-compose.yml in the root folder. Starting containers..."
cd $1
docker-compose up -d
SCRIPT
diff --git a/presetup-mac.sh b/presetup-mac.sh
new file mode 100644
index 0000000..921196c
--- /dev/null
+++ b/presetup-mac.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+# Console colors
+red='\033[0;31m'
+green='\033[0;32m'
+yellow='\033[1;33m'
+NC='\033[0m'
+
+# Homebrew installation
+echo -e "${green}Installing Homebrew...${NC}"
+ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
+
+# Cask installation
+echo -e "${green}Installing Cask...${NC}"
+brew install caskroom/cask/brew-cask
+
+# Update brew formulae
+echo -e "${green}Updating brew formulae...${NC}"
+brew update
+
+# VirtualBox installation
+echo -e "${green}Installing virtualbox...${NC}"
+brew cask install virtualbox
+
+# Vagrant installation
+echo -e "${green}Installing vagrant...${NC}"
+brew cask install vagrant
+
+# Install docker
+echo -e "${green}Installing docker...${NC}"
+brew install docker
+
+# Install docker-compose
+echo -e "${green}Installing docker-compose...${NC}"
+brew install docker-compose
diff --git a/presetup-win.cmd b/presetup-win.cmd
new file mode 100644
index 0000000..cf31674
--- /dev/null
+++ b/presetup-win.cmd
@@ -0,0 +1,12 @@
+REM Installation chocolatey
+@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
+
+REM Install git, virtualbox, vagrant, docker
+choco install git -y
+choco install virtualbox -y
+choco install vagrant -y
+choco install docker -y
+
+REM Git configuration (proper line endings on Windows and support for long paths)
+git config --global core.autocrlf input
+git config --system core.longpaths true
diff --git a/setup.sh b/setup.sh
index 524e3ff..381533a 100755
--- a/setup.sh
+++ b/setup.sh
@@ -6,34 +6,6 @@ green='\033[0;32m'
yellow='\033[1;33m'
NC='\033[0m'
-# Homebrew installation
-echo -e "${green}Installing Homebrew...${NC}"
-ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
-
-# Cask installation
-echo -e "${green}Installing Cask...${NC}"
-brew install caskroom/cask/brew-cask
-
-# Update brew formulae
-echo -e "${green}Updating brew formulae...${NC}"
-brew update
-
-# VirtualBox installation
-echo -e "${green}Installing virtualbox...${NC}"
-brew cask install virtualbox
-
-# Vagrant installation
-echo -e "${green}Installing vagrant...${NC}"
-brew cask install vagrant
-
-# Install docker
-echo -e "${green}Installing docker...${NC}"
-brew install docker
-
-# Install docker-compose
-echo -e "${green}Installing docker-compose...${NC}"
-brew install docker-compose
-
# Download Vagrantfile
echo -e "${green}Downloading Vagrantfile into the current directory...${NC}"
curl -sO https://raw.githubusercontent.com/blinkreaction/boot2docker-vagrant/master/Vagrantfile
@@ -51,18 +23,18 @@ SOURCE_FILE='';
DOCKER_HOST_EXPORT='\n# Docker (default for Vagrant based boxes)\nexport DOCKER_HOST=tcp://localhost:2375\n'
# Detect shell to write to the right .rc file
-if [[ $SHELL == '/bin/bash' ]]; then SOURCE_FILE=".bashrc"; fi
+if [[ $SHELL == '/bin/bash' || $SHELL == '/bin/sh' ]]; then SOURCE_FILE=".bashrc"; fi
if [[ $SHELL == '/bin/zsh' ]]; then SOURCE_FILE=".zshrc"; fi
if [[ $SOURCE_FILE ]]; then
# See if we already did this and skip if so
- grep -Rq "export DOCKER_HOST=tcp://localhost:2375" $HOME/$SOURCE_FILE
+ grep -q "export DOCKER_HOST=tcp://localhost:2375" $HOME/$SOURCE_FILE
if [[ $? -ne 0 ]]; then
echo -e "${green}Adding automatic DOCKER_HOST export to $HOME/$SOURCE_FILE${NC}"
echo -e $DOCKER_HOST_EXPORT >> $HOME/$SOURCE_FILE
fi
# Source the file so we can use the DOCKER_HOST variabel right away.
- source $HOME/$SOURCE_FILE
+ . $HOME/$SOURCE_FILE
else
echo -e "${red}Cannot detect your shell. Please manually add the following to your respective .rc or .profile file:${NC}"
echo -e "$DOCKER_HOST_EXPORT"
@@ -70,7 +42,9 @@ fi
# Check that Docker works
echo -e "${green}Checking that everything is in place...${NC}"
-docker version
+docker version && vagrant ssh -c 'docker-compose --version'
if [[ $? -ne 0 ]]; then
echo -e "${red}Something went wrong. Please review console output for possible clues.${NC}"
+else
+ echo -e "${green}Docker Host is up and running. Please restart your shell.${NC}"
fi
diff --git a/vagrant.yml.dist b/vagrant.yml.dist
index 3561e21..699e0d5 100644
--- a/vagrant.yml.dist
+++ b/vagrant.yml.dist
@@ -14,6 +14,7 @@ synced_folders:
smb_password: 'vagrant'
# List of folders to sync with rsync. These should be subfolder names within the folder (e.g. "drupal7")
# Uncomment and add folders per the example below as neccessary.
+ # Note: you'll have to run `vagrant rsync-auto` in the background to keep the files in sync as you make changes
folders:
#- "projectA" # rsync projectA folder
#- "projectB" # rsync projectB folder
@@ -35,3 +36,10 @@ hosts:
# Automatically start containers if docker-compose.yml is present in the current directory (default: false).
compose_autostart: false
+
+# vhost-proxy
+# https://github.com/jwilder/nginx-proxy
+# Use a reverse proxy to map host name to containers.
+# This is an alternative to using dedicated IP addresses in the 'hosts' section above.
+# Containers must define a "VIRTUAL_HOST" environment variable to be recognized and routed by the vhost-proxy.
+vhost_proxy: false