upgrade docker files to not attempt to install or use the old API daemon

This commit is contained in:
Jude Nelson
2018-05-04 17:43:34 -04:00
parent 890c48d56a
commit cd0bc1e89d
8 changed files with 139 additions and 110 deletions

View File

@@ -21,15 +21,12 @@ COPY . .
# Upgrade pip and install pyparsing
RUN pip install pyparsing uwsgi
# If you're doing this from a branch that is not in PyPI, uncomment the line below
# install Blockstack from source
RUN python ./setup.py build && python ./setup.py install
# install deps
# install ancillary deps
RUN pip install -r api/requirements.txt
# Install Blockstack from source
RUN pip install . --upgrade
# Create data dir
RUN mkdir /var/blockstack-search

View File

@@ -38,7 +38,6 @@ services:
- BSK_API_TMPLTDIR=/src/blockstack/api/templates
- DEFAULT_CACHE_TIMEOUT=1800
- MONGODB_URI=mongodb://mongodb
- BSK_API_TMPLTDIR=/src/blockstack/api/templates
- BASE_API_URL=http://blockstack-core:6270
- DEBUG=True
networks:
@@ -50,6 +49,18 @@ services:
- mongodb
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

139
api/ops
View File

@@ -1,52 +1,97 @@
#!/bin/bash
ops () {
local image=quay.io/blockstack/blockstack-core
local tag=master
init-indexer () {
local idxData=data/search-api
echo "Initializing Blockstack Indexer with dummy data..."
mkdir -p $idxData
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-indexer -> Set up the bootstrapping data for the indexer
init-core -> Set up blockstack-core instance for this API
EOF
}
case $1 in
init-indexer)
init-indexer
;;
init-core)
init-core
;;
*)
commands
;;
esac
set -e
# must be run from the api/ directory
exit_error() {
echo "$1" >&2
exit 1
}
ops $1 $2
test -d "deployment" || exit_error "Must be run from the api/ directory"
docker ps -a >/dev/null 2>&1 || exit_error "Could not connect to docker (is it running, and do you have permission?)"
init_indexer () {
# set up search indexer
# $1: the directory into which to store the search data (default: data/)
datadir="$1"
if [[ -z "$datadir" ]]; then
datadir="$(pwd)/data"
fi
local idxData="$datadir/search-api"
echo "Initializing Blockstack Indexer with dummy data..."
mkdir -p "$idxData"
cp search/fixtures/blockchain_data.json "$idxData/blockchain_data.json"
cp search/fixtures/profile_data.slice.json "$idxData/profile_data.json"
mkdir -p "$datadir/mongodb"
}
function init_core () {
# set up core node
# $1: the directory into which to store the Blockstack Core data (default: data/)
# $2: the tag of the Blockstack Core docker image to pull (default: master)
datadir="$1"
tag="$2"
image=quay.io/blockstack/blockstack-core
if [[ -z "$datadir" ]]; then
datadir="$(pwd)/data"
fi
if [[ -z "$tag" ]]; then
tag=master
else
# need to remove '/'
tag="$(echo "$tag" | sed -r 's@/@_@g')"
fi
local coreData="$datadir/blockstack-core"
echo "Initializing Blockstack Core node (tag=$tag) into $coreData. This task runs in the background and may take up to 20 minutes..."
mkdir -p "$coreData/server/"
cp "deployment/blockstack-server.ini" "$coreData/server/blockstack-server.ini"
docker run -d --rm \
-v "$coreData/server/:/root/.blockstack-server/" \
--name blockstack-core-init \
"$image:$tag" \
blockstack-core --debug fast_sync > /dev/null
docker logs -f blockstack-core-init
}
function commands() {
# usage
cat <<-EOF
ops commands:
init-indexer [data_dir] -> Set up the bootstrapping data for the indexer
init-core [data_dir [tag] -> Set up blockstack-core instance for this API
EOF
}
function init_all() {
# $1: data directory
# $2: blockstack-core tag
init_indexer "$1"
init_core "$1" "$2"
}
# entry point
case "$1" in
init-indexer)
init_indexer "$2"
;;
init-core)
init_core "$2" "$3"
;;
init)
init_all "$2" "$3"
;;
*)
commands
;;
esac

View File

@@ -9,8 +9,13 @@ RUN apk add libffi-dev openssl-dev build-base linux-headers musl musl-dev musl-u
# Copy all files from the repo into the container
COPY . .
# # Upgrade pip and install pyparsing
# Upgrade pip and install pyparsing
RUN pip install --upgrade pip && pip install pyparsing uwsgi
# install Blockstack from source
RUN python ./setup.py build && python ./setup.py install
# install ancillary requirements
RUN pip install -r api/requirements.txt
# Install Blockstack from source
@@ -24,7 +29,6 @@ WORKDIR /src/blockstack/api
# Add crontab file in the cron directory
COPY api/deployment/crontab /var/spool/cron/crontabs/root
# COPY api/deployment/client.ini /root/.blockstack/client.ini
# Give execution rights on the cron job
RUN chmod 0600 /var/spool/cron/crontabs/root

View File

@@ -1,14 +1,31 @@
[bitcoind]
p2p_port = 8333
passwd = blockstacksystem
regtest = False
spv_path = /root/.virtualchain-spv-headers.dat
server = bitcoin.blockstack.com
passwd = blockstacksystem
p2p_port = 8333
user = blockstack
timeout = 300
port = 8332
use_https = False
[blockstack]
email = foo@bar.com
server_version = 0.18.0.0
subdomaindb_path = /root/.blockstack-server/subdomains.db
rpc_port = 6264
backup_max_age = 288
enabled = True
atlasdb_path = /root/.blockstack-server/atlas.db
atlas_blacklist =
atlas = True
backup_frequency = 144
zonefiles = /root/.blockstack-server/zonefiles
atlas_port = 6264
announcers = judecn.id,muneeb.id,shea256.id
server_version = 0.19.0.0
atlas_seeds = node.blockstack.org:6264
[blockstack-api]
indexer_url = http://blockstack-core:6264
api_port = 6270
enabled = True
api_host = 0.0.0.0

View File

@@ -1,4 +1,4 @@
# This docker-compose file is for spinning up a blockstack-core node and api
# This docker-compose file is for spinning up a blockstack-core node
version: '2'
services:
blockstack-core:
@@ -6,25 +6,11 @@ services:
command: 'blockstack-core start --foreground --debug'
volumes:
- './data/core/server/:/root/.blockstack-server/'
- './data/core/api/:/root/.blockstack/'
restart: always
ports:
- "6264:6264"
networks:
- "api"
blockstack-api:
image: 'quay.io/blockstack/blockstack-core:master'
command: blockstack api start-foreground -y --debug --password dummywalletpassword
ports:
- "6270:6270"
volumes:
- './data/api:/root/.blockstack'
- './data/api/tmp:/tmp'
environment:
- BLOCKSTACK_CLIENT_INTERACTIVE_YES=0
restart: always
networks:
- "api"
networks:
api: null

View File

@@ -10,24 +10,11 @@ init-core () {
cp $(pwd)/blockstack-server.ini $(pwd)/$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
}
init-api () {
local apiData=data/api
echo "Initializing Blockstack Core API server with dummy wallet..."
mkdir -p $(pwd)/$apiData
docker run -it --rm \
-v $(pwd)/$apiData:/root/.blockstack \
$image:$tag \
blockstack setup -y --password dummywalletpassword
sudo cp client.ini $apiData/client.ini
}
test-core () {
if [ -z "$1" ]; then
echo "Need to input host to test against..."
@@ -42,26 +29,11 @@ test-core () {
fi
}
test-api () {
if [ -z "$1" ]; then
echo "Need to input host to test against..."
exit 1
fi
if [ -z "$2" ]; then
echo "Need to input port to test against..."
exit 1
else
curl -L $1:$2/v1/ping
fi
}
commands () {
cat <<-EOF
ops commands:
init-core -> Fast sync core node directories to $(pwd)/data/core
init-api -> Create dummywallet and config for blockstack api in $(pwd)/data/api
test-core {host} {port} -> Call the getinfo RPC method against node running at {host}:{port}
test-api {host} {port} -> Call the /v1/ping route against api running at {host}:{port}
EOF
}
@@ -69,9 +41,6 @@ case $1 in
init-core)
init-core
;;
init-api)
init-api
;;
test-core)
test-core $2 $3
;;

View File

@@ -1,6 +1,6 @@
#!/bin/sh
BLOCKSTACK_VERSION="0.18.0"
BLOCKSTACK_VERSION="0.19.0"
VENV_DIR="$(pwd)/blockstack-$BLOCKSTACK_VERSION"
LOGPATH="/tmp/blockstack_${BLOCKSTACK_VERSION}_get_started.log"
@@ -117,9 +117,9 @@ source "$VENV_DIR"/bin/activate || exit_with_error "Failed to activate virtualen
pip install blockstack 2>&1 | tee -a "$LOGPATH" || exit_with_error "Failed to install blockstack. Logfile in $LOGPATH"
# test blockstack
test -x "$(which blockstack)" || exit_with_error "Failed to find installed blockstack program. Logfile in $LOGPATH"
test -x "$(which blockstack-core)" || exit_with_error "Failed to find installed blockstack program. Logfile in $LOGPATH"
blockstack --version 2>/dev/null | grep "$BLOCKSTACK_VERSION" >/dev/null || exit_with_error "Could not find blockstack $BLOCKSTACK_VERSION. Logfile in $LOGPATH."
blockstack-core --version 2>/dev/null | grep "$BLOCKSTACK_VERSION" >/dev/null || exit_with_error "Could not find blockstack $BLOCKSTACK_VERSION. Logfile in $LOGPATH."
logecho "Blockstack $BLOCKSTACK_VERSION installed to $VENV_DIR."
echo ""