mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Docker dev setup docs (#653)
* Include configuration step in Dockerfile * Document dev setup with docker-compose * Add server API env vars and port * Parameterize SERVER_BIND and API_ENDPOINT env vars * Give a bit more detailed information on GET /
This commit is contained in:
parent
a759a48d79
commit
1ae08990c8
@ -10,3 +10,4 @@ RUN pip install --upgrade pip
|
|||||||
COPY . /usr/src/app/
|
COPY . /usr/src/app/
|
||||||
|
|
||||||
RUN pip install --no-cache-dir -e .[dev]
|
RUN pip install --no-cache-dir -e .[dev]
|
||||||
|
RUN bigchaindb -y configure
|
||||||
|
@ -10,7 +10,7 @@ config = {
|
|||||||
'server': {
|
'server': {
|
||||||
# Note: this section supports all the Gunicorn settings:
|
# Note: this section supports all the Gunicorn settings:
|
||||||
# - http://docs.gunicorn.org/en/stable/settings.html
|
# - http://docs.gunicorn.org/en/stable/settings.html
|
||||||
'bind': 'localhost:9984',
|
'bind': os.environ.get('BIGCHAINDB_SERVER_BIND') or 'localhost:9984',
|
||||||
'workers': None, # if none, the value will be cpu_count * 2 + 1
|
'workers': None, # if none, the value will be cpu_count * 2 + 1
|
||||||
'threads': None, # if none, the value will be cpu_count * 2 + 1
|
'threads': None, # if none, the value will be cpu_count * 2 + 1
|
||||||
},
|
},
|
||||||
@ -29,7 +29,7 @@ config = {
|
|||||||
'port': 8125,
|
'port': 8125,
|
||||||
'rate': 0.01,
|
'rate': 0.01,
|
||||||
},
|
},
|
||||||
'api_endpoint': 'http://localhost:9984/api/v1',
|
'api_endpoint': os.environ.get('BIGCHAINDB_API_ENDPOINT') or 'http://localhost:9984/api/v1',
|
||||||
'backlog_reassign_delay': 30
|
'backlog_reassign_delay': 30
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,8 +27,10 @@ services:
|
|||||||
- ./setup.py:/usr/src/app/setup.py
|
- ./setup.py:/usr/src/app/setup.py
|
||||||
- ./setup.cfg:/usr/src/app/setup.cfg
|
- ./setup.cfg:/usr/src/app/setup.cfg
|
||||||
- ./pytest.ini:/usr/src/app/pytest.ini
|
- ./pytest.ini:/usr/src/app/pytest.ini
|
||||||
- ~/.bigchaindb_docker:/root/.bigchaindb_docker
|
|
||||||
environment:
|
environment:
|
||||||
BIGCHAINDB_DATABASE_HOST: rdb
|
BIGCHAINDB_DATABASE_HOST: rdb
|
||||||
BIGCHAINDB_CONFIG_PATH: /root/.bigchaindb_docker/config
|
BIGCHAINDB_API_ENDPOINT: http://bdb:9984/api/v1
|
||||||
|
BIGCHAINDB_SERVER_BIND: 0.0.0.0:9984
|
||||||
|
ports:
|
||||||
|
- "9984"
|
||||||
command: bigchaindb start
|
command: bigchaindb start
|
||||||
|
@ -38,3 +38,87 @@ The BigchainDB [CONTRIBUTING.md file](https://github.com/bigchaindb/bigchaindb/b
|
|||||||
Ian Worrall of [Encrypted Labs](http://www.encryptedlabs.com/) wrote a document (PDF) explaining how to set up a BigchainDB (Server) dev machine on [Cloud9](https://c9.io/):
|
Ian Worrall of [Encrypted Labs](http://www.encryptedlabs.com/) wrote a document (PDF) explaining how to set up a BigchainDB (Server) dev machine on [Cloud9](https://c9.io/):
|
||||||
|
|
||||||
[Download that document from GitHub](https://github.com/bigchaindb/bigchaindb/raw/master/docs/source/_static/cloud9.pdf)
|
[Download that document from GitHub](https://github.com/bigchaindb/bigchaindb/raw/master/docs/source/_static/cloud9.pdf)
|
||||||
|
|
||||||
|
|
||||||
|
## Option C: Using a Local Dev Machine and Docker
|
||||||
|
|
||||||
|
You need to have recent versions of [docker engine](https://docs.docker.com/engine/installation/#installation)
|
||||||
|
and [docker-compose](https://docs.docker.com/compose/install/).
|
||||||
|
|
||||||
|
Build the images:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose build
|
||||||
|
```
|
||||||
|
|
||||||
|
Start RethinkDB:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose up -d rdb
|
||||||
|
```
|
||||||
|
|
||||||
|
The RethinkDB web interface should be accessible at <http://localhost:58080/>.
|
||||||
|
Depending on which platform, and/or how you are running docker, you may need
|
||||||
|
to change `localhost` for the `ip` of the machine that is running docker. As a
|
||||||
|
dummy example, if the `ip` of that machine was `0.0.0.0`, you would accees the
|
||||||
|
web interface at: <http://0.0.0.0:58080/>.
|
||||||
|
|
||||||
|
Start a BigchainDB node:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose up -d bdb
|
||||||
|
```
|
||||||
|
|
||||||
|
You can monitor the logs:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose logs -f bdb
|
||||||
|
```
|
||||||
|
|
||||||
|
If you wish to run the tests:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose run --rm bdb py.test -v -n auto
|
||||||
|
```
|
||||||
|
|
||||||
|
A quick check to make sure that the BigchainDB server API is operational:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl $(docker-compose port bdb 9984)
|
||||||
|
```
|
||||||
|
|
||||||
|
should give you something like:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
{
|
||||||
|
"api_endpoint": "http://bdb:9984/api/v1",
|
||||||
|
"keyring": [],
|
||||||
|
"public_key": "Brx8g4DdtEhccsENzNNV6yvQHR8s9ebhKyXPFkWUXh5e",
|
||||||
|
"software": "BigchainDB",
|
||||||
|
"version": "0.6.0"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
How does the above curl command work? Inside the Docker container, BigchainDB
|
||||||
|
exposes the HTTP API on port `9984`. First we get the public port where that
|
||||||
|
port is bound:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose port bdb 9984
|
||||||
|
```
|
||||||
|
|
||||||
|
The port binding will change whenever you stop/restart the `bdb` service. You
|
||||||
|
should get an output similar to:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
0.0.0.0:32772
|
||||||
|
```
|
||||||
|
|
||||||
|
but with a port different from `32772`.
|
||||||
|
|
||||||
|
|
||||||
|
Knowing the public port we can now perform a simple `GET` operation against the
|
||||||
|
root:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl 0.0.0.0:32772
|
||||||
|
```
|
||||||
|
@ -121,6 +121,8 @@ def test_autoconfigure_read_both_from_file_and_env(monkeypatch):
|
|||||||
monkeypatch.setattr('bigchaindb.config_utils.file_config', lambda *args, **kwargs: file_config)
|
monkeypatch.setattr('bigchaindb.config_utils.file_config', lambda *args, **kwargs: file_config)
|
||||||
monkeypatch.setattr('os.environ', {'BIGCHAINDB_DATABASE_NAME': 'test-dbname',
|
monkeypatch.setattr('os.environ', {'BIGCHAINDB_DATABASE_NAME': 'test-dbname',
|
||||||
'BIGCHAINDB_DATABASE_PORT': '4242',
|
'BIGCHAINDB_DATABASE_PORT': '4242',
|
||||||
|
'BIGCHAINDB_API_ENDPOINT': 'api://ipa',
|
||||||
|
'BIGCHAINDB_SERVER_BIND': '1.2.3.4:56',
|
||||||
'BIGCHAINDB_KEYRING': 'pubkey_0:pubkey_1:pubkey_2'})
|
'BIGCHAINDB_KEYRING': 'pubkey_0:pubkey_1:pubkey_2'})
|
||||||
|
|
||||||
import bigchaindb
|
import bigchaindb
|
||||||
@ -130,7 +132,7 @@ def test_autoconfigure_read_both_from_file_and_env(monkeypatch):
|
|||||||
assert bigchaindb.config == {
|
assert bigchaindb.config == {
|
||||||
'CONFIGURED': True,
|
'CONFIGURED': True,
|
||||||
'server': {
|
'server': {
|
||||||
'bind': 'localhost:9984',
|
'bind': '1.2.3.4:56',
|
||||||
'workers': None,
|
'workers': None,
|
||||||
'threads': None,
|
'threads': None,
|
||||||
},
|
},
|
||||||
@ -149,7 +151,7 @@ def test_autoconfigure_read_both_from_file_and_env(monkeypatch):
|
|||||||
'port': 8125,
|
'port': 8125,
|
||||||
'rate': 0.01,
|
'rate': 0.01,
|
||||||
},
|
},
|
||||||
'api_endpoint': 'http://localhost:9984/api/v1',
|
'api_endpoint': 'api://ipa',
|
||||||
'backlog_reassign_delay': 5
|
'backlog_reassign_delay': 5
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user