upgraded DOCKER instructions

This commit is contained in:
Ethan Buchman 2015-09-21 19:46:14 +00:00 committed by Jae Kwon
parent 6d66223bf6
commit 10de637496
4 changed files with 34 additions and 65 deletions

View File

@ -1,16 +1,16 @@
# Pull base image. # Pull base image.
FROM golang:1.4 FROM golang:1.4
ENV user tendermint ENV USER tmuser
ENV data_root /data/tendermint ENV DATA_ROOT /data/tendermint
# set user right away for determinism # set user right away for determinism
RUN groupadd -r $user \ RUN groupadd -r $USER \
&& useradd -r -s /bin/false -g $user $user && useradd -r -s /bin/false -g $USER $USER
# create directory for persistence and give our user ownership # create directory for persistence and give our user ownership
RUN mkdir -p $data_root \ RUN mkdir -p $DATA_ROOT \
&& chown -R $user:$user $data_root && chown -R $USER:$USER $DATA_ROOT
# Set the env variables to non-interactive # Set the env variables to non-interactive
ENV DEBIAN_FRONTEND noninteractive ENV DEBIAN_FRONTEND noninteractive
@ -19,23 +19,21 @@ ENV DEBCONF_NOWARNINGS yes
ENV TERM linux ENV TERM linux
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
# grab deps (gmp) # grab deps (git)
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y --no-install-recommends \ apt-get install -y --no-install-recommends \
libgmp3-dev && \ git && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
# set the repo and install tendermint # copy run.sh
ENV repo /go/src/github.com/tendermint/tendermint COPY ./run.sh $DATA_ROOT/run.sh
ADD . $repo RUN chmod +x $DATA_ROOT/run.sh
WORKDIR $repo
RUN make
# persist data, set user # persist data, set user
VOLUME $data_root WORKDIR $DATA_ROOT
USER tendermint VOLUME $DATA_ROOT
ENV TMROOT $data_root USER $USER
ENV TMROOT $DATA_ROOT
# run tendermint # run tendermint
CMD ["./DOCKER/run.sh"] CMD ["./run.sh"]

View File

@ -1,33 +1,8 @@
# Build and run a docker image and container
# Persistence ```
cd DOCKER
./docker.sh
```
It's good practice to use a data-only container, alongside the main application. See DOCKER/docker.sh for more information
The `docker.sh` script sets it all up for you, and provides the
same functionality as `-v host_dir:image_dir` but by copying the data rather than
mounting it.
# To Play
The commands should work from tendermint/tendermint or tendermint/tendermint/DOCKER,
save the removal of DOCKER from the path.
Get quickly caught up with the testnet: `./DOCKER/docker.sh`
Use a pre-existing `~/.tendermint`: `VC=~/.tendermint NO_BUILD=true ./DOCKER/docker.sh`
This is like doing `-v ~/.tendermint:/data/tendermint`, but better.
Use `NO_BUILD` to avoid waiting if the image is already built.
Rerunning `docker.sh` will require you to delete the old containers:
`docker rm mint mintdata`
However, if you remove the `mintdata` container, you delete the data (the blockchain).
If you don't use the `VC` option, your key will be deleted too
To avoid deleting and recreating the data container, use
`VD=true NO_BUILD=true ./DOCKER/docker.sh`
Of course, once running, you can just control the main container with `docker stop mint` and `docker start mint`

View File

@ -2,20 +2,15 @@
# don't build if you're impatient # don't build if you're impatient
if [[ ! $NO_BUILD ]]; then if [[ ! $NO_BUILD ]]; then
cd $GOPATH/src/github.com/tendermint/tendermint cd $GOPATH/src/github.com/tendermint/tendermint/DOCKER
docker build -t mint -f DOCKER/Dockerfile . docker build -t tmbase -f Dockerfile .
fi fi
# create the data-only container # create the data-only container
if [[ ! $VD ]]; then docker run --name tmdata --entrypoint /bin/echo tmbase Data-only container for tmnode
docker run --name mintdata --entrypoint /bin/echo mint Data-only container for mint
fi
# copy a directory from host to data-only volume
if [[ $VC ]]; then
cd $VC
tar cf - . | docker run -i --rm --volumes-from mintdata mint tar xvf - -C /data/tendermint
fi
# run tendermint # run tendermint
docker run --name mint --volumes-from mintdata -d -p 46656:46656 -p 46657:46657 mint docker run name tmnode --volumes-from tmdata -d -p 46656:46656 -p 46657:46657 -e TMCOMMIT="origin/develop" tmbase
# cleanup
# docker rm -v -f tmdata tmnode; docker rmi -f tmbase

View File

@ -1,7 +1,8 @@
#! /bin/bash #! /bin/bash
if [[ $BARAK_SEED ]]; then go get -u github.com/tendermint/tendermint/cmd/tendermint
cat ./cmd/barak/$BARAK_SEED | ./build/barak & cd $GOPATH/src/github.com/tendermint/tendermint
fi git fetch -a origin
git reset --hard $TMHEAD
make
tendermint node tendermint node