mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Decouple backend DB and BigchainDB
This commit is contained in:
parent
5e479d831b
commit
f66c44689a
@ -1,4 +1,4 @@
|
|||||||
FROM rethinkdb:2.3
|
FROM ubuntu:xenial
|
||||||
|
|
||||||
# From http://stackoverflow.com/a/38553499
|
# 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?
|
# but maybe our Docker or Docker Compose stuff does?
|
||||||
# ENV BIGCHAINDB_API_ENDPOINT http://bigchaindb:9984/api/v1
|
# ENV BIGCHAINDB_API_ENDPOINT http://bigchaindb:9984/api/v1
|
||||||
|
|
||||||
ENTRYPOINT ["bigchaindb", "--dev-start-rethinkdb", "--dev-allow-temp-keypair"]
|
ENTRYPOINT ["bigchaindb"]
|
||||||
|
|
||||||
CMD ["start"]
|
CMD ["start"]
|
||||||
|
|
||||||
EXPOSE 8080 9984 28015 29015
|
|
||||||
|
@ -15,13 +15,21 @@ In a terminal shell, pull the latest version of the BigchainDB Docker image usin
|
|||||||
docker pull bigchaindb/bigchaindb
|
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
|
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`:
|
be stored in a file on your host machine at `~/bigchaindb_docker/.bigchaindb`:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
docker run --rm -v "$HOME/bigchaindb_docker:/data" -ti \
|
docker run \
|
||||||
bigchaindb/bigchaindb -y configure rethinkdb
|
--interactive \
|
||||||
|
--rm \
|
||||||
|
--tty \
|
||||||
|
--volume "$HOME/bigchaindb_docker:/data" \
|
||||||
|
bigchaindb/bigchaindb \
|
||||||
|
-y configure --dev-allow-temp-keypair \
|
||||||
|
[mongodb|rethinkdb]
|
||||||
|
|
||||||
Generating keypair
|
Generating keypair
|
||||||
Configuration written to /data/.bigchaindb
|
Configuration written to /data/.bigchaindb
|
||||||
Ready to go!
|
Ready to go!
|
||||||
@ -30,35 +38,77 @@ Ready to go!
|
|||||||
Let's analyze that command:
|
Let's analyze that command:
|
||||||
|
|
||||||
* `docker run` tells Docker to run some image
|
* `docker run` tells Docker to run some image
|
||||||
|
* `--interactive` keep STDIN open even if not attached
|
||||||
* `--rm` remove the container once we are done
|
* `--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`;
|
`$HOME/bigchaindb_docker` to the container directory `/data`;
|
||||||
this allows us to have the data persisted on the host machine,
|
this allows us to have the data persisted on the host machine,
|
||||||
you can read more in the [official Docker
|
you can read more in the [official Docker
|
||||||
documentation](https://docs.docker.com/engine/tutorials/dockervolumes/#/mount-a-host-directory-as-a-data-volume)
|
documentation](https://docs.docker.com/engine/tutorials/dockervolumes/#/mount-a-host-directory-as-a-data-volume)
|
||||||
* `-t` allocate a pseudo-TTY
|
* `bigchaindb/bigchaindb` the image to use. All the options after the container name are passed on to the entrypoint inside the container.
|
||||||
* `-i` keep STDIN open even if not attached
|
* `-y configure` execute the `configure` sub-command (of the `bigchaindb`
|
||||||
* `bigchaindb/bigchaindb` the image to use
|
command) inside the container, with the `-y` option to automatically use all the default config values
|
||||||
* `-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
|
||||||
|
|
||||||
|
|
||||||
After configuring the system, you can run BigchainDB with the following 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
|
||||||
|
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
|
```text
|
||||||
docker run -v "$HOME/bigchaindb_docker:/data" -d \
|
docker run \
|
||||||
--name bigchaindb \
|
--detach \
|
||||||
-p "58080:8080" -p "59984:9984" \
|
--name=rethinkdb \
|
||||||
bigchaindb/bigchaindb start
|
--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
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run BigchainDB
|
||||||
|
|
||||||
|
```text
|
||||||
|
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:
|
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
|
* `--name bigchaindb` give a nice name to the container so it's easier to
|
||||||
refer to it later
|
refer to it later
|
||||||
* `-p "58080:8080"` map the host port `58080` to the container port `8080`
|
* `--publish "59984:9984"` map the host port `59984` to the container port `9984`
|
||||||
(the RethinkDB admin interface)
|
|
||||||
* `-p "59984:9984"` map the host port `59984` to the container port `9984`
|
|
||||||
(the BigchainDB API server)
|
(the BigchainDB API server)
|
||||||
* `start` start the BigchainDB service
|
* `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
|
`--publish-all`) option. This will publish all exposed ports to random ports. You can
|
||||||
always run `docker ps` to check the random mapping.
|
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
|
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
|
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
|
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:
|
You can load test the BigchainDB running in that container by running the `bigchaindb load` command in a second container:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
docker run --rm -v "$HOME/bigchaindb_docker:/data" \
|
docker run \
|
||||||
-e BIGCHAINDB_DATABASE_HOST=bigchaindb \
|
--env BIGCHAINDB_DATABASE_HOST=bigchaindb \
|
||||||
--link 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`).
|
Note the `--link` option to link to the first container (named `bigchaindb`).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user