From ce18332b524facf4d3294be04a573437862f2c71 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Fri, 27 Jan 2017 21:10:13 +0400 Subject: [PATCH] update Dockerfile - update golang to 1.7.4 - version as env variable - change DATA_ROOT from /tendermint/data to /tendermint (it's not just data that gets stored in DATA_ROOT; we create data folder on start; as a result we get /tendermint/data/data, which is confusing) - remove noninteractive env vars (do we really need these?) - remove nodejs dep (some apps may require nodejs, but core is not one of them; it was convenient before, but now I believe we ought to remove it because other people who are using java do not want a bloated container with nodejs) - build tendermint inside a container (once again, it was convenient before, but now I am testing kubernetes and I don't want to wait every time TM compiles) --- DOCKER/Dockerfile | 74 ++++++++++++++++++++--------------------------- DOCKER/run.sh | 10 ------- 2 files changed, 32 insertions(+), 52 deletions(-) delete mode 100755 DOCKER/run.sh diff --git a/DOCKER/Dockerfile b/DOCKER/Dockerfile index 356fa8bf9..e640d4c05 100644 --- a/DOCKER/Dockerfile +++ b/DOCKER/Dockerfile @@ -1,54 +1,44 @@ -# Pull base image. -FROM golang:1.6 +FROM golang:1.7.4 -ENV USER tmuser -ENV DATA_ROOT /data/tendermint +# This is the release of tendermint to pull in. +ENV TM_VERSION 0.8.0 -# Set user right away for determinism -RUN groupadd -r $USER \ - && useradd -r -s /bin/false -g $USER $USER +# Tendermint will be looking for genesis file in /tendermint (unless you change +# `genesis_file` in config.toml). You can put your config.toml and private +# validator file into /tendermint. +# +# The /tendermint/data dir is used by tendermint to store state. +ENV DATA_ROOT /tendermint +ENV TMROOT $DATA_ROOT -# Create home directory for USER -# Needed for nodejs/nom -RUN mkdir -p /home/$USER \ - && chown -R $USER:$USER /home/$USER +# Set user right away for determinism +RUN groupadd -r tmuser && \ + useradd -r -s /bin/false -g tmuser tmuser # 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 (git) -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - git && \ - rm -rf /var/lib/apt/lists/* +RUN mkdir -p $DATA_ROOT && \ + chown -R tmuser:tmuser $DATA_ROOT -# Grab deps (node) -RUN curl -sL https://deb.nodesource.com/setup_5.x | bash - +# TODO replace with downloading a binary (this will allow us to replace golang +# base container with alpine|jessie - 600MB vs 50MB) RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - nodejs && \ - rm -rf /var/lib/apt/lists/* - -# Copy run.sh -COPY ./run.sh $DATA_ROOT/run.sh -RUN chmod +x $DATA_ROOT/run.sh - -# Persist data, set user -WORKDIR $DATA_ROOT + apt-get install -y --no-install-recommends \ + git && \ + rm -rf /var/lib/apt/lists/* +RUN mkdir -p $GOPATH/src/github.com/tendermint/tendermint && \ + cd $GOPATH/src/github.com/tendermint/tendermint && \ + git clone https://github.com/tendermint/tendermint.git . && \ + git fetch && \ + git reset --hard v$TM_VERSION && \ + make install + +# Expose the data directory as a volume since there's mutable state in there VOLUME $DATA_ROOT -USER $USER -ENV TMROOT $DATA_ROOT EXPOSE 46656 EXPOSE 46657 -# Run tendermint -CMD ["./run.sh"] +ENTRYPOINT ["tendermint"] + +# By default you'll get the dummy app +CMD ["node", "--moniker=`hostname`", "--proxy_app=dummy"] diff --git a/DOCKER/run.sh b/DOCKER/run.sh deleted file mode 100755 index 903cf667c..000000000 --- a/DOCKER/run.sh +++ /dev/null @@ -1,10 +0,0 @@ -#! /bin/bash - -mkdir -p $GOPATH/src/$TMREPO -cd $GOPATH/src/$TMREPO -git clone https://$TMREPO.git . -git fetch -git reset --hard $TMHEAD -go get -d $TMREPO/cmd/tendermint -make -tendermint node --seeds="$TMSEEDS" --moniker="$TMNAME"