Add browser

This commit is contained in:
Jack Zampolin
2017-08-25 09:50:28 -07:00
parent 768238d016
commit bc31ef185e
2 changed files with 79 additions and 40 deletions

View File

@@ -172,33 +172,24 @@ $ blockstack-core/images/scripts/debian-release-candidate.sh
## Running in Docker
To run the Blockstack API in a docker container requires a couple of steps. Run the following commands from the root of the repo:
> _*WARNING*_: This install path is currently for developers only.
To run the Blockstack API and the Blockstack Browser in docker containers is easy! There is also a provided CLI: `bsdocker.sh`. The CLI will pull down the images from our [Quay image repository](https://quay.io/organization/blockstack). If you want to build the API image locally run `./bsdocker build`. The browser image and build script are in the [`blockstack-browser`](https://github.com/blockstack/blockstack-browser) repository.
```bash
# Build image
$ docker build -t myrepo/blockstack:latest .
# First run the setup command. This will create a `$HOME/.blockstack` directory to store your Blockstack Core API config and wallet
$ ./bsdocker setup <password>
# Setup wallet and client config using the ./data/blockstack-api directory for your client.
$ docker run -it -v $(pwd)/data/blockstack-api:/root/.blockstack myrepo/blockstack:latest blockstack setup -y --password PASSWORD
# Next you can start the Blockstack Core API
$ ./bsdocker start <password>
# Update [blockstack-client]api_endpoint_bind = 0.0.0.0
$ nano $(pwd)/data/client.ini
# Finally start the Blockstack Browser
$ ./bsdocker browser
### MAC
# Now open your browser to `localhost:8888` to view the blockstack browser!
# Start API on top of newly created wallet and configuration // run in terminal window
$ docker run -it -v $(pwd)/data/blockstack-api:/root/.blockstack -p 6270:6270 myrepo/blockstack:latest blockstack api start-foreground --password PASSWORD --debug
# Start API on top of newly created wallet and configuration // run detached
$ docker run -d -v $(pwd)/data/blockstack-api:/root/.blockstack -p 6270:6270 myrepo/blockstack:latest blockstack api start-foreground --password PASSWORD --debug
### LINUX
# Start API on top of newly created wallet and configuration // run in terminal window
$ docker run -it -v $(pwd)/data/blockstack-api:/root/.blockstack -v /tmp/:/tmp/ -p 6270:6270 myrepo/blockstack:latest blockstack api start-foreground --password PASSWORD --debug
# Start API on top of newly created wallet and configuration // run detached
$ docker run -d -v $(pwd)/data/blockstack-api:/root/.blockstack -v /tmp/:/tmp/ -p 6270:6270 myrepo/blockstack:latest blockstack api start-foreground --password PASSWORD --debug
# When you are done you can clean up your environment by running
$ ./bsdocker stop
```
## Community

View File

@@ -2,17 +2,20 @@
# This script provides a simple interface for folks to use the docker install
image=quay.io/blockstack/blockstack-core:latest
coreimage=quay.io/blockstack/blockstack-core:latest
browserimage=quay.io/blockstack/blockstack-browser:latest
# Local Blockstack directory
homedir=$HOME/.blockstack
# Blockstack Directory inside container
containerdir=/root/.blockstack
# Name of Blockstack API container
containername=blockstack-api
corecontainer=blockstack-api
# Name of Blockstack Browser container
browsercontainer=blockstack-browser
build () {
echo "Building blockstack docker image. This might take a minute..."
docker build -t $image .
docker build -t $coreimage .
}
setup () {
@@ -20,11 +23,11 @@ setup () {
echo "Need to input new wallet password when running setup: ./bsdocker setup mypass"
exit 1
fi
docker run -it -v $homedir:$containerdir $image blockstack setup -y --password $1
docker run -it -v $homedir:$containerdir $coreimage blockstack setup -y --password $1
# Use init containers to set the API bind to 0.0.0.0
docker run -it -v $homedir:$containerdir $image sed -i 's/api_endpoint_bind = localhost/api_endpoint_bind = 0.0.0.0/' $containerdir/client.ini
docker run -it -v $homedir:$containerdir $image sed -i 's/api_endpoint_host = localhost/api_endpoint_host = 0.0.0.0/' $containerdir/client.ini
docker run -it -v $homedir:$containerdir $coreimage sed -i 's/api_endpoint_bind = localhost/api_endpoint_bind = 0.0.0.0/' $containerdir/client.ini
docker run -it -v $homedir:$containerdir $coreimage sed -i 's/api_endpoint_host = localhost/api_endpoint_host = 0.0.0.0/' $containerdir/client.ini
}
start () {
@@ -35,45 +38,87 @@ start () {
fi
# Check for the blockstack-api container is running or stopped.
if [ "$(docker ps -q -f name=blockstack-api)" ]; then
if [ "$(docker ps -q -f name=$corecontainer)" ]; then
echo "container is already running"
exit 1
elif [ ! "$(docker ps -q -f name=blockstack-api)" ]; then
if [ "$(docker ps -aq -f status=exited -f name=blockstack-api)" ]; then
elif [ ! "$(docker ps -q -f name=$corecontainer)" ]; then
if [ "$(docker ps -aq -f status=exited -f name=$corecontainer)" ]; then
# cleanup old container if its still around
echo "removing old container..."
docker rm $containername
docker rm $corecontainer
fi
# If there is no existing blockstack-api container, run one
# If there is no existing $corecontainer container, run one
# Linux needs to mount /tmp:/tmp
if [[ $(uname) == 'Linux' ]]; then
docker run -d --name $containername -v $homedir:$containerdir -v /tmp/:/tmp/ -p 6270:6270 $image blockstack api start-foreground --password $1 --api_password $1 --debug
docker run -d --name $corecontainer -v $homedir:$containerdir -p 6270:6270 $coreimage blockstack api start-foreground --password $1 --api_password $1
elif [[ $(uname) == 'Darwin' ]]; then
docker run -d --name $containername -v $homedir:$containerdir -p 6270:6270 $image blockstack api start-foreground --password $1 --api_password $1 --debug
docker run -d --name $corecontainer -v $homedir:$containerdir -p 6270:6270 $coreimage blockstack api start-foreground --password $1 --api_password $1
elif [[ $(uname) == 'Windows' ]]; then
echo "Don't know if this works!!!"
docker run -d --name $corecontainer -v $homedir:$containerdir -p 6270:6270 $coreimage blockstack api start-foreground --password $1 --api_password $1
fi
fi
}
browser () {
# Check for the blockstack-api container is running or stopped.
if [ "$(docker ps -q -f name=$browsercontainer)" ]; then
echo "container is already running"
exit 1
elif [ ! "$(docker ps -q -f name=$browsercontainer)" ]; then
if [ "$(docker ps -aq -f status=exited -f name=$browsercontainer)" ]; then
# cleanup old container if its still around
echo "removing old container..."
docker rm $browsercontainer
fi
# If there is no existing blockstack-api container, run one
# Linux needs to mount /tmp:/tmp
if [[ $(uname) == 'Linux' ]]; then
docker run -d --name $browsercontainer-static -p 8888:8888 $browserimage blockstack-browser
docker run -d --name $browsercontainer-cors -p 1337:1337 $browserimage blockstack-cors-proxy
elif [[ $(uname) == 'Darwin' ]]; then
docker run -d --name $browsercontainer-static -p 8888:8888 $browserimage blockstack-browser
docker run -d --name $browsercontainer-cors -p 1337:1337 $browserimage blockstack-cors-proxy
elif [[ $(uname) == 'Windows' ]]; then
echo "Don't know if this works!!!"
docker run -d --name $browsercontainer-static -p 8888:8888 $browserimage blockstack-browser
docker run -d --name $browsercontainer-cors -p 1337:1337 $browserimage blockstack-cors-proxy
fi
fi
}
stop () {
echo "stopping the running blockstack-api container"
docker stop $containername && docker rm $containername
bc=$(docker ps -a -f name=$browsercontainer -q)
cc=$(docker ps -f name=$corecontainer -q)
if [ ! -z "$cc" ]; then
echo "stopping the running blockstack-api container"
docker stop $cc
docker rm $cc
fi
if [ ! -z "$bc" ]; then
echo "stopping the running blockstack-browser containers"
docker stop $bc
docker rm $bc
fi
}
enter () {
echo "entering docker container"
docker exec -it $containername /bin/bash
docker exec -it $corecontainer /bin/bash
}
logs () {
echo "streaming logs for blockstack-api container"
docker logs $containername -f
docker logs $corecontainer -f
}
push () {
echo "pushing build container up to quay.io..."
docker push $image
docker push $coreimage
}
commands () {
@@ -83,8 +128,8 @@ bsdocker commands:
stop -> stop the blockstack api server
setup -> run the setup for blockstack and generate a wallet
logs -> access the logs from the blockstack api server
build -> build the docker image for running the api server
enter -> exec into the running docker container
browser -> run the two browser containers as well
EOF
}
@@ -104,6 +149,9 @@ case $1 in
enter)
enter
;;
browser)
browser
;;
start)
start $2
;;