Skip to content

Commit 5409143

Browse files
committed
[FAB-3000] Remove reliance on vagrant baseimage
Maintaining the vagrant-baseimage is difficult since we lack suitable automation facilities. It has therefore become an impediment to producing new docker baseimages. In addition, it is also less important these days since most of the heavy lifting is performed by the docker infrastructure. Consider that when the baseimage for vagrant was created, we still needed to compile a bunch of basic tools (golang, protobufs rocksdb, etc). This is no longer true: Some of the tools are now available in binary form, others are exectuted within docker, and others are no longer used (e.g. rocksdb). Therefore, we can greatly simplify our processes by simply eliminating our reliance on a precompiled baseimage for vagrant. Because of the dockerization effort, all we really need is a basic platform with make, git, golang-1.7, and docker. We also include a few other items for developer convenience, such as behave, nodejs, and java. Fixes FAB-3000 Change-Id: Ic0749a1c0361a0b4a83d7ca6879e9d2bb50a5456 Signed-off-by: Gregory Haskins <[email protected]>
1 parent cacb292 commit 5409143

File tree

3 files changed

+111
-40
lines changed

3 files changed

+111
-40
lines changed

devenv/Vagrantfile

+1-4
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,9 @@ cd #{SRCMOUNT}/devenv
2929
3030
SCRIPT
3131

32-
baseimage_release = File.read '../.baseimage-release'
33-
3432
Vagrant.require_version ">= 1.7.4"
3533
Vagrant.configure('2') do |config|
36-
config.vm.box = "hyperledger/fabric-baseimage"
37-
config.vm.box_version = ENV['USE_LOCAL_BASEIMAGE'] ? "0": baseimage_release # Vagrant does not support versioning local images, the local version is always implicitly version 0
34+
config.vm.box = "ubuntu/xenial64"
3835

3936
config.vm.network :forwarded_port, guest: 7050, host: 7050 # fabric orderer service
4037
config.vm.network :forwarded_port, guest: 7051, host: 7051 # fabric peer service

devenv/setup.sh

+76-36
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,8 @@
11
#!/bin/bash
22

3-
helpme()
4-
{
5-
cat <<HELPMEHELPME
6-
Syntax: sudo $0
7-
8-
Installs the stuff needed to get the VirtualBox Ubuntu (or other similar Linux
9-
host) into good shape to run our development environment.
10-
11-
This script needs to run as root.
12-
13-
The current directory must be the dev-env project directory.
14-
15-
HELPMEHELPME
16-
}
17-
18-
if [[ "$1" == "-?" || "$1" == "-h" || "$1" == "--help" ]] ; then
19-
helpme
20-
exit 1
21-
fi
22-
23-
# Installs the stuff needed to get the VirtualBox Ubuntu (or other similar Linux
24-
# host) into good shape to run our development environment.
25-
26-
# ALERT: if you encounter an error like:
27-
# error: [Errno 1] Operation not permitted: 'cf_update.egg-info/requires.txt'
28-
# The proper fix is to remove any "root" owned directories under your update-cli directory
29-
# as source mount-points only work for directories owned by the user running vagrant
30-
31-
# Stop on first error
323
set -e
4+
set -x
335

34-
BASEIMAGE_RELEASE=`cat /etc/hyperledger-baseimage-release`
356
DEVENV_REVISION=`(cd /hyperledger/devenv; git rev-parse --short HEAD)`
367

378
# Install WARNING before we start provisioning so that it
@@ -40,6 +11,17 @@ DEVENV_REVISION=`(cd /hyperledger/devenv; git rev-parse --short HEAD)`
4011
SCRIPT_DIR="$(readlink -f "$(dirname "$0")")"
4112
cat "$SCRIPT_DIR/failure-motd.in" >> /etc/motd
4213

14+
# Update the entire system to the latest releases
15+
apt-get update
16+
#apt-get dist-upgrade -y
17+
18+
# Install some basic utilities
19+
apt-get install -y build-essential git make curl unzip g++ libtool
20+
21+
# ----------------------------------------------------------------
22+
# Install Docker
23+
# ----------------------------------------------------------------
24+
4325
# Storage backend logic
4426
case "${DOCKER_STORAGE_BACKEND}" in
4527
aufs|AUFS|"")
@@ -59,6 +41,22 @@ case "${DOCKER_STORAGE_BACKEND}" in
5941
exit 1;;
6042
esac
6143

44+
# Update system
45+
apt-get update -qq
46+
47+
# Prep apt-get for docker install
48+
apt-get install -y apt-transport-https ca-certificates
49+
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
50+
51+
# Add docker repository
52+
echo deb https://apt.dockerproject.org/repo ubuntu-xenial main > /etc/apt/sources.list.d/docker.list
53+
54+
# Update system
55+
apt-get update -qq
56+
57+
# Install docker
58+
apt-get install -y linux-image-extra-$(uname -r) apparmor docker-engine
59+
6260
# Install docker-compose
6361
curl -L https://github.com/docker/compose/releases/download/1.8.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
6462
chmod +x /usr/local/bin/docker-compose
@@ -68,19 +66,61 @@ DOCKER_OPTS="-s=${DOCKER_STORAGE_BACKEND_STRING} -r=true --api-cors-header='*' -
6866
sed -i.bak '/^DOCKER_OPTS=/{h;s|=.*|=\"'"${DOCKER_OPTS}"'\"|};${x;/^$/{s||DOCKER_OPTS=\"'"${DOCKER_OPTS}"'\"|;H};x}' /etc/default/docker
6967

7068
service docker restart
71-
usermod -a -G docker vagrant # Add vagrant user to the docker group
69+
usermod -a -G docker ubuntu # Add ubuntu user to the docker group
7270

7371
# Test docker
7472
docker run --rm busybox echo All good
7573

74+
# ----------------------------------------------------------------
75+
# Install Golang
76+
# ----------------------------------------------------------------
77+
GO_VER=1.7.5
78+
GO_URL=https://storage.googleapis.com/golang/go${GO_VER}.linux-amd64.tar.gz
79+
7680
# Set Go environment variables needed by other scripts
7781
export GOPATH="/opt/gopath"
78-
export GOROOT="/opt/go/"
82+
export GOROOT="/opt/go"
7983
PATH=$GOROOT/bin:$GOPATH/bin:$PATH
8084

85+
cat <<EOF >/etc/profile.d/goroot.sh
86+
export GOROOT=$GOROOT
87+
export GOPATH=$GOPATH
88+
export PATH=\$PATH:$GOROOT/bin:$GOPATH/bin
89+
EOF
90+
91+
mkdir -p $GOROOT
92+
93+
curl -sL $GO_URL | (cd $GOROOT && tar --strip-components 1 -xz)
94+
95+
# ----------------------------------------------------------------
96+
# Install NodeJS
97+
# ----------------------------------------------------------------
98+
NODE_VER=6.9.5
99+
NODE_URL=https://nodejs.org/dist/v$NODE_VER/node-v$NODE_VER-linux-x64.tar.gz
100+
101+
curl -sL $NODE_URL | (cd /usr/local && tar --strip-components 1 -xz )
102+
103+
# ----------------------------------------------------------------
104+
# Install Behave
105+
# ----------------------------------------------------------------
106+
/hyperledger/scripts/install_behave.sh
107+
108+
# ----------------------------------------------------------------
109+
# Install Java
110+
# ----------------------------------------------------------------
111+
apt-get install -y openjdk-8-jdk maven
112+
113+
wget https://services.gradle.org/distributions/gradle-2.12-bin.zip -P /tmp --quiet
114+
unzip -q /tmp/gradle-2.12-bin.zip -d /opt && rm /tmp/gradle-2.12-bin.zip
115+
ln -s /opt/gradle-2.12/bin/gradle /usr/bin
116+
117+
# ----------------------------------------------------------------
118+
# Misc tasks
119+
# ----------------------------------------------------------------
120+
81121
# Create directory for the DB
82122
sudo mkdir -p /var/hyperledger
83-
sudo chown -R vagrant:vagrant /var/hyperledger
123+
sudo chown -R ubuntu:ubuntu /var/hyperledger
84124

85125
# clean any previous builds as they may have image/.dummy files without
86126
# the backing docker images (since we are, by definition, rebuilding the
@@ -90,7 +130,7 @@ cd $GOPATH/src/github.com/hyperledger/fabric
90130
make clean gotools
91131

92132
# Ensure permissions are set for GOPATH
93-
sudo chown -R vagrant:vagrant $GOPATH
133+
sudo chown -R ubuntu:ubuntu $GOPATH
94134

95135
# Update limits.conf to increase nofiles for RocksDB
96136
sudo cp /hyperledger/devenv/limits.conf /etc/security/limits.conf
@@ -105,8 +145,8 @@ EOF
105145

106146
# Set our shell prompt to something less ugly than the default from packer
107147
# Also make it so that it cd's the user to the fabric dir upon logging in
108-
cat <<EOF >> /home/vagrant/.bashrc
109-
PS1="\u@hyperledger-devenv:v$BASEIMAGE_RELEASE-$DEVENV_REVISION:\w$ "
148+
cat <<EOF >> /home/ubuntu/.bashrc
149+
PS1="\u@hyperledger-devenv:$DEVENV_REVISION:\w$ "
110150
cd $GOPATH/src/github.com/hyperledger/fabric/
111151
EOF
112152

scripts/install_behave.sh

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# Update system
4+
apt-get update -qq
5+
6+
# Install Python, pip, behave, nose
7+
#
8+
# install python-dev and libyaml-dev to get compiled speedups
9+
apt-get install --yes python-dev
10+
apt-get install --yes libyaml-dev
11+
12+
apt-get install --yes python-setuptools
13+
apt-get install --yes python-pip
14+
pip install --upgrade pip
15+
pip install behave
16+
pip install nose
17+
18+
# updater-server, update-engine, and update-service-common dependencies (for running locally)
19+
pip install -I flask==0.10.1 python-dateutil==2.2 pytz==2014.3 pyyaml==3.10 couchdb==1.0 flask-cors==2.0.1 requests==2.4.3
20+
21+
# Python grpc package for behave tests
22+
# Required to update six for grpcio
23+
pip install --ignore-installed six
24+
pip install --upgrade 'grpcio==0.13.1'
25+
26+
# install ruby and apiaryio
27+
#apt-get install --yes ruby ruby-dev gcc
28+
#gem install apiaryio
29+
30+
# Install Tcl prerequisites for busywork
31+
apt-get install --yes tcl tclx tcllib
32+
33+
# Install NPM for the SDK
34+
apt-get install --yes npm

0 commit comments

Comments
 (0)