From 150959b182e0845fc0e20148f35b779398cfc0a7 Mon Sep 17 00:00:00 2001 From: Matthew Wampler-Doty Date: Wed, 18 Mar 2015 01:02:04 -0700 Subject: [PATCH] Introducing make economy and docker --- Dockerfile | 27 +++++++++++++++++++++++++++ Makefile | 8 +++++++- Vagrantfile | 25 +++++++++++++++++++++++++ consensus/state.go | 4 ++-- 4 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 Dockerfile create mode 100644 Vagrantfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..615e348a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# Pull base image. +FROM golang:1.4.2-wheezy + +# Set the env variables to non-interactive +ENV DEBIAN_FRONTEND noninteractive +ENV DEBIAN_PRIORITY critical +ENV DEBCONF_NOWARNINGS yes +ENV TERM linux +RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections + +# Install go +# ADD tendermint user +RUN useradd tendermint + +# Get rid of tendermint user login shell +RUN usermod -s /sbin/nologin tendermint + +ADD . /go/src/github.com/tendermint/tendermint +WORKDIR /go/src/github.com/tendermint/tendermint +RUN make + +# Set environment variables +USER tendermint +ENV USER tendermint +ENV TMROOT /tendermint_root +# docker run -v $(pwd)/tendermint_root:/tendermint_root +CMD [ "./tendermint", "daemon" ] diff --git a/Makefile b/Makefile index d8ac7f82..7531cbe0 100644 --- a/Makefile +++ b/Makefile @@ -17,5 +17,11 @@ list_deps: get_deps: go get github.com/tendermint/tendermint/... +tendermint_root/priv_validator.json: tendermint_root/priv_validator.json.orig + cp $< $@ + +economy: tendermint_root/priv_validator.json + docker run -v $(CURDIR)/tendermint_root:/tendermint_root -p 8080:8080 tendermint + clean: - rm -f tendermint + rm -f tendermint tendermint_root/priv_validator.json diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 00000000..17ea8a1d --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,25 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + config.vm.box = "phusion-open-ubuntu-14.04-amd64" + config.vm.box_url = "https://oss-binaries.phusionpassenger.com/vagrant/boxes/latest/ubuntu-14.04-amd64-vbox.box" + # Or, for Ubuntu 12.04: + + config.vm.provider :vmware_fusion do |f, override| + override.vm.box_url = "https://oss-binaries.phusionpassenger.com/vagrant/boxes/latest/ubuntu-14.04-amd64-vmwarefusion.box" + end + + if Dir.glob("#{File.dirname(__FILE__)}/.vagrant/machines/default/*/id").empty? + # Install Docker + pkg_cmd = "wget -q -O - https://get.docker.io/gpg | apt-key add -;" \ + "echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list;" \ + "apt-get update -qq; apt-get install -q -y --force-yes lxc-docker; " + # Add vagrant user to the docker group + pkg_cmd << "usermod -a -G docker vagrant; " + config.vm.provision :shell, :inline => pkg_cmd + end +end diff --git a/consensus/state.go b/consensus/state.go index 24f32aa1..5d5ac8f9 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -71,8 +71,8 @@ import ( ) const ( - roundDuration0 = 30 * time.Second // The first round is 60 seconds long. - roundDurationDelta = 10 * time.Second // Each successive round lasts 15 seconds longer. + roundDuration0 = 10 * time.Second // The first round is 60 seconds long. + roundDurationDelta = 3 * time.Second // Each successive round lasts 15 seconds longer. roundDeadlinePrevote = float64(1.0 / 3.0) // When the prevote is due. roundDeadlinePrecommit = float64(2.0 / 3.0) // When the precommit vote is due. newHeightDelta = roundDuration0 / 3 // The time to wait between commitTime and startTime of next consensus rounds.