docker
This commit is contained in:
parent
57ff919d50
commit
5d7df99591
|
@ -0,0 +1,41 @@
|
|||
# Pull base image.
|
||||
FROM golang:1.4.2-wheezy
|
||||
|
||||
ENV user tendermint
|
||||
ENV data_root /data/tendermint
|
||||
|
||||
# set user right away for determinism
|
||||
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
|
||||
|
||||
# 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
|
||||
|
||||
# grab deps (gmp)
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
libgmp3-dev && \
|
||||
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
|
||||
|
||||
# persist data, set user
|
||||
VOLUME $data_root
|
||||
USER tendermint
|
||||
ENV TMROOT $data_root
|
||||
|
||||
# run tendermint
|
||||
CMD ["./run.sh"]
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
# Persistence
|
||||
|
||||
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
|
||||
|
||||
Get quickly caught up with the testnet: `FAST_SYNC=true ./DOCKER/docker.sh`
|
||||
|
||||
Use a pre-existing `~/.tendermint`: `VC=~/.tendermint NO_BUILD=true ./docker.sh`
|
||||
|
||||
This is like doing `-v ~/.tendermint:/data/tendermint`, but better.
|
||||
|
||||
Use `NO_BUILD` to avoid waiting if the image is already built. If you don't use
|
||||
`NO_BUILD`, you should be in `tendermint/tendermint`, and using `./DOCKER/docker.sh`
|
||||
|
||||
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.sh`
|
||||
|
||||
Of course, once running, you can just control the main container with `docker stop mint` and `docker start mint`
|
|
@ -0,0 +1,20 @@
|
|||
#! /bin/bash
|
||||
|
||||
# don't build if you're impatient
|
||||
if [[ ! $NO_BUILD ]]; then
|
||||
docker build -t mint .
|
||||
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 --volumes-from mintdata mint tar xvf - -C /data/tendermint
|
||||
fi
|
||||
|
||||
# run tendermint
|
||||
docker run --name mint --volumes-from mintdata -d -p 46656:46656 -p 46657:46657 -e FAST_SYNC=$FAST_SYNC mint
|
|
@ -0,0 +1,12 @@
|
|||
#! /bin/bash
|
||||
|
||||
if [[ $BARAK_SEED ]]; then
|
||||
cat ./cmd/barak/$BARAK_SEED | ./build/barak &
|
||||
fi
|
||||
|
||||
if [[ $FAST_SYNC ]]; then
|
||||
./build/tendermint node --fast_sync
|
||||
else
|
||||
./build/tendermint node
|
||||
fi
|
||||
|
32
Dockerfile
32
Dockerfile
|
@ -1,32 +0,0 @@
|
|||
# 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
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
libgmp3-dev && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 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 [ "./build/tendermint", "node" ]
|
4
Makefile
4
Makefile
|
@ -2,7 +2,7 @@
|
|||
|
||||
all: build
|
||||
|
||||
build: get_deps
|
||||
build:
|
||||
go build -o build/tendermint github.com/tendermint/tendermint/cmd/tendermint
|
||||
go build -o build/barak github.com/tendermint/tendermint/cmd/barak
|
||||
go build -o build/debora github.com/tendermint/tendermint/cmd/debora
|
||||
|
@ -12,7 +12,7 @@ no_get:
|
|||
go build -o build/barak github.com/tendermint/tendermint/cmd/barak
|
||||
go build -o build/debora github.com/tendermint/tendermint/cmd/debora
|
||||
|
||||
build_race: get_deps
|
||||
build_race:
|
||||
go build -race -o build/tendermint github.com/tendermint/tendermint/cmd/tendermint
|
||||
go build -race -o build/barak github.com/tendermint/tendermint/cmd/barak
|
||||
go build -race -o build/debora github.com/tendermint/tendermint/cmd/debora
|
||||
|
|
Loading…
Reference in New Issue