From f414a0fa13f0f0b670b951e793ce54b3d07bff63 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Fri, 26 Jan 2018 11:59:41 -0800 Subject: [PATCH] Update instructions for running in docker --- api/README.md | 18 ++++++++++++++++++ api/deployment/client.ini | 6 +++--- api/docker-compose.yaml | 18 +++++++++++++++++- api/ops | 21 ++++++++++++++++++--- 4 files changed, 56 insertions(+), 7 deletions(-) diff --git a/api/README.md b/api/README.md index 68d3b29bc..2c33faf82 100644 --- a/api/README.md +++ b/api/README.md @@ -6,6 +6,21 @@ In general, all documentation is in the [docs/](https://github.com/blockstack/bl Instructions for deploying your own (public) node are [here](https://github.com/blockstack/blockstack-core/tree/master/docs/install-api.md). +### Running in docker + +This directory contains the necessary components for running this API in docker for development purposes. To do so run the following commands: + +```bash +# First run the init steps for each service: +$ ./ops init-core +$ ./ops init-api +$ ./ops init-indexer + +# Then build the docker images and run them +# NOTE: this build step takes quite a bit of time +$ docker-compose up --build -d +``` + ### Environment Variables for Deployment The following is a list of environmental variables that help configure the API, and their defaults: @@ -43,4 +58,7 @@ SEARCH_NODE_URL=https://search.example.org # SEARCH_DEFAULT_LIMIT sets the number of results per call SEARCH_DEFAULT_LIMIT=50 + +# BSK_API_TMPLTDIR sets the path to the generated documentation for serving +BSK_API_TMPLTDIR=/src/blockstack/api/templates ``` diff --git a/api/deployment/client.ini b/api/deployment/client.ini index 0e5a36584..fb6adb10e 100644 --- a/api/deployment/client.ini +++ b/api/deployment/client.ini @@ -1,11 +1,11 @@ [blockstack-client] -protocol = https +protocol = http api_endpoint_host = 0.0.0.0 poll_interval = 300 api_endpoint_port = 6270 api_password = dummywalletpassword metadata = metadata -server = node.technofractal.com +server = blockstack-core email = api_endpoint_bind = 0.0.0.0 blockchain_writer = blockstack_utxo @@ -14,7 +14,7 @@ storage_drivers = disk,http,dht blockchain_reader = blockstack_utxo client_version = 0.17.0.16 storage_drivers_required_write = disk,dropbox -port = 6263 +port = 6264 anonymous_statistics = True [blockchain-reader] diff --git a/api/docker-compose.yaml b/api/docker-compose.yaml index 8cbc84d6f..aa112aa4e 100644 --- a/api/docker-compose.yaml +++ b/api/docker-compose.yaml @@ -9,7 +9,9 @@ services: restart: always blockstack-api: - image: 'quay.io/blockstack/blockstack-core:master' + build: + context: ../ + dockerfile: ../Dockerfile command: blockstack api start-foreground -y --debug --password dummywalletpassword volumes: - './data/blockstack-api:/root/.blockstack' @@ -38,6 +40,7 @@ services: volumes: - "./data/search-api:/var/blockstack-search" - "/etc/localtime:/etc/localtime:ro" + - "./deployment/client.ini:/root/.blockstack/client.ini" search-api: build: @@ -48,6 +51,7 @@ services: - PUBLIC_NODE=True - DEFAULT_HOST=0.0.0.0 - MONGODB_URI=mongodb://mongodb + - BSK_API_TMPLTDIR=/src/blockstack/api/templates - BASE_API_URL=http://blockstack-api:6270 - DEBUG=True networks: @@ -60,6 +64,18 @@ services: - blockstack-api volumes: - "./data/search-api:/var/blockstack-search" + + blockstack-core: + build: + context: ../ + dockerfile: Dockerfile + command: 'blockstack-core start --foreground --debug' + volumes: + - './blockstack-core/server/:/root/.blockstack-server/' + - './blockstack-core/api/:/root/.blockstack/' + restart: always + networks: + - api networks: api: null diff --git a/api/ops b/api/ops index f5e48d02b..6416a7589 100755 --- a/api/ops +++ b/api/ops @@ -2,9 +2,6 @@ ops () { - local python=/usr/bin/python - local initCore=blockstack-core-init - local storageBucket=https://blockstack.blob.core.windows.net/index local image=quay.io/blockstack/blockstack-core local tag=master @@ -26,12 +23,27 @@ ops () { cp search/fixtures/blockchain_data.json $idxData/blockchain_data.json cp search/fixtures/profile_data.slice.json $idxData/profile_data.json } + + init-core () { + local coreData=data/blockstack-core + echo "Initializing Blockstack Core node. This task runs in the background and may take up to 20 minutes..." + mkdir -p $coreData/server/ + cp $(pwd)/deployment/blockstack-server.ini $coreData/server/blockstack-server.ini + docker run -d --rm \ + -v $(pwd)/$coreData/server/:/root/.blockstack-server/ \ + -v $(pwd)/$coreData/api/:/root/.blockstack \ + --name blockstack-core-init \ + $image:$tag \ + blockstack-core --debug fast_sync http://fast-sync.blockstack.org/snapshot.bsk > /dev/null + } + commands () { cat <<-EOF ops commands: init-api -> Set up the dummy wallet for the core api init-indexer -> Set up the bootstrapping data for the indexer + init-core -> Set up blockstack-core instance for this API EOF } @@ -42,6 +54,9 @@ EOF init-indexer) init-indexer ;; + init-core) + init-core + ;; *) commands ;;