Skip to content

Commit

Permalink
Merge pull request #7 from /issues/7
Browse files Browse the repository at this point in the history
v0.6
  • Loading branch information
suin committed Sep 18, 2015
2 parents ea3389d + 087f9bd commit 8c0e057
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 48 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
packer_cache
packer_cache
*.box
output-*
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
build:
packer build template.json

only-vmware:
packer build --only vmware-iso template.json

only-virtualbox:
packer build --only virtualbox-iso template.json

clean:
rm -fv *.box
rm -rfv output-*

add-box:
-vagrant box remove docker-vmware
vagrant box add ubuntu-14.04-with-docker.vmware.box --name docker-vmware
3 changes: 3 additions & 0 deletions scripts/dev-tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

apt-get -yq install dstat
4 changes: 4 additions & 0 deletions scripts/docker-compose.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

curl -L https://github.com/docker/compose/releases/download/1.4.1/docker-compose-Linux-x86_64 > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
17 changes: 2 additions & 15 deletions scripts/docker-containers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,14 @@
set -eu

CONTAINERS=(
"clue/httpie"
"java:8u66"
"nginx:1.9.1"
"mysql"
"selenium/hub:2.44.0"
"shouldbee/ansible-boto"
"shouldbee/baseimage-go"
"shouldbee/bootstrap-compile-kit"
"shouldbee/codecept"
"shouldbee/coffeescript"
"shouldbee/dredd"
"shouldbee/flyway"
"shouldbee/go"
"shouldbee/html2pdf"
"shouldbee/nginx-https-reverse-proxy"
"shouldbee/phantomjs"
"shouldbee/php"
"shouldbee/php-cs-fixer"
"shouldbee/scala:2.10.4"
"shouldbee/selenium"
"shouldbee/selenium-node-chrome"
"shouldbee/selenium-node-firefox"
"shouldbee/tcpproxy"
"sylvainlasnier/memcached"
)

Expand Down
4 changes: 0 additions & 4 deletions scripts/docker-fig.sh

This file was deleted.

16 changes: 2 additions & 14 deletions scripts/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,9 @@ do
sudo usermod -a -G docker $user
done

# add repository
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9

sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"

# install curl
apt-get update
apt-get install -y curl

# Update your sources
apt-get update

# Install. Confirm install.
# apt-get install -y docker.io
apt-get install -y lxc-docker

# Link docker.io to docker
# ln -s /usr/bin/docker.io /usr/bin/docker
# install docker
curl -sSL https://get.docker.com/ | sh
17 changes: 12 additions & 5 deletions scripts/fusion.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
# Install the Linux headers
apt-get -y install build-essential linux-headers-$(uname -r)
set -eu

# Install the VMware Fusion guest tools
echo "==> install the linux headers"
apt-get -yqq install git build-essential linux-headers-$(uname -r)

echo "==> install the vmware fusion guest tools"
cd /tmp

echo "==> download vmware-tools-patches"
git clone https://github.com/rasa/vmware-tools-patches.git
mkdir -p /mnt/cdrom
mount -o loop ~/linux.iso /mnt/cdrom
tar zxf /mnt/cdrom/VMwareTools-*.tar.gz -C /tmp/
/tmp/vmware-tools-distrib/vmware-install.pl -d
cp /mnt/cdrom/VMwareTools-*.tar.gz /tmp/vmware-tools-patches/
cd /tmp/vmware-tools-patches/
./untar-and-patch-and-compile.sh
rm /home/ubuntu/linux.iso
umount /mnt/cdrom
rm -rf /tmp/vmware-tools-patches
8 changes: 5 additions & 3 deletions scripts/vagrant.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -eu

useradd -m -s /bin/bash vagrant

for user in vagrant ubuntu
Expand All @@ -15,15 +17,15 @@ do
mkdir -p /home/$user/.ssh
chmod 700 /home/$user/.ssh
cd /home/$user/.ssh
wget --no-check-certificate 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub' -O authorized_keys
wget --quiet --no-check-certificate 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub' -O authorized_keys

chmod 600 /home/$user/.ssh/authorized_keys
chown -R $user /home/$user/.ssh
done

# Install NFS for ubuntu
apt-get update
apt-get install -y nfs-common
apt-get -qq update
apt-get -yqq install nfs-common

# Set up .bashrc
cat << EOF >> /home/vagrant/.bashrc
Expand Down
10 changes: 10 additions & 0 deletions scripts/vm_cleanup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/bin/bash

# Removing apt caches
echo "cleaning apt caches"
rm -rf /var/lib/apt/lists/*
apt-get autoremove
apt-get clean

# Removing leftover leases and persistent rules
echo "cleaning up dhcp leases"
rm /var/lib/dhcp/*
Expand All @@ -14,6 +20,10 @@ rm /lib/udev/rules.d/75-persistent-net-generator.rules
echo "Adding a 2 sec delay to the interface up, to make the dhclient happy"
echo "pre-up sleep 2" >> /etc/network/interfaces

# Truncate log files
echo "cleaning /var/log files"
find /var/log -type f -exec truncate -s 0 {} \;

# Zero out the free space to save space in the final image:
echo "Zeroing device to make space..."
dd if=/dev/zero of=/EMPTY bs=1M
Expand Down
22 changes: 16 additions & 6 deletions template.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
"aws_access_key": "",
"aws_secret_key": ""
},

"builders": [
{
"type": "vmware-iso",
"iso_url": "http://ftp.jaist.ac.jp/pub/Linux/ubuntu-releases/trusty/ubuntu-14.04.2-server-amd64.iso",
"iso_checksum": "8acd2f56bfcba2f7ac74a7e4a5e565ce68c024c38525c0285573e41c86ae90c0",
"vm_name": "ubuntu",
"headless": true,
"iso_url": "http://ftp.jaist.ac.jp/pub/Linux/ubuntu-releases/trusty/ubuntu-14.04.3-server-amd64.iso",
"iso_checksum": "a3b345908a826e262f4ea1afeb357fd09ec0558cf34e6c9112cead4bb55ccdfb",
"iso_checksum_type": "sha256",
"boot_wait": "5s",
"boot_command": [
Expand All @@ -29,8 +30,10 @@
},
{
"type": "virtualbox-iso",
"iso_url": "http://ftp.jaist.ac.jp/pub/Linux/ubuntu-releases/trusty/ubuntu-14.04.2-server-amd64.iso",
"iso_checksum": "8acd2f56bfcba2f7ac74a7e4a5e565ce68c024c38525c0285573e41c86ae90c0",
"vm_name": "ubuntu",
"headless": true,
"iso_url": "http://ftp.jaist.ac.jp/pub/Linux/ubuntu-releases/trusty/ubuntu-14.04.3-server-amd64.iso",
"iso_checksum": "a3b345908a826e262f4ea1afeb357fd09ec0558cf34e6c9112cead4bb55ccdfb",
"iso_checksum_type": "sha256",
"boot_wait": "5s",
"boot_command": [
Expand All @@ -54,6 +57,11 @@
],

"provisioners": [
{
"type": "shell",
"scripts": "scripts/dev-tools.sh",
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -E -S bash '{{.Path}}'"
},
{
"type": "shell",
"script": "scripts/fusion.sh",
Expand Down Expand Up @@ -95,7 +103,7 @@
},
{
"type": "shell",
"scripts": "scripts/docker-fig.sh",
"scripts": "scripts/docker-compose.sh",
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -E -S bash '{{.Path}}'"
},
{
Expand All @@ -108,6 +116,8 @@
"post-processors": [
{
"type": "vagrant",
"output": "ubuntu-14.04-with-docker.{{.Provider}}.box",
"compression_level": 9,
"keep_input_artifact": true
}
]
Expand Down

0 comments on commit 8c0e057

Please sign in to comment.