-
Notifications
You must be signed in to change notification settings - Fork 949
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add vagrant environment for development
Signed-off-by: u2takey <[email protected]>
- Loading branch information
Showing
4 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Vagrant cache | ||
.vagrant/ | ||
|
||
# ignore log | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- 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.hostname = "pouch-dev-node" | ||
end | ||
|
||
config.vm.box_check_update = false | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/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 |