Skip to content
Ian Johnson edited this page Jul 14, 2020 · 17 revisions

Dependencies

NodeJS runs the server-side of the app. MongoDB and Redis are used for storing users and sessions for authentication.

Setting up databases

Make sure you initialize both Redis and MongoDB before running.

OS X

Method 1: Using Docker

The simplest way to get started in blockbuilder is to use docker. To begin, install the app through Homebrew.

brew cask install docker
# From Application launcher, open the Docker app after installation completes

Next, from within the blockbuilder directory, run the following command. Docker-compose will read from the docker-compose file to download and build the appropriate mongodb and redis images from Docker Hub registry. This may take a while, but it only needs to be done once. After downloading the images, docker will also launch the applications on the ports that blockbuilder expects.

# The -d flag runs the containers 
# in detached mode, so that you can 
# use the terminal for other things
docker-compose up -d 

That's it, you're done! When you're done with your databases, run the following command to shut down your Docker network from within the blockbuilder directory.

docker-compose down 

You can now proceed to the "Running Server" portion of this guide. If you're not using Docker, read the next section for an alternate way to run the databases.

Method 2: Using Homebrew Manually
brew install mongodb
brew install redis

More steps may be necessary to install MongoDB on Mac OS X

To start the mongo database service, open a new terminal tab and run:

mongod --config /usr/local/etc/mongod.conf

To start the redis server, open a new terminal window and run:

redis-server

You can follow this more detailed guide on Mac OS X.

Other platforms

  1. Refer to Redis Quick Start to set up a Redis instance.
  2. Refer to Install MongoDB to set up a MongoDB instance for your platform

Project Setup and Running Server

1. Initial Setup

git clone https://github.com/enjalot/blockbuilder.git
cd blockbuilder/
npm install

2. Building JS / CSS Files

Built files are not included in this repo. To build files, webpack is used.

To have a continually running watch script, use npm run buildWatch, which will leave a process running which will re-build the file. This command runs webpack to build the js & css bundles. This process watches for any changes to any client-side files and repacks them during development so there might not be any apparent progress in the terminal. It is customary to leave this running in its own tab during development.

npm run buildWatch

To build the files once, without watching for changes, run:

npm run build

3. Copy secrets

Blockbuilder expects something in the secrets.json file.

cp secrets.json-example secrets.json

4. Running the server

This will use node to launch the server:

node server.js

Leave the server running, and now you can access http://localhost:8889.

Then take any bl.ock and replace the bl.ocks.org part with localhost:8889 like
http://localhost:8889/syntagmatic/0d4f736796ab7b465020

GitHub authentication

If you'd like to enable GitHub authentication (for saving and forking as a logged in user) you will need to:

  1. Register a GitHub application
  1. Fill secrets.json with the client ID and secret key from GitHub