Skip to content

Commit

Permalink
add vagrant environment for development
Browse files Browse the repository at this point in the history
  • Loading branch information
u2takey committed Apr 28, 2018
1 parent da348c6 commit 59cf318
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ coverage.txt
.*.swp
.editorconfig
.bashrc
.vagrant

29 changes: 29 additions & 0 deletions hack/vagrant/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Vagrant Setup to Test the Pouch

This documentation highlights how to use [Vagrant](https://www.vagrantup.com/) to setup node to test pouch.

## Pre-requisites

This was tested on:

- Vagrant 1.9.5
- VirtualBox 5.1.26

## Getting Started

Clone this repo, change to the `hack/vagrant` directory and let Vagrant do the work.

$ vagrant up
$ vagrant status
Current machine states:

pouch-dev-node running (virtualbox)

You are now ready to SSH to `pouch-dev-node`, source code of pouch is mounted to /go/src/github.com/alibaba/pouch on `pouch-dev-node`.

$ vagrant ssh pouch-dev-node
vagrant@pouch-dev-node:~$ sudo su
root@pouch-dev-node:/home/vagrant# cd /go/src/github.com/alibaba/pouch/
root@pouch-dev-node:/go/src/github.com/alibaba/pouch# make && make test
...<snip>...

22 changes: 22 additions & 0 deletions hack/vagrant/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :


# refer: https://github.com/hashicorp/vagrant/issues/9442
Vagrant::DEFAULT_SERVER_URL.replace('https://vagrantcloud.com')

Vagrant.configure("2") do |config|
config.vm.boot_timeout=600
# ubuntu/xenial64 is from official ubuntu 16.04 LTS (Xenial Xerus) daily build, which is
# based on the long-term supported Linux release series 4.4, refer: https://app.vagrantup.com/ubuntu
config.vm.box = "ubuntu/xenial64"
config.vm.provision :shell, path: "bootstrap.sh"
config.vm.synced_folder "../../", "/go/src/github.com/alibaba/pouch"

config.vm.define "pouch-dev-node" do |node|
node.vm.network "private_network", ip: "172.30.30.10"
node.vm.hostname = "pouch-dev-node"
end

config.vm.box_check_update = false
end
54 changes: 54 additions & 0 deletions hack/vagrant/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash

set -euo pipefail

GOVERSION="${GOVERSION:-1.9.1}"
SOURCEPATH="${SOURCEPATH:-/go/src/github.com/alibaba/pouch}"


# install_pkgs install pkgs such as git/libncurses5-dev/...
# which is useful for pouch development environment
install_pkgs(){
apt-get update
apt-get install -y git \
libncurses5-dev \
libslang2-dev \
gettext \
zlib1g-dev \
libselinux1-dev \
debhelper \
lsb-release \
pkg-config \
po-debconf \
autoconf \
automake \
autopoint \
libtool
}

# install_go install go with version $GOVERSION with goenv
install_go(){
git clone --depth=1 https://github.com/syndbg/goenv.git ~/.goenv

PROFILE="$HOME/.bashrc"
echo 'export GOENV_ROOT="$HOME/.goenv"' >> $PROFILE
echo 'export PATH="$GOENV_ROOT/bin:$PATH"' >> $PROFILE
echo 'eval "$(goenv init -)"' >> $PROFILE
echo 'export GOPATH="/go"' >> $PROFILE

$HOME/.goenv/bin/goenv install $GOVERSION
$HOME/.goenv/bin/goenv global $GOVERSION
}

# install_docker install docker with get.docker.com's shell script
install_docker(){
curl -fsSL get.docker.com -o get-docker.sh
sh get-docker.sh
}
main() {
install_pkgs
install_go
install_docker
}

main

0 comments on commit 59cf318

Please sign in to comment.