From f66c44689a486f06d3546a595616f583dd05977c Mon Sep 17 00:00:00 2001 From: "krish7919 (Krish)" Date: Wed, 8 Feb 2017 17:10:45 +0100 Subject: [PATCH 1/3] Decouple backend DB and BigchainDB --- Dockerfile | 6 +- .../source/appendices/run-with-docker.md | 96 ++++++++++++++----- 2 files changed, 75 insertions(+), 27 deletions(-) diff --git a/Dockerfile b/Dockerfile index f5e4b3b1fc..ed0ca462eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM rethinkdb:2.3 +FROM ubuntu:xenial # From http://stackoverflow.com/a/38553499 @@ -34,8 +34,6 @@ ENV BIGCHAINDB_SERVER_BIND 0.0.0.0:9984 # but maybe our Docker or Docker Compose stuff does? # ENV BIGCHAINDB_API_ENDPOINT http://bigchaindb:9984/api/v1 -ENTRYPOINT ["bigchaindb", "--dev-start-rethinkdb", "--dev-allow-temp-keypair"] +ENTRYPOINT ["bigchaindb"] CMD ["start"] - -EXPOSE 8080 9984 28015 29015 diff --git a/docs/server/source/appendices/run-with-docker.md b/docs/server/source/appendices/run-with-docker.md index d6e33a70cc..6c4011021d 100644 --- a/docs/server/source/appendices/run-with-docker.md +++ b/docs/server/source/appendices/run-with-docker.md @@ -15,13 +15,21 @@ In a terminal shell, pull the latest version of the BigchainDB Docker image usin docker pull bigchaindb/bigchaindb ``` -then do a one-time configuration step to create the config file; we will use +### Configuration +A one-time configuration step is required to create the config file; we will use the `-y` option to accept all the default values. The configuration file will be stored in a file on your host machine at `~/bigchaindb_docker/.bigchaindb`: ```text -docker run --rm -v "$HOME/bigchaindb_docker:/data" -ti \ - bigchaindb/bigchaindb -y configure rethinkdb +docker run \ + --interactive \ + --rm \ + --tty \ + --volume "$HOME/bigchaindb_docker:/data" \ + bigchaindb/bigchaindb \ + -y configure --dev-allow-temp-keypair \ + [mongodb|rethinkdb] + Generating keypair Configuration written to /data/.bigchaindb Ready to go! @@ -30,35 +38,77 @@ Ready to go! Let's analyze that command: * `docker run` tells Docker to run some image +* `--interactive` keep STDIN open even if not attached * `--rm` remove the container once we are done -* `-v "$HOME/bigchaindb_docker:/data"` map the host directory +* `--tty` allocate a pseudo-TTY +* `--volume "$HOME/bigchaindb_docker:/data"` map the host directory `$HOME/bigchaindb_docker` to the container directory `/data`; this allows us to have the data persisted on the host machine, you can read more in the [official Docker documentation](https://docs.docker.com/engine/tutorials/dockervolumes/#/mount-a-host-directory-as-a-data-volume) -* `-t` allocate a pseudo-TTY -* `-i` keep STDIN open even if not attached -* `bigchaindb/bigchaindb` the image to use -* `-y configure` execute the `configure` sub-command (of the `bigchaindb` command) inside the container, with the `-y` option to automatically use all the default config values +* `bigchaindb/bigchaindb` the image to use. All the options after the container name are passed on to the entrypoint inside the container. +* `-y configure` execute the `configure` sub-command (of the `bigchaindb` + command) inside the container, with the `-y` option to automatically use all the default config values +* `--dev-allow-temp-keypair` specifies that this is a dev environment and + enables creation of temporary key pairs to be written to the configuration + file +* `mongodb` or `rethinkdb` specifies the database backend to use with bigchaindb + + +### Run the backend database +From v0.9 onwards, you can run either RethinkDB or MongoDB. + +We use the virtual interface created by the docker daemon to allow +communication between the BigchainDB and database containers. +It has an IP address of 172.17.0.1 by default. + +You can also use docker host networking or bind to your primary (eth) + interface, if needed. + +#### For RethinkDB + +```text +docker run \ + --detach \ + --name=rethinkdb \ + --publish=172.17.0.1:28015:28015 \ + --publish=172.17.0.1:58080:8080 \ + rethinkdb:2.3 +``` + +You can also access the RethinkDB dashboard at +[http://localhost:58080/](http://localhost:58080/) + + +#### For MongoDB + +```text +docker run \ + --detach \ + --name=mongodb \ + --publish=172.17.0.1:27017:27017 \ + mongo:3.4.1 --replSet=bigchain-rs +``` -After configuring the system, you can run BigchainDB with the following command: +### Run BigchainDB ```text -docker run -v "$HOME/bigchaindb_docker:/data" -d \ - --name bigchaindb \ - -p "58080:8080" -p "59984:9984" \ - bigchaindb/bigchaindb start +docker run \ + --detach \ + --name=bigchaindb \ + --publish=59984:9984 \ + --volume=$HOME/bigchaindb_docker:/data \ + bigchaindb/bigchaindb \ + start ``` The command is slightly different from the previous one, the differences are: -* `-d` run the container in the background +* `--detach` run the container in the background * `--name bigchaindb` give a nice name to the container so it's easier to refer to it later -* `-p "58080:8080"` map the host port `58080` to the container port `8080` - (the RethinkDB admin interface) -* `-p "59984:9984"` map the host port `59984` to the container port `9984` +* `--publish "59984:9984"` map the host port `59984` to the container port `9984` (the BigchainDB API server) * `start` start the BigchainDB service @@ -66,9 +116,6 @@ Another way to publish the ports exposed by the container is to use the `-P` (or `--publish-all`) option. This will publish all exposed ports to random ports. You can always run `docker ps` to check the random mapping. -You can also access the RethinkDB dashboard at -[http://localhost:58080/](http://localhost:58080/) - If that doesn't work, then replace `localhost` with the IP or hostname of the machine running the Docker engine. If you are running docker-machine (e.g. on Mac OS X) this will be the IP of the Docker machine (`docker-machine ip @@ -89,10 +136,13 @@ You should see a container named `bigchaindb` in the list. You can load test the BigchainDB running in that container by running the `bigchaindb load` command in a second container: ```text -docker run --rm -v "$HOME/bigchaindb_docker:/data" \ - -e BIGCHAINDB_DATABASE_HOST=bigchaindb \ +docker run \ + --env BIGCHAINDB_DATABASE_HOST=bigchaindb \ --link bigchaindb \ - bigchaindb/bigchaindb load + --rm \ + --volume "$HOME/bigchaindb_docker:/data" \ + bigchaindb/bigchaindb \ + load ``` Note the `--link` option to link to the first container (named `bigchaindb`). From 1be05d3ffc24fc56ea641d76b577dd1719340341 Mon Sep 17 00:00:00 2001 From: "krish7919 (Krish)" Date: Thu, 9 Feb 2017 09:55:53 +0100 Subject: [PATCH 2/3] Changes as requested by @ttmc --- docs/server/source/appendices/run-with-docker.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/server/source/appendices/run-with-docker.md b/docs/server/source/appendices/run-with-docker.md index 6c4011021d..7c6f97778a 100644 --- a/docs/server/source/appendices/run-with-docker.md +++ b/docs/server/source/appendices/run-with-docker.md @@ -27,7 +27,7 @@ docker run \ --tty \ --volume "$HOME/bigchaindb_docker:/data" \ bigchaindb/bigchaindb \ - -y configure --dev-allow-temp-keypair \ + -y configure \ [mongodb|rethinkdb] Generating keypair @@ -58,7 +58,7 @@ Let's analyze that command: ### Run the backend database From v0.9 onwards, you can run either RethinkDB or MongoDB. -We use the virtual interface created by the docker daemon to allow +We use the virtual interface created by the Docker daemon to allow communication between the BigchainDB and database containers. It has an IP address of 172.17.0.1 by default. From 2a9042f39cb081de62a64adc904a1389095e0a6b Mon Sep 17 00:00:00 2001 From: "krish7919 (Krish)" Date: Wed, 15 Feb 2017 11:20:41 +0100 Subject: [PATCH 3/3] Typo: Removing redundant line from docs --- docs/server/source/appendices/run-with-docker.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/server/source/appendices/run-with-docker.md b/docs/server/source/appendices/run-with-docker.md index 7c6f97778a..9b72726858 100644 --- a/docs/server/source/appendices/run-with-docker.md +++ b/docs/server/source/appendices/run-with-docker.md @@ -49,9 +49,6 @@ Let's analyze that command: * `bigchaindb/bigchaindb` the image to use. All the options after the container name are passed on to the entrypoint inside the container. * `-y configure` execute the `configure` sub-command (of the `bigchaindb` command) inside the container, with the `-y` option to automatically use all the default config values -* `--dev-allow-temp-keypair` specifies that this is a dev environment and - enables creation of temporary key pairs to be written to the configuration - file * `mongodb` or `rethinkdb` specifies the database backend to use with bigchaindb