From db4bba72a235a52b7cb96058d4fc2bfd1a56b5ec Mon Sep 17 00:00:00 2001 From: Greg Szabo Date: Tue, 4 Jul 2017 16:23:51 +0000 Subject: [PATCH] Added dockerfiles for applications --- ansible/extract-testnet-config.yml | 32 ---------- docker/README.md | 95 ++++++++++++++++++++++++++++++ docker/basecoin/Dockerfile | 14 +++++ docker/ethermint/Dockerfile | 15 +++++ docker/tendermint/Dockerfile | 14 +++++ 5 files changed, 138 insertions(+), 32 deletions(-) delete mode 100644 ansible/extract-testnet-config.yml create mode 100644 docker/README.md create mode 100644 docker/basecoin/Dockerfile create mode 100644 docker/ethermint/Dockerfile create mode 100644 docker/tendermint/Dockerfile diff --git a/ansible/extract-testnet-config.yml b/ansible/extract-testnet-config.yml deleted file mode 100644 index 2383fad6..00000000 --- a/ansible/extract-testnet-config.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -#Copy genesis.json and config.toml from the testnet - -#variable "service" is required - -- hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}" - gather_facts: no - - vars: - - testnet_name: "{{lookup('env','TF_VAR_TESTNET_NAME')}}" - output_dir: "{{OUTPUT|default('.')}}" - - tasks: - - - name: Create local folder structure - file: "path={{item}} state=directory recurse=yes" - with_items: - - "{{output_dir}}/{{testnet_name}}/tendermint" - - "{{output_dir}}/{{testnet_name}}/{{service}}" - connection: local - run_once: true - - - name: Copy files from remote host - synchronize: "mode=pull src={{item.src}} dest={{item.dest}}" - with_items: - - { src: "/etc/{{service}}/tendermint/genesis.json", dest: "{{output_dir}}/{{testnet_name}}/tendermint" } - - { src: "/etc/{{service}}/tendermint/config.toml", dest: "{{output_dir}}/{{testnet_name}}/tendermint" } - - { src: "/etc/{{service}}/genesis.json", dest: "{{output_dir}}/{{testnet_name}}/{{service}}" } - become: no - run_once: true - diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 00000000..fc867973 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,95 @@ +# Docker container description for Tendermint applications + +* Overview (#Overview) +* Tendermint (#Tendermint) +* Basecoin (#Basecoin) +* Ethermint (#Ethermint) + +## Overview + +This folder contains Docker container descriptions. Using this folder you can build your own Docker images with the tendermint application. + +It is assumed that you set up docker already. + +If you don't want to build the images yourself, you should be able to download them from Docker Hub. + +## Tendermint + +Build the container: +Copy the `tendermint` binary to the `tendermint` folder. +``` +docker build -t tendermint tendermint +``` + +The application configuration will be stored at `/tendermint` in the container. The ports 46656 and 46657 will be open for ABCI applications to connect. + +Initialize tendermint configuration and keep it after the container is finished in a docker volume called `data`: +``` +docker run --rm -v data:/tendermint tendermint init +``` +If you want the docker volume to be a physical directory on your filesystem, you have to give an absolute path to docker and make sure the permissions allow the application to write it. + +Get the public key of tendermint: +``` +docker run --rm -v data:/tendermint tendermint show_validator +``` + +Run the docker tendermint application with: +``` +docker run --rm -d -v data:/tendermint tendermint node +``` + +## Basecoin + +Build the container: +Copy the `basecoin` binary to the `basecoin` folder. +``` +docker build -t basecoin basecoin +``` +The application configuration will be stored at `/basecoin`. + +Initialize basecoin configuration and keep it after the container is finished: +``` +docker run --rm -v basecoindata:/basecoin basecoin init deadbeef +``` +Use your own basecoin account instead of `deadbeef` in the `init` command. + +Get the public key of basecoin: +We use a trick here: since the basecoin and the tendermint configuration folders are similar, the `tendermint` command can extract the public key for us if we feed the basecoin configuration folder to tendermint. +``` +docker run --rm -v basecoindata:/tendermint tendermint show_validator +``` + +Run the docker tendermint application with: +This is a two-step process: +* Run the basecoin container. +* Run the tendermint container and expose the ports that allow clients to connect. The --proxy_app should contain the basecoin application's IP address and port. +``` +docker run --rm -d -v basecoindata:/basecoin basecoin start --without-tendermint +docker run --rm -d -v data:/tendermint -p 46656-46657:46656-46657 tendermint node --proxy_app tcp://172.17.0.2:46658 +``` + +## Ethermint + +Build the container: +Copy the `ethermint` binary and the setup folder to the `ethermint` folder. +``` +docker build -t ethermint ethermint +``` +The application configuration will be stored at `/ethermint`. +The files required for initializing ethermint (the files in the source `setup` folder) are under `/setup`. + +Initialize ethermint configuration: +``` +docker run --rm -v ethermintdata:/ethermint ethermint init /setup/genesis.json +``` + +Start ethermint as a validator node: +This is a two-step process: +* Run the ethermint container. You will have to define where tendermint runs as the ethermint binary connects to it explicitly. +* Run the tendermint container and expose the ports that allow clients to connect. The --proxy_app should contain the ethermint application's IP address and port. +``` +docker run --rm -d -v ethermintdata:/ethermint ethermint --tendermint_addr tcp://172.17.0.3:46657 +docker run --rm -d -v data:/tendermint -p 46656-46657:46656-46657 tendermint node --proxy_app tcp://172.17.0.2:46658 +``` + diff --git a/docker/basecoin/Dockerfile b/docker/basecoin/Dockerfile new file mode 100644 index 00000000..42d01883 --- /dev/null +++ b/docker/basecoin/Dockerfile @@ -0,0 +1,14 @@ +FROM busybox +#Use --build-arg to change where the basecoin binary resides +ARG BASECOIN_BINARY=basecoin +ENV BCHOME /basecoin +COPY $BASECOIN_BINARY /usr/bin/basecoin +RUN adduser -h $BCHOME -D basecoin +VOLUME [ $BCHOME ] +EXPOSE 46658 +USER basecoin +ENTRYPOINT ["/usr/bin/basecoin"] +CMD ["start","--without-tendermint"] +WORKDIR $BCHOME +STOPSIGNAL SIGTERM + diff --git a/docker/ethermint/Dockerfile b/docker/ethermint/Dockerfile new file mode 100644 index 00000000..3f5a9ab9 --- /dev/null +++ b/docker/ethermint/Dockerfile @@ -0,0 +1,15 @@ +FROM busybox +#Use --build-arg to change where the ethermint binary and setup directory resides +ARG ETHERMINT_BINARY=ethermint +ARG SETUP_DIR=setup +ENV EMHOME /ethermint +COPY $ETHERMINT_BINARY /usr/bin/ethermint +COPY $SETUP_DIR /setup +RUN adduser -h $EMHOME -D ethermint +VOLUME [ $EMHOME ] +EXPOSE 46658 +USER ethermint +ENTRYPOINT ["/usr/bin/ethermint","--datadir","$EMHOME"] +WORKDIR $EMHOME +STOPSIGNAL SIGTERM + diff --git a/docker/tendermint/Dockerfile b/docker/tendermint/Dockerfile new file mode 100644 index 00000000..3344c1fd --- /dev/null +++ b/docker/tendermint/Dockerfile @@ -0,0 +1,14 @@ +FROM busybox +#Use --build-arg to change where the tendermint binary resides +ARG TENDERMINT_BINARY=tendermint +ENV TMHOME /tendermint +COPY $TENDERMINT_BINARY /usr/bin/tendermint +RUN adduser -h $TMHOME -D tendermint +VOLUME [ $TMHOME ] +EXPOSE 46656 46657 +USER tendermint +ENTRYPOINT ["/usr/bin/tendermint"] +CMD ["node"] +WORKDIR $TMHOME +STOPSIGNAL SIGTERM +