NOTE: While open-source, some features of this block explorer are not easily compatible with running your own version locally, and this is no longer recommended (except for expert users).
--
- Follow the instructions here to install Homebrew and then (re)install python.
- If for some reason the step above does not install pip and virtualenv, follow the instructions here to get pip and then install virtualenv using pip install virtualenv.
- Install the foreman gem for accessing environmental variables:
$ gem install foreman
- Optional (for webhooks): install ngrok with
brew install ngrok
(thanks Homebrew!) - Optional (advanced features): Install the latest stable version of postgres 9. (http://postgresapp.com/)[Postgresapp for Mac] is quite easy to install.
$ sudo apt-get update && sudo apt-get upgrade -y
$ sudo apt-get install postgresql libpq-dev
$ apt install software-properties-common
$ add-apt-repository ppa:deadsnakes/ppa
$ apt install python3.7
$ echo "alias python3=python3.7" >> .bashrc
$ echo "alias python=python3.7" >> .bashrc
$ source .bashrc
$ git clone https://github.com/defunctec/apiexplorer.git
$ cd apiexplorer
$ apt install virtualenv
$ virtualenv -p python3 venv
$ source venv/bin/activate
$ apt-get install libncurses5-dev
$ apt-get install python3-pip python3.7-dev
$ pip3 install -r requirements.txt
$ sudo -u postgres psql
$ CREATE DATABASE explorer_local;
$ CTRL+z (To exit)
- Run
$ git remote -v
, it should look like this:
origin git@github.com:blockcypher/explorer.git (fetch)
origin git@github.com:blockcypher/explorer.git (push)
- Create a
.env
file in the project root directory with the following:
DEBUG=True
TEMPLATE_DEBUG=True
DJ_DEFAULT_URL=postgres://postgres:YOURLOCALPASSWORDHERE@localhost:5432/explorer_local
SECRET_KEY=RANDOMLY_GENERATED_50CHAR_STRING
SITE_DOMAIN=pick_this_yourself.ngrok.com
BLOCKCYPHER_API_KEY=PUT_YOURS_HERE
(these are for your local machine, production is a little different as settings.py
is smartly designed to default to production settings)
- Create DB tables from code (replace
foreman
withheroku
for running on production, which should basically never happen again):
-
$ apt install ruby-foreman
-
You may run into errors with the next commands, reinstall psycopg2 if you fail.
-
$ pip uninstall psycopg2
-
$ pip install psycopg2
$ foreman run python3 manage.py migrate
$ foreman run python3 manage.py runserver
Now visit: http://YOURSERVERIP:8000/
To receive webhooks locally, you need to also run ngrok
in the terminal (use the same SITE_DOMAIN
from your .env
file above):
$ ngrok -subdomain=pick_this_yourself 8000
Now visit http://pick_this_yourself.ngrok.com to confirm it's working (you could even do this on your phone)
- Create a superuser admin for yourself, by entering the following into
$ foreman run python3 manage.py shell
:
from users.models import AuthUser
AuthUser.objects.create_superuser(email='YOURCHOICE', password='PASSWORDGOESHERE')
Now visit http://YOURSERVERIP:8000/admin
First, pull the latest version of the code from github:
$ git pull origin master
Make a new branch:
$ git checkout -b my_branch
Make some trivial change and commit it:
$ git commit -am 'my changes'
Push it up to github:
$ git push origin my_branch
You can submit your pull request here: https://github.com/blockcypher/explorer
Congrats, you're all setup!
You're on your own for that.
Compare your local version of site to what's on github:
$ git log origin/master..HEAD --oneline