github.com/vipernet-xyz/tm@v0.34.24/docs/networks/docker-compose.md (about)

     1  ---
     2  order: 2
     3  ---
     4  
     5  # Docker Compose
     6  
     7  With Docker Compose, you can spin up local testnets with a single command.
     8  
     9  ## Requirements
    10  
    11  1. [Install tendermint](../introduction/install.md)
    12  2. [Install docker](https://docs.docker.com/engine/installation/)
    13  3. [Install docker-compose](https://docs.docker.com/compose/install/)
    14  
    15  ## Build
    16  
    17  Build the `tendermint` binary and, optionally, the `tendermint/localnode`
    18  docker image.
    19  
    20  Note the binary will be mounted into the container so it can be updated without
    21  rebuilding the image.
    22  
    23  ```sh
    24  # Build the linux binary in ./build
    25  make build-linux
    26  
    27  # (optionally) Build tendermint/localnode image
    28  make build-docker-localnode
    29  ```
    30  
    31  ## Run a testnet
    32  
    33  To start a 4 node testnet run:
    34  
    35  ```sh
    36  make localnet-start
    37  ```
    38  
    39  The nodes bind their RPC servers to ports 26657, 26660, 26662, and 26664 on the
    40  host.
    41  
    42  This file creates a 4-node network using the localnode image.
    43  
    44  The nodes of the network expose their P2P and RPC endpoints to the host machine
    45  on ports 26656-26657, 26659-26660, 26661-26662, and 26663-26664 respectively.
    46  
    47  To update the binary, just rebuild it and restart the nodes:
    48  
    49  ```sh
    50  make build-linux
    51  make localnet-start
    52  ```
    53  
    54  ## Configuration
    55  
    56  The `make localnet-start` creates files for a 4-node testnet in `./build` by
    57  calling the `tendermint testnet` command.
    58  
    59  The `./build` directory is mounted to the `/tendermint` mount point to attach
    60  the binary and config files to the container.
    61  
    62  To change the number of validators / non-validators change the `localnet-start` Makefile target [here](../../Makefile):
    63  
    64  ```makefile
    65  localnet-start: localnet-stop
    66    @if ! [ -f build/node0/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/tendermint:Z tendermint/localnode testnet --v 5 --n 3 --o . --populate-persistent-peers --starting-ip-address 192.167.10.2 ; fi
    67    docker-compose up
    68  ```
    69  
    70  The command now will generate config files for 5 validators and 3
    71  non-validators. Along with generating new config files the docker-compose file needs to be edited.
    72  Adding 4 more nodes is required in order to fully utilize the config files that were generated.
    73  
    74  ```yml
    75    node3: # bump by 1 for every node
    76      container_name: node3 # bump by 1 for every node
    77      image: "tendermint/localnode"
    78      environment:
    79        - ID=3
    80        - LOG=${LOG:-tendermint.log}
    81      ports:
    82        - "26663-26664:26656-26657" # Bump 26663-26664 by one for every node
    83      volumes:
    84        - ./build:/tendermint:Z
    85      networks:
    86        localnet:
    87          ipv4_address: 192.167.10.5 # bump the final digit by 1 for every node
    88  ```
    89  
    90  Before running it, don't forget to cleanup the old files:
    91  
    92  ```sh
    93  # Clear the build folder
    94  rm -rf ./build/node*
    95  ```
    96  
    97  ## Configuring ABCI containers
    98  
    99  To use your own ABCI applications with 4-node setup edit the [docker-compose.yaml](https://github.com/vipernet-xyz/tm/blob/v0.34.x/docker-compose.yml) file and add image to your ABCI application.
   100  
   101  ```yml
   102   abci0:
   103      container_name: abci0
   104      image: "abci-image"
   105      build:
   106        context: .
   107        dockerfile: abci.Dockerfile
   108      command: <insert command to run your abci application>
   109      networks:
   110        localnet:
   111          ipv4_address: 192.167.10.6
   112  
   113    abci1:
   114      container_name: abci1
   115      image: "abci-image"
   116      build:
   117        context: .
   118        dockerfile: abci.Dockerfile
   119      command: <insert command to run your abci application>
   120      networks:
   121        localnet:
   122          ipv4_address: 192.167.10.7
   123  
   124    abci2:
   125      container_name: abci2
   126      image: "abci-image"
   127      build:
   128        context: .
   129        dockerfile: abci.Dockerfile
   130      command: <insert command to run your abci application>
   131      networks:
   132        localnet:
   133          ipv4_address: 192.167.10.8
   134  
   135    abci3:
   136      container_name: abci3
   137      image: "abci-image"
   138      build:
   139        context: .
   140        dockerfile: abci.Dockerfile
   141      command: <insert command to run your abci application>
   142      networks:
   143        localnet:
   144          ipv4_address: 192.167.10.9
   145  
   146  ```
   147  
   148  Override the [command](https://github.com/vipernet-xyz/tm/blob/v0.34.x/networks/local/localnode/Dockerfile#L12) in each node to connect to it's ABCI.
   149  
   150  ```yml
   151    node0:
   152      container_name: node0
   153      image: "tendermint/localnode"
   154      ports:
   155        - "26656-26657:26656-26657"
   156      environment:
   157        - ID=0
   158        - LOG=$${LOG:-tendermint.log}
   159      volumes:
   160        - ./build:/tendermint:Z
   161      command: node --proxy_app=tcp://abci0:26658
   162      networks:
   163        localnet:
   164          ipv4_address: 192.167.10.2
   165  ```
   166  
   167  Similarly do for node1, node2 and node3 then [run testnet](https://github.com/vipernet-xyz/tm/blob/v0.34.x/docs/networks/docker-compose.md#run-a-testnet)
   168  
   169  ## Logging
   170  
   171  Log is saved under the attached volume, in the `tendermint.log` file. If the
   172  `LOG` environment variable is set to `stdout` at start, the log is not saved,
   173  but printed on the screen.
   174  
   175  ## Special binaries
   176  
   177  If you have multiple binaries with different names, you can specify which one
   178  to run with the `BINARY` environment variable. The path of the binary is relative
   179  to the attached volume.