diff --git a/.gitignore b/.gitignore index 839aa53..fe5782b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ .vagrant/ packer_cache/ *.box -b2d.iso -boot2docker-vagrant.iso +*.iso +output* \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..06d1729 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,61 @@ + +## 07/11/2014 (v1.3.1) +- Moving to boot2docker 1.3.1 (docker 1.3.1) +- Adding SSL docker's daemon port NAT to 2376 +- NATed ports are now auto-moved when conflicting +- Packer 0.7 compatibility +- When docker-building, AUFS limit is now 128 layers instead of 42 +- Packer-only new build process, from the vanilla boot2docker iso, checksumed + +## 13/07/2014 (v1.1.1) +- Moving to boot2docker 1.1.1 (and Docker 1.1.1 by transitivity) +- Persisting the b2d dependency into the make.sh script for easying future updates and trusting +- Moving the default RAM of the VM to 2Gb + +## 05/07/2014 (v1.1.0) +- Moving to docker v1.1.0 +- Moving to boot2docker v1.1.0 +- Adding some error handling when building from shell + +## 22/06/2014 (v1.0.1) +- Moving to docker and b2d 1.0.1 + +## 19/06/2014 (v1.0.0) +- Building b2d-vbox and b2d vagrant custom in one Dockerfile instead of Docker + vagrant + ubuntu +- Adding possibility to build boot2docker vanilla image from official github repo instead of pulling from Docker index +- Move to b2d and docker 1.0.0 (bash make.sh v1.0.0) + +## 15/06/2014 (v0.5.0) +- Moving to the new IANA Docker port 2375, and let vagrant auto corrects when collision +- Moving to boot2docker and Docker 1.0.0 +- Using a custom Vagrantfile for building a b2d iso with vbox addition +- Re-using temporarly mitchellh vagrantfile + build-iso workflow for "vagranti-zing" the b2d.iso +- Updating build scripts (Unix/Windows) with packer building all types + +## 08/05/2014 (v0.4.0) +- Adding auto Docker update +- Moving to Docker 0.11.1 + +## 07/05/2014 (v0.3.0) +- Adding linux build chain and bats tests +- Moving to official boot2docker build system +- Integrate boot2docker build into a Vagrant Docker provider +- Vboxsf build into ISO (auto) [4.3.8] + +## 23/04/2014 (v0.2.0) +- Adding custom_profile mangement +- Adding Windows build chain +- Adding docker and vagrant BATS tests, Windows only + +## 21/04/2014 (v0.1.0) + +- Fetching latest version from mitchellh offical repository (results in using a vagrant cloud baebox with no docker) +- Updating b2d to experimental build with vboxsf inside (https://github.com/boot2docker/boot2docker/issues/282) +- Updating build-iso.sh to add a /etc/rc.d script for loading vboxsf module at boot. +- Updating basebox's vagrantfile template to enable /vagrant share +- Updating basebox's vagrantfile template to aut correct docker's TCP port when launching multiple VMs + +## 03/03/2014 + +- Using misheska's ubuntu basebox for running docker easily. +- Attempts to install fig from orchardups. diff --git a/Makefile b/Makefile index 7925f8c..23c10c3 100644 --- a/Makefile +++ b/Makefile @@ -4,9 +4,7 @@ build: boot2docker-vagrant.iso prepare: clean boot2docker-vagrant.iso boot2docker-vagrant.iso: - vagrant up - vagrant ssh -c 'cd /vagrant && sudo ./build-iso.sh' - vagrant destroy --force + wget -O boot2docker.iso https://github.com/boot2docker/boot2docker/releases/download/v1.3.0/boot2docker.iso clean: rm -rf *.iso *.box diff --git a/README.md b/README.md index 4bbfc74..7d39c2f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # boot2docker Vagrant Box This repository contains the scripts necessary to create a Vagrant-compatible -[boot2docker](https://github.com/steeve/boot2docker) box. If you work solely +[boot2docker](https://github.com/boot2docker/boot2docker) box. If you work solely with Docker, this box lets you keep your Vagrant workflow and work in the most minimal Docker environment possible. @@ -32,22 +32,18 @@ do so in seconds. To build the box, first install the following prerequisites: - * [Packer](http://www.packer.io) (at least version 0.5.1) + * [Packer](http://www.packer.io) (at least version 0.7.2) * [VirtualBox](http://www.virtualbox.org) (at least version 4.3), VMware, or Parallels * [Vagrant](http://www.vagrantup.com) Then follow the steps: ``` -$ vagrant up -... -$ vagrant ssh -c 'cd /vagrant && sudo ./build-iso.sh' -... -$ vagrant destroy --force +$ wget -O boot2docker-vagrant.iso ... $ packer build template.json ... ``` You can restrict only VirtualBox, VMware, or Parallels by specifying the `-only` flag -to Packer. +to Packer. \ No newline at end of file diff --git a/Vagrantfile b/Vagrantfile deleted file mode 100644 index fd8197d..0000000 --- a/Vagrantfile +++ /dev/null @@ -1,23 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! -VAGRANTFILE_API_VERSION = "2" - -Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| - # All Vagrant configuration is done here. The most common configuration - # options are documented and commented below. For a complete reference, - # please see the online documentation at vagrantup.com. - - # Every Vagrant virtual environment requires a box to build off of. - config.vm.box = "chef/ubuntu-12.04-i386" - - config.vm.provider "virtualbox" do |v| - v.customize ["modifyvm", :id, "--memory", "1500"] - end - - config.vm.provider "parallels" do |v, override| - override.vm.box = "parallels/ubuntu-12.04" - v.memory = 1500 - end -end diff --git a/b2d-provision.sh b/b2d-provision.sh new file mode 100644 index 0000000..d414cfb --- /dev/null +++ b/b2d-provision.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +# Creating one partition and formating to ext4 +# See https://github.com/boot2docker/boot2docker/issues/531#issuecomment-61740859 +echo "n +p +1 + + +w +p +q +"| /sbin/fdisk /dev/sda +/sbin/mkfs.ext4 -L boot2docker-data /dev/sda1 + +# Mounting the freshly formatted volume to copy persisted content +mount /dev/sda1 /mnt + +# Inserting vagrant key in the userdata.tar which should be deployed when boot2docker boot +B2D_PERSISTENT_DIR=/mnt/var/lib/boot2docker +TMP_USERDATA_DIR=/tmp/userdata + +mkdir -p ${B2D_PERSISTENT_DIR} ${TMP_USERDATA_DIR}/.ssh + +cat <${TMP_USERDATA_DIR}/.ssh/authorized_keys +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key +KEY +chmod 0600 ${TMP_USERDATA_DIR}/.ssh/authorized_keys + + +cd ${TMP_USERDATA_DIR} +tar cf ${B2D_PERSISTENT_DIR}/userdata.tar ./.ssh diff --git a/build-iso.sh b/build-iso.sh deleted file mode 100755 index 5a74ff8..0000000 --- a/build-iso.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# -# This script takes a boot2docker.iso and re-processes it to be usable -# by Vagrant. -# -set -e -set -x - -B2D_URL="https://github.com/boot2docker/boot2docker/releases/download/v1.3.0/boot2docker.iso" - -apt-get -y update -apt-get install -y genisoimage - -#-------------------------------------------------------------------- -# B2D -#-------------------------------------------------------------------- -# Download boot2docker -wget -O b2d.iso ${B2D_URL} - -# Mount it up -rm -rf /tmp/boot -mkdir -p /mnt/tmp -mount b2d.iso /mnt/tmp -o loop,ro -cp -a /mnt/tmp/boot /tmp -mv /tmp/boot/initrd.img /tmp -umount /mnt/tmp - -# Extract the core filesystem -EXTRACT_DIR="/tmp/extract" -rm -rf ${EXTRACT_DIR} -mkdir -p ${EXTRACT_DIR} -pushd ${EXTRACT_DIR} -lzma -dc /tmp/initrd.img | cpio -i -H newc -d -popd - -#-------------------------------------------------------------------- -# Customization -#-------------------------------------------------------------------- -# Script to add in public key -cat < ${EXTRACT_DIR}/etc/rc.d/vagrant -mkdir -p /home/docker/.ssh -chmod 0700 /home/docker/.ssh - -cat </home/docker/.ssh/authorized_keys -ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key -KEY -chmod 0600 /home/docker/.ssh/authorized_keys - -chown -R docker:staff /home/docker/.ssh -EOF -chmod +x ${EXTRACT_DIR}/etc/rc.d/vagrant - -# Configure boot to add public key -echo "/etc/rc.d/vagrant" >> ${EXTRACT_DIR}/opt/bootsync.sh - -#-------------------------------------------------------------------- -# Package -#-------------------------------------------------------------------- -# Make the initrd.img image... -pushd ${EXTRACT_DIR} -find | cpio -o -H newc | xz -9 --format=lzma > /tmp/initrd.img -popd - -# Make the ISO -pushd /tmp -mv initrd.img boot -mkdir newiso -mv boot newiso -popd -mkisofs -l -J -R -V b2d-vagrant -no-emul-boot -boot-load-size 4 \ - -boot-info-table -b boot/isolinux/isolinux.bin \ - -c boot/isolinux/boot.cat -o boot2docker-vagrant.iso /tmp/newiso -rm -rf /tmp/newiso diff --git a/readme_image.gif b/readme_image.gif deleted file mode 100644 index cb18996..0000000 Binary files a/readme_image.gif and /dev/null differ diff --git a/template.json b/template.json index 80ce138..8eb6456 100644 --- a/template.json +++ b/template.json @@ -1,8 +1,13 @@ { + "variables": { + "B2D_ISO_FILE": "boot2docker.iso", + "B2D_ISO_CHECKSUM": "a0f8e7b9ef9a59befcd9ceff604ef2af" + }, "builders": [{ "type": "virtualbox-iso", - "iso_url": "boot2docker-vagrant.iso", - "iso_checksum_type": "none", + "iso_url": "{{user `B2D_ISO_FILE`}}", + "iso_checksum_type": "md5", + "iso_checksum": "{{user `B2D_ISO_CHECKSUM`}}", "boot_wait": "5s", "guest_additions_mode": "attach", "guest_os_type": "Linux_64", @@ -11,8 +16,9 @@ "shutdown_command": "sudo poweroff" }, { "type": "vmware-iso", - "iso_url": "boot2docker-vagrant.iso", - "iso_checksum_type": "none", + "iso_url": "{{user `B2D_ISO_FILE`}}", + "iso_checksum_type": "md5", + "iso_checksum": "{{user `B2D_ISO_CHECKSUM`}}", "boot_wait": "5s", "guest_os_type": "other3xlinux-64", "ssh_username": "docker", @@ -20,24 +26,29 @@ "shutdown_command": "sudo poweroff" }, { "type": "parallels-iso", - "iso_url": "boot2docker-vagrant.iso", - "iso_checksum_type": "none", + "iso_url": "{{user `B2D_ISO_FILE`}}", + "iso_checksum_type": "md5", + "iso_checksum": "{{user `B2D_ISO_CHECKSUM`}}", "boot_wait": "5s", - "guest_os_distribution": "linux", + "guest_os_type": "linux", "ssh_username": "docker", "ssh_password": "tcuser", - "shutdown_command": "sudo poweroff" - }], - - "provisioners": [{ - "type": "shell", - "inline": ["mkfs.ext4 -F -L boot2docker-data /dev/sda"] + "shutdown_command": "sudo poweroff", + "parallels_tools_mode": "disable" }], - + "provisioners": [ + { + "type": "shell", + "execute_command": "{{ .Vars }} sudo -E -S sh '{{ .Path }}'", + "scripts": [ + "b2d-provision.sh" + ] + } + ], "post-processors": [{ "type": "vagrant", - "include": ["boot2docker-vagrant.iso"], + "include": ["boot2docker.iso"], "vagrantfile_template": "vagrantfile.tpl", "output": "boot2docker_{{.Provider}}.box" }] -} +} \ No newline at end of file diff --git a/vagrantfile.tpl b/vagrantfile.tpl index f551b1b..d1963f7 100644 --- a/vagrantfile.tpl +++ b/vagrantfile.tpl @@ -2,11 +2,9 @@ Vagrant.configure("2") do |config| config.ssh.shell = "sh" config.ssh.username = "docker" - # Disable synced folders because guest additions aren't available - config.vm.synced_folder ".", "/vagrant", disabled: true - - # Expose the Docker port + # Expose the Docker ports (non secured AND secured) config.vm.network "forwarded_port", guest: 2375, host: 2375, host_ip: "127.0.0.1", auto_correct: true, id: "docker" + config.vm.network "forwarded_port", guest: 2376, host: 2376, host_ip: "127.0.0.1", auto_correct: true, id: "docker-ssl" # Attach the ISO config.vm.provider "virtualbox" do |v| @@ -16,7 +14,7 @@ Vagrant.configure("2") do |config| "--port", "0", "--device", "1", "--type", "dvddrive", - "--medium", File.expand_path("../boot2docker-vagrant.iso", __FILE__), + "--medium", File.expand_path("../boot2docker.iso", __FILE__), ] end @@ -24,7 +22,7 @@ Vagrant.configure("2") do |config| config.vm.provider vmware do |v| v.vmx["bios.bootOrder"] = "CDROM,hdd" v.vmx["ide1:0.present"] = "TRUE" - v.vmx["ide1:0.fileName"] = File.expand_path("../boot2docker-vagrant.iso", __FILE__) + v.vmx["ide1:0.fileName"] = File.expand_path("../boot2docker.iso", __FILE__) v.vmx["ide1:0.deviceType"] = "cdrom-image" end end @@ -34,11 +32,11 @@ Vagrant.configure("2") do |config| "set", :id, "--device-add", "cdrom", "--enable", "--connect", - "--image", File.expand_path("../boot2docker-vagrant.iso", __FILE__) + "--image", File.expand_path("../boot2docker.iso", __FILE__) ] v.customize "pre-boot", [ "set", :id, "--device-bootorder", "cdrom0 hdd0" ] end -end +end \ No newline at end of file