|
| 1 | +#!/bin/bash -ex |
| 2 | + |
| 3 | +# |
| 4 | +# Prepare a Deis-optimized AMI from a vanilla Ubuntu 12.04 |
| 5 | +# |
| 6 | +# Instructions: |
| 7 | +# |
| 8 | +# 1. Launch a vanilla Ubuntu 12.04 instance (64-bit with an EBS root volume) |
| 9 | +# 2. SSH in and install the 3.8 kernel with: |
| 10 | +# apt-get update && apt-get install -yq linux-generic-lts-raring && reboot |
| 11 | +# 3. After reboot is complete, SSH in and `uname -r` to confirm kernel is 3.8 |
| 12 | +# 4. Run this script (as root!) to optimize the image for fast boot times |
| 13 | +# 5. Create a new AMI from the root volume |
| 14 | +# 6. Distribute the AMI to other regions using `ec2-copy-image` |
| 15 | +# 7. Create/update your Deis flavors to use your new AMIs |
| 16 | +# |
| 17 | + |
| 18 | +# add docker ppa |
| 19 | +apt-add-repository ppa:dotcloud/lxc-docker -y |
| 20 | + |
| 21 | +# upgrade to latest packages |
| 22 | +apt-get update |
| 23 | +apt-get dist-upgrade -yq |
| 24 | + |
| 25 | +# install required packages |
| 26 | +apt-get install lxc-docker curl git python-setuptools python-pip -yq |
| 27 | + |
| 28 | +# create buildstep docker image |
| 29 | +git clone https://github.com/opdemand/buildstep.git |
| 30 | +cd buildstep |
| 31 | +./build.sh ./stack deis/buildstep |
| 32 | +cd .. |
| 33 | +rm -rf buildstep |
| 34 | + |
| 35 | +# install chef 11.x deps |
| 36 | +apt-get install -yq ruby1.9.1 ruby1.9.1-dev make |
| 37 | +update-alternatives --set ruby /usr/bin/ruby1.9.1 |
| 38 | +update-alternatives --set gem /usr/bin/gem1.9.1 |
| 39 | + |
| 40 | +# clean and remove old packages |
| 41 | +apt-get clean |
| 42 | +apt-get autoremove -yq |
| 43 | + |
| 44 | +# reset cloud-init |
| 45 | +rm -rf /var/lib/cloud |
| 46 | + |
| 47 | +# purge SSH authorized keys |
| 48 | +rm -f /home/ubuntu/.ssh/authorized_keys |
| 49 | +rm -f /root/.ssh/authorized_keys |
| 50 | + |
| 51 | +# ssh host keys are automatically regenerated |
| 52 | +# on system boot by ubuntu cloud init |
| 53 | + |
| 54 | +# purge /var/log |
| 55 | +find /var/log -type f | xargs rm |
| 56 | + |
| 57 | +# flush writes to block storage |
| 58 | +sync |
0 commit comments