From aac1a358740001abd1e9c6eafcd696412ecdb38c Mon Sep 17 00:00:00 2001 From: Ahmed Sghaier Date: Thu, 31 Mar 2016 23:04:01 +0100 Subject: [PATCH] Added support for Debian/Ubuntu and Mac OSX and improved setup steps --- .ahoy.yml | 56 ++++++++++++++++++------ .ahoy/arch.ahoy.yml | 57 +++++++++++++++++++++---- .ahoy/debian.ahoy.yml | 99 +++++++++++++++++++++++++++++++++++++++++++ .ahoy/mac.ahoy.yml | 89 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 279 insertions(+), 22 deletions(-) create mode 100644 .ahoy/debian.ahoy.yml create mode 100644 .ahoy/mac.ahoy.yml diff --git a/.ahoy.yml b/.ahoy.yml index 1147e7f..4ea0586 100644 --- a/.ahoy.yml +++ b/.ahoy.yml @@ -1,18 +1,32 @@ ahoyapi: v1 version: 0.0.0 commands: + help: - usage: Mac setup commands - import: .ahoy/arch.ahoy.yml + usage: Development environment setup help + cmd: | + echo 'For a full docker development environment setup use the following command: + ahoy setup + + For a step by step setup use the following commands in order: + ahoy deps + ahoy virtualbox + ahoy docker + ahoy nfs + ahoy machine' + mac: usage: Mac setup commands - import: .ahoy/arch.ahoy.yml + import: .ahoy/mac.ahoy.yml + debian: usage: Debian setup commands - import: .ahoy/arch.ahoy.yml + import: .ahoy/debian.ahoy.yml + arch: usage: Arch Linux setup commands import: .ahoy/arch.ahoy.yml + os: usage: Checks the Operating System cmd: | @@ -27,6 +41,17 @@ commands: fi fi echo $os + + shell: + usage: Prints the default shell + cmd: | + echo "$(echo $SHELL|rev|cut -d/ -f1|rev)" + + rcfile: + usage: Prints the rcfile path of the default shell + cmd: | + echo "$HOME/.$(ahoy shell)rc" + setup: usage: Setup the development environment cmd: | @@ -36,6 +61,17 @@ commands: echo "[Error] This OS is not supported." exit 1 fi + + deps: + usage: Install dependencies + cmd: | + if [ "$(ahoy os)" != "" ]; then + ahoy $(ahoy os) deps {{args}} + else + echo "[Error] This OS is not supported." + exit 1 + fi + virtualbox: usage: Install Virtualbox cmd: | @@ -45,6 +81,7 @@ commands: echo "[Error] This OS is not supported." exit 1 fi + docker: usage: Install Docker cmd: | @@ -54,6 +91,7 @@ commands: echo "[Error] This OS is not supported." exit 1 fi + nfs: usage: Install NFS cmd: | @@ -63,15 +101,7 @@ commands: echo "[Error] This OS is not supported." exit 1 fi - deps: - usage: Install dependencies - cmd: | - if [ "$(ahoy os)" != "" ]; then - ahoy $(ahoy os) deps {{args}} - else - echo "[Error] This OS is not supported." - exit 1 - fi + machine: usage: Create the "default" Docker machine cmd: | diff --git a/.ahoy/arch.ahoy.yml b/.ahoy/arch.ahoy.yml index 9c38c8b..0f11629 100644 --- a/.ahoy/arch.ahoy.yml +++ b/.ahoy/arch.ahoy.yml @@ -1,46 +1,85 @@ ahoyapi: v1 version: 0.0.0 commands: + setup: usage: Setup the Arch Linux development environment cmd: | + set -e + + ahoy arch deps ahoy arch virtualbox ahoy arch docker ahoy arch nfs - ahoy arch deps ahoy arch machine + + deps: + usage: Install dependencies + cmd: | + echo; echo "*** Dependencies Setup ***"; echo + set -e + + echo "*** Setting up perl-digest-hmac..." + yaourt -S perl-digest-hmac + virtualbox: usage: Install Virtualbox cmd: | + echo; echo "*** Virtualbox Setup ***"; echo + set -e + + echo "*** Virtualbox setup..." yaourt -S virtualbox virtualbox-guest-dkms virtualbox-guest-iso virtualbox-guest-utils virtualbox-host-dkms + + echo "*** Virtualbox drivers setup..." sudo /sbin/rcvboxdrv setup + + echo "*** Virtualbox kernel modules loading at system bootup..." sudo sh -c "echo -e \"vboxnetadp\nvboxnetflt\nvboxpci\nvboxdrv\" > /etc/modules-load.d/virtualbox.conf" + docker: usage: Install Docker cmd: | + echo; echo "*** Docker Setup ***"; echo + set -e + + echo "*** Docker, docker-compose and docker-machine setup..." yaourt -S docker docker-compose docker-machine + nfs: usage: Install NFS cmd: | + echo; echo "*** NFS Setup ***"; echo + set -e + + echo "*** Docker-machine-nfs setup..." sudo wget -q https://raw.githubusercontent.com/asghaier/docker-machine-nfs/arch-linux-support/docker-machine-nfs.sh -O /usr/local/bin/docker-machine-nfs && sudo chmod 755 /usr/local/bin/docker-machine-nfs + + echo "*** NTP and NFS-utils setup..." yaourt -S ntp nfs-utils + + echo "*** Starting and enabling bootup services for NTP daemon and NFS server..." sudo systemctl start ntpd.service sudo systemctl enable ntpd.service sudo systemctl start nfs-server.service sudo systemctl enable nfs-server.service - deps: - usage: Install dependencies - cmd: | - yaourt -S perl-digest-hmac + machine: usage: Create the "default" Docker machine cmd: | + echo; echo "*** Default Docker Machine Setup ***"; echo + set -e + MACHINE_NAME=default - SHARE_FOLDER=$HOME/docker - RC_FILE=$HOME/.zshrc + + echo "*** Creating the default docker machine using the virtualbox driver..." docker-machine create --driver virtualbox $MACHINE_NAME - docker-machine-nfs $MACHINE_NAME --nfs-config="(rw,sync,all_squash,anonuid=$(id -u),anongid=$(id -g),no_subtree_check)" --shared-folder=$SHARE_FOLDER --force + + echo "*** Setting up docker machine nfs for the default machine..." + docker-machine-nfs $MACHINE_NAME --nfs-config="(rw,sync,all_squash,anonuid=$(id -u),anongid=$(id -g),no_subtree_check)" --shared-folder=$HOME/docker --force + + echo "*** Environment variables setup and sourcing for the default machine..." DEFAULT_SOURCE="$HOME/.default.docker-machine" docker-machine env $MACHINE_NAME | grep -v "^#" > $DEFAULT_SOURCE source $DEFAULT_SOURCE - echo "source $DEFAULT_SOURCE" >> $RC_FILE + echo "source $DEFAULT_SOURCE" >> $(ahoy rcfile) diff --git a/.ahoy/debian.ahoy.yml b/.ahoy/debian.ahoy.yml new file mode 100644 index 0000000..06ec89c --- /dev/null +++ b/.ahoy/debian.ahoy.yml @@ -0,0 +1,99 @@ +ahoyapi: v1 +version: 0.0.0 +commands: + + setup: + usage: Setup the Arch Linux development environment + cmd: | + set -e + + ahoy arch deps + ahoy arch virtualbox + ahoy arch docker + ahoy arch nfs + ahoy arch machine + + deps: + usage: Install dependencies + cmd: | + echo; echo "*** Dependencies Setup ***"; echo + set -e + + echo "*** Installing Perl digest hmac..." + sudo apt-get install libdigest-hmac-perl -y + + virtualbox: + usage: Install Virtualbox + cmd: | + echo; echo "*** Virtualbox Setup ***"; echo + set -e + + echo "*** Adding virtualbox to apt sources..." + echo "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release --codename -s) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list > /dev/null && wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add - && sudo apt-get update + + echo "*** Virtualbox setup..." + sudo apt-get install virtualbox-5.0 + + docker: + usage: Install Docker + cmd: | + echo; echo "*** Docker Setup ***"; echo + set -e + + MACHINE_MD5_LINUX_64=5558e5d7d003d337eacdc534c505dc5d + COMPOSE_MD5_LINUX_64=cb7f2d7f1a45bcff83cfd4669b1dcf53 + DOCKER_MD5_LINUX_64=4583697764e695dd6d7f68d2834b5443 + + echo "*** Adding docker to apt sources..." + sudo apt-get install apt-transport-https ca-certificates && sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D && echo "deb https://apt.dockerproject.org/repo ubuntu-${OS[$codename]} main" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null && sudo apt-get update + + echo "*** Remove legacy lxc-docker if it exists..." + sudo apt-get purge lxc-docker + + echo "*** Install linux-image-extra..." + sudo apt-get install linux-image-extra-$(uname -r) + + if [ $(cat /etc/*release|grep -i 'ubuntu'|wc -l) -gt 0 ]; then + echo "*** Install apparmor on Ubunu..." + sudo apt-get install apparmor + fi + + echo "*** Installing docker-engine..." + echo $DOCKER_MD5_LINUX_64 /usr/bin/docker | md5sum -c - || sudo apt-get install docker-engine && echo $DOCKER_MD5_LINUX_64 /usr/bin/docker | md5sum -c - + + echo "*** Installing docker-machine..." + echo $MACHINE_MD5_LINUX_64 /usr/local/bin/docker-machine | md5sum -c - || sudo wget -q https://github.com/docker/machine/releases/download/v0.6.0/docker-machine-`uname -s`-`uname -m` -O /usr/local/bin/docker-machine && sudo chmod 755 /usr/local/bin/docker-machine && echo $MACHINE_MD5_LINUX_64 /usr/local/bin/docker-machine | md5sum -c - + + echo "*** Installing docker-compose..." + echo $COMPOSE_MD5_LINUX_64 /usr/local/bin/docker-compose | md5sum -c - || sudo wget -q https://github.com/docker/compose/releases/download/1.6.0/docker-compose-`uname -s`-`uname -m` -O /usr/local/bin/docker-compose && sudo chmod 755 /usr/local/bin/docker-compose && echo $COMPOSE_MD5_LINUX_64 /usr/local/bin/docker-compose | md5sum -c - + + nfs: + usage: Install NFS + cmd: | + echo; echo "*** NFS Setup ***"; echo + set -e + + # Note that we needed to modify the docker-machine-nfs script to work with linux. So load the custom version. + # See https://github.com/adlogix/docker-machine-nfs/pull/51 + echo "*** Installing docker-machine-nfs (custom version)..." + sudo wget -q https://raw.githubusercontent.com/devinci-code/docker-machine-nfs/dev-50-support-linux/docker-machine-nfs.sh -O /usr/local/bin/docker-machine-nfs && sudo chmod 755 /usr/local/bin/docker-machine-nfs + + machine: + usage: Create the "default" Docker machine + cmd: | + echo; echo "*** Default Docker Machine Setup ***"; echo + set -e + + MACHINE_NAME=default + + echo "*** Creating a default docker-machine..." + docker-machine create --driver virtualbox $MACHINE_NAME + + echo "*** Setting up the default docker-machine with NFS..." + docker-machine-nfs $MACHINE_NAME --nfs-config="(rw,sync,all_squash,anonuid=$(id -u),anongid=$(id -g),no_subtree_check)" --shared-folder=$HOME/docker --force + + echo "*** Environment variables setup and sourcing for the default machine..." + DEFAULT_SOURCE="$HOME/.default.docker-machine" + docker-machine env $MACHINE_NAME | grep -v "^#" > $DEFAULT_SOURCE + source $DEFAULT_SOURCE + echo "source $DEFAULT_SOURCE" >> $(ahoy rcfile) diff --git a/.ahoy/mac.ahoy.yml b/.ahoy/mac.ahoy.yml new file mode 100644 index 0000000..a53994f --- /dev/null +++ b/.ahoy/mac.ahoy.yml @@ -0,0 +1,89 @@ +ahoyapi: v1 +version: 0.0.0 +commands: + + setup: + usage: Setup the Arch Linux development environment + cmd: | + set -e + + ahoy arch deps + ahoy arch virtualbox + ahoy arch docker + ahoy arch nfs + ahoy arch machine + + deps: + usage: Install dependencies + cmd: | + echo; echo "*** Dependencies Setup ***"; echo + set -e + + # Assume homebrew is a requirement for now + if [ ! "$(which brew)" ]; then + echo "[Error] It looks like homebrew isn't installed. Please install that first." + exit 1 + fi + + echo "*** Updating Homebrew..." + brew update + + if [ -z "$(brew cask update)" ]; then + echo "[Error] It looks like homebrew cask isn't installed. As of Dec 2015, it should come with homebrew. Try 'brew update'" + fi + + virtualbox: + usage: Install Virtualbox + cmd: | + echo; echo "*** Virtualbox Setup ***"; echo + set -e + + echo "Installing the latest virtualbox" + brew update + + docker: + usage: Install Docker + cmd: | + echo; echo "*** Docker Setup ***"; echo + set -e + + echo "*** Installing docker-engine..." + brew install docker + + echo "*** Installing docker-machine..." + brew install docker-machine + + echo "*** Installing docker-machine..." + brew install docker-machine + + nfs: + usage: Install NFS + cmd: | + echo; echo "*** NFS Setup ***"; echo + set -e + + echo "*** Installing docker-machine-nfs..." + curl -s https://raw.githubusercontent.com/adlogix/docker-machine-nfs/master/docker-machine-nfs.sh | sudo tee /usr/local/bin/docker-machine-nfs > /dev/null && sudo chmod +x /usr/local/bin/docker-machine-nfs + + machine: + usage: Create the "default" Docker machine + cmd: | + echo; echo "*** Default Docker Machine Setup ***"; echo + set -e + + MACHINE_NAME=default + + echo "*** Creating a default docker-machine..." + docker-machine create --driver virtualbox $MACHINE_NAME + + echo "*** Setting up the default docker-machine with NFS..." + docker-machine-nfs $MACHINE_NAME + + echo "*** Starting docker-machine $MACHINE_NAME..." + docker-machine start $MACHINE_NAME + + echo "*** Environment variables setup and sourcing for the default machine..." + DEFAULT_SOURCE="$HOME/.default.docker-machine" + docker-machine env $MACHINE_NAME | grep -v "^#" > $DEFAULT_SOURCE + source $DEFAULT_SOURCE + echo "source $DEFAULT_SOURCE" >> $(ahoy rcfile)