Browse Source

upgraded DOCKER instructions

pull/157/head
Ethan Buchman 9 years ago
committed by Jae Kwon
parent
commit
10de637496
4 changed files with 34 additions and 65 deletions
  1. +16
    -18
      DOCKER/Dockerfile
  2. +6
    -31
      DOCKER/README.md
  3. +7
    -12
      DOCKER/docker.sh
  4. +5
    -4
      DOCKER/run.sh

+ 16
- 18
DOCKER/Dockerfile View File

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

+ 6
- 31
DOCKER/README.md 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.
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`
See DOCKER/docker.sh for more information

+ 7
- 12
DOCKER/docker.sh View File

@ -2,20 +2,15 @@
# don't build if you're impatient
if [[ ! $NO_BUILD ]]; then
cd $GOPATH/src/github.com/tendermint/tendermint
docker build -t mint -f DOCKER/Dockerfile .
cd $GOPATH/src/github.com/tendermint/tendermint/DOCKER
docker build -t tmbase -f Dockerfile .
fi
# create the data-only container
if [[ ! $VD ]]; then
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
docker run --name tmdata --entrypoint /bin/echo tmbase Data-only container for tmnode
# 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

+ 5
- 4
DOCKER/run.sh View File

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

Loading…
Cancel
Save