Skip to content

Commit

Permalink
Update condenser README (steemit#1631)
Browse files Browse the repository at this point in the history
* Update condenser README

* Some minor fixes
  • Loading branch information
jredbeard authored and Valentine Zavgorodnev committed Aug 6, 2017
1 parent 84edea5 commit 799773a
Showing 1 changed file with 91 additions and 85 deletions.
176 changes: 91 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,121 @@

# Steemit.com
# Condenser


Steemit.com is the react.js web interface to the world's first and best blockchain-based social media platform. It uses [STEEM](https://github.com/steemit/steem), a blockchain powered by Graphene 2.0 technology to store JSON-based content for a plethora of web applications.
Condenser is the react.js web interface to the world's first and best blockchain-based social media platform, steemit.com. It uses [STEEM](https://github.com/steemit/steem), a blockchain powered by Graphene 2.0 technology to store JSON-based content for a plethora of web applications.

## Why would I want to use Steemit.com?
## Why would I want to use Condenser (steemit.com front-end)?
* Learning how to build blockchain-based web applications using STEEM as a content storage mechanism in react.js
* Reviewing the inner workings of the steemit.com social media platform
* Assisting with software development for steemit.com

## Installation

#### Docker

We highly recommend using docker to run condenser. This is how we run the live steemit.com site and it is the most supported (and fastest) method of both building and running condenser. We will always have the latest version of condenser (master branch) available on dockerhub. Configuration settings can be set using environment variables (see configuration section below for more information). If you need to install docker, you can get it at https://get.docker.com

To bring up a running container it's as simple as this:

```bash
docker run -it -p 8080:8080 steemit/condenser
```

Environment variables can be added like this:

```bash
docker run -it --env SDC_DATABASE_URL="mysql://user:pass@hostname/databasename" -p 8080:8080 steemit/condenser
```

If you would like to modify, build, and run condenser using docker, it's as simple as pulling in the github repo and issuing one command to build it, like this:

```bash
git clone https://github.com/steemit/condenser
cd condenser
docker build -t="myname/condenser:mybranch" .
docker run -it -p 8080:8080 myname/condenser:mybranch
```

## Building from source without docker (the 'traditional' way):

#### Clone the repository and make a tmp folder
```bash
git clone https://github.com/steemit/condenser
cd condenser
mkdir tmp
```

#### Verify NVM is installed
#### Install dependencies

Install at least Node v7.5 if you don't already have it. We recommend using `nvm` to do this as it's both the simplest way to install and manage installed version(s) of node. If you need `nvm`, you can get it at [https://github.com/creationix/nvm](https://github.com/creationix/nvm).

Using nvm, you would install like this:
```bash
command -v nvm # verify
nvm install v7.5
```

It should output "nvm". If it does not, install nvm.
We use the yarn package manager instead of the default `npm`. There are multiple reasons for this, one being that we have `steem-js` built from source pulling the github repo as part of the build process and yarn supports this. This way the library that handles keys can be loaded by commit hash instead of a version name and cryptographically verified to be exactly what we expect it to be. Yarn can be installed with `npm`, but afterwards you will not need to use `npm` further.

#### Install dependencies
```bash
npm install -g yarn
yarn global add babel-cli
yarn install
yarn run build
```
To run condenser in production mode, run:

```bash
# Install at least Node v6.3 if you don't already have it ([NVM](https://github.com/creationix/nvm) recommended)
nvm install v6
yarn run production
```

When launching condenser in production mode it will automatically use 1 process per available core. You will be able to access the front-end at http://localhost:8080 by default.

npm install
npm install -g babel-cli
To run condenser in development mode, run:

```bash
yarn run start
```

#### Create config file
It will take quite a bit longer to start in this mode (~60s) as it needs to build and start the webpack-dev-server.

By default you will be connected to steemit.com's public steem node at `wss://steemd.steeemit.com`. This is actually on the real blockchain and you would use your regular account name and credentials to login - there is not an official separate testnet at this time. If you intend to run a full-fleged site relying on your own, we recommend looking into running a copy of `steemd` locally instead [https://github.com/steemit/steem](https://github.com/steemit/steem).

#### Configuration

The intention is to configure condenser using environment variables. You can see the names of all of the available configuration environment variables in `config/custom-environment-variables.json`. Default values are stored in `config/defaults.json`.

Environment variables using an example like this:

```bash
cd config
cp default.json steem-dev.json
export SDC_CLIENT_STEEMD_URL="wss://steemd.steemit.com"
export SDC_SERVER_STEEMD_URL="wss://steemd.steemit.com"
```
Keep in mind environment variables only exist in your active session, so if you wish to save them for later use you can put them all in a file and `source` them in.

If you'd like to statically configure condenser without variables you can edit the settings directly in `config/defaults.json`.

Generate a new crypto_key and save under server_session_secret in ./steem-dev.json.
If you're intending to run condenser in a production environment one configuration option that you will definetely want to edit is `server_session_secret` which can be set by the environment variable `SDC_SESSION_SECRETKEY`. To generate a new value for this setting, you can do this:

```bash
node
> crypto.randomBytes(32).toString('base64')
> .exit
```

(note: it's steem.json in production)

#### Install mysql server

If you've followed the instructions up until this point you will already have a running condenser installation which is entirely acceptable for development purposes. It is *not required to run a SQL server for development*. If you're running a full-fleged site however, you will want to set one up.

Once set up, you can set the mysql server configuration option for condenser using the environment variable `SDC_DATABASE_URL`, or alterntivaely by editting it in `config/defaults.json`. You will use the format `mysql://user:pass@hostname/databasename`.

Example:

```bash
export SDC_DATABASE_URL="mysql://root:[email protected]/steemit_dev"
```

Here are instructions for setting up a mysql server and running the necessary migrations by operating system:

OS X:

```bash
Expand Down Expand Up @@ -91,57 +151,29 @@ mysql -u root
> quit
```

Create a password for the root mysql account:

mysql_secure_installation

(answer all it's questions as No, with Enter key, except to add a password, use "password")
#### Database migrations

This is a required step in order for the database to be 'ready' for condenser's use.

Install `sequelize-cli` globally:
Install these modules globally:

```bash
npm install -g sequelize sequelize-cli pm2 mysql
yarn global add sequelize sequelize-cli pm2 mysql mysql2
```

###### Edit the following files and make these changes:

Edit `~/condenser/db/config/config.json` and save the mysql password under "password".

Edit `~/condenser/config/default.json` and enter this string for database:

"database_url": "mysql://root:password@127.0.0.1/steemit_dev"

Edit `~/condenser/.babelrc if it doesn't look like the following:

{

"presets": ["es2015", "stage-0", "react"],

"plugins": ["transform-runtime", "transform-decorators-legacy"]

}


###### IMPORTANT: Add an env var for the database as well in your shell:

touch ~/.bash_profile
edit this file, add 1 line:

`export SDC_DATABASE_URL="mysql://root:password@localhost/steemit_dev"`

source ~/.bash_profile

globally install sql2:

npm i -g mysql2

Edit the file `src/db/config/config.json` using your favorite command line text editor being sure that the username, password, host, and database name are set correctly and match your newly configured mysql setup.

Run `sequelize db:migrate` in `src/db` directory, like this:

Run `sequelize db:migrate` in `db/` directory.
```bash
cd src/db
sequelize db:migrate
```

#### Install Tarantool - Production Only

Tarantool similarly to mysql is not required for development but if you're running a full-fleged site with condenser you will want to run one.

OS X:

```bash
Expand All @@ -160,15 +192,7 @@ Test the interactive console:
user@example:~$ tarantool
```

### Development

```bash
npm start
```

It will take a few moments to launch. Once it says "Application started on port ####", you now have your development front end running at localhost:####, connected to the main public steem blockchain. You don't need to run ```steemd``` locally, by default you will connect to ```ws://node.steem.ws```. Use your regular account name and credentials to login -- there is no separate dev login.

#### Style Guides
#### Style Guides For Submitting Pull Requests

##### File naming and location

Expand All @@ -182,7 +206,7 @@ We are using _Airbnb JavaScript Style Guide_ with some modifications (see .eslin
Please run _eslint_ in the working directory before committing your changes and make sure you didn't introduce any new styling issues.

##### CSS & SCSS
If component requires a css rule, please use its uppercase name for the class, e.g. "Header" class for the header's root div.
If a component requires a css rule, please use its uppercase name for the class, e.g. "Header" class for the header's root div.
We adhere to BEM methodology with exception for Foundation classes, here is an example for the Header component:

```html
Expand All @@ -196,24 +220,6 @@ We adhere to BEM methodology with exception for Foundation classes, here is an e
</ul>
```

### Production

If you want to test it locally in production mode, just run the following commands:

```bash
npm run build
npm run prod
```

or via pm2:

```bash
npm run build
npm -i -g pm2 # one time
pm2 start config/process.json
```


## Issues

To report a non-critical issue, please file an issue on this GitHub project.
Expand Down

0 comments on commit 799773a

Please sign in to comment.