changes to readme, and setup docs #721

Merged
jessopb merged 1 commit from readme into master 2018-11-12 15:20:46 +01:00
5 changed files with 348 additions and 18 deletions

109
README.md
View file

@ -1,21 +1,97 @@
# Spee.ch
Spee.ch is a web app that reads and publishes images and videos to and from the [LBRY](https://lbry.io/) blockchain. You are encouraged to contribute to the shared code base, or fork it and make it your own.
Spee.ch is a web app that reads and publishes images and videos to and from the [LBRY](https://lbry.io/) blockchain. We encourage you to contribute to the shared code base, or fork it and make it your own.
You can create your own custom version of spee.ch by installing this code base and then creating your own custom components and styles to override the defaults. (More details/guide on how to do that coming soon.)
## Quickstart
## Technology Overview
Spee.ch is a react web app that depends on MySQL for local content, and on two other lbry technologies:
* [chainquery](https://github.com/lbryio/chainquery) - a normalized database of the blockchain data. We've provided credentials to use a public chainquery service. You can also install it on your own server to avoid being affected by the commons.
* [lbrynet](https://github.com/lbryio/lbry) - a daemon that handles your wallet and transactions.
### Ubuntu
[Ubuntu VPS Setup](./docs/ubuntu16vpspersonal.md)
## Installation
_Note: This is our new setup. For our old setup see the [fullstart guide](./fullstart.md)._
### Ubuntu Step by Step
[Ubuntu Install Guide](./docs/ubuntuinstall.md)
#### System Dependencies:
* [node](https://nodejs.org)
### Quickstart Overview
#### Get some information ready:
* mysqlusername
* mysqlpassword
* domainname or 'http://localhost'
* speechport = 3000
#### Install and Set Up System Dependencies:
* [NodeJS](https://nodejs.org)
* [MySQL](https://dev.mysql.com/doc/refman/8.0/en/installing.html)
* [`lbry`](https://github.com/lbryio/lbry) daemon
* note: retrieve an address from the daemon and send your wallet a few credits (or join us in the [#speech discord channel](https://discord.gg/YjYbwhS) and we will send you a few)
* localhost port 3306
* mysqlusername or root
* mysqlpassword
* You may need
```
mysql> `ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yourpassword';`
```
* [lbrynet](https://github.com/lbryio/lbry) daemon
* run this as a service exposing ports 3333 and 4444
* _note_: once the daemon is running, issue commands in another terminal session (tmux) to retrieve an address for your wallet to recieve 5+ LBC credits (or join us in the [#speech discord channel](https://discord.gg/YjYbwhS) and we will send you a few)
* `./lbrynet commands` gets a list of commands
* `./lbrynet account_balance` gets your balance (initially 0.0)
* `./lbrynet address_list` gets addresses you can use to recieve LBC
* [FFmpeg](https://www.ffmpeg.org/download.html)
* [Spee.ch] (below)
* [pm2] (optional) process manager such as pm2 to run speech server.js
* [http proxy server] caddy, nginx, traefik, etc to forward 443 to speech port 3000
#### Clone this repo
* release version for stable production
```
$ git clone -b release https://github.com/lbryio/spee.ch.git
```
* master version for development
```
$ git clone https://github.com/lbryio/spee.ch.git
```
* your own fork for customization
#### Change directory into your project
```
$ cd spee.ch
```
#### Install node dependencies
```
$ npm install
```
#### Create the config files using the built-in CLI
_note: make sure lbrynet is running in the background before proceeding_
```
$ npm run configure
```
* _note: At the moment, you will have to copy chainqueryConfig.json from:_
```
~/spee.ch/docs/setup/conf/speech/chainqueryConfig.json
```
_to:_
```
~/spee.ch/site/config/chainqueryConfig.json
```
* _note: The domain name in this part must be prefixed with http:// or https://_
#### Build & start the app
_note: make sure lbrynet is running in the background before proceeding_
```
$ npm run start
```
#### View in browser
* Visit [http://localhost:3000](http://localhost:3000) in your browser
#### Customize your app
@ -23,12 +99,11 @@ Check out the [customization guide](https://github.com/lbryio/spee.ch/blob/readm
#### (optional) add custom components and update the styles
* Create custom components by creating React components in `src/views/` (further instructions coming soon)
* Update the CSS by changing the files in `public/assets/css/` (further instructions and refactor coming soon)
* Create custom components by creating React components in `site/custom/src/` (further instructions coming soon)
* Update the CSS by changing the files in `site/custom/scss` (further instructions and refactor coming soon)
#### (optional) Syncing the full blockchain
* Start the `spee.ch-sync` tool available at [billbitt/spee.ch-sync](https://github.com/billbitt/spee.ch-sync)
* This is not necessary, but highly recommended. It will decode the blocks of the `LBRY` blockchain and add the claims information to your database's tables
#### (optional) install your own chainquery
Instructions are coming at [lbry-docker] to install your own chainquery instance using docker-compose. This will require 50GB of preferably SSD space and at least 10 minutes to download, possibly much longer.
## API
#### /api/claim/publish
@ -112,7 +187,7 @@ Spee.ch also runs a sync tool, which decodes blocks from the `LBRY` blockchain a
### Architecture
* `cli/` contains the code for the CLI tool. Running the tool will create `.json` config files and place them in the `config/` folder
* `cli/` contains the code for the CLI tool. Running the tool will create `.json` config files and place them in the `site/config/` folder
* `configure.js` is the entry point for the CLI tool
* `cli/defaults/` holds default config files
* `cli/questions/` holds the questions that the CLI tool asks to build the config files
@ -128,9 +203,9 @@ Spee.ch also runs a sync tool, which decodes blocks from the `LBRY` blockchain a
* `client/scss/` contains the CSS for the project
*
* `config/custom` is a folder which can be used to override the default components in `client/`
* `site/custom` is a folder which can be used to override the default components in `client/`
* The folder structure mimics that of the `client/` folder
* to customize spee.ch, place your own components and scss in the `config/custom/src/` and `config/custom/scss` folders.
* to customize spee.ch, place your own components and scss in the `site/custom/src/` and `site/custom/scss` folders.
* `server/` contains all of the server code
* `index.js` is the entry point for the server. It creates the [express app](https://expressjs.com/), requires the routes, syncs the database, and starts the server listening on the `PORT` designated in the config files.

View file

@ -1,6 +1,6 @@
# Configure your own spee.ch
_note: this guide assumes you have done the []quickstart](https://github.com/lbryio/spee.ch/blob/readme-update/README.md) or [fullstart](https://github.com/lbryio/spee.ch/blob/readme-update/fullstart.md) guide and have a working spee.ch server_
_note: this guide assumes you have done the [quickstart](https://github.com/lbryio/spee.ch/blob/readme-update/README.md) or [fullstart](https://github.com/lbryio/spee.ch/blob/readme-update/fullstart.md) guide and have a working spee.ch server_
## Custom Components
The components used by spee.ch are taken from the `client/` folder, but you can override those components by defining your own in the `site/custom/` folder.

View file

@ -0,0 +1,9 @@
[Service]
ExecStart=/usr/bin/node /opt/app/app.js
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=node-app-1
User=your_app_user_name
Group=your_app_user_name
Environment=NODE_ENV=production PORT=3000

246
docs/ubuntuinstall.md Normal file
View file

@ -0,0 +1,246 @@
# Create Your Own Spee.ch on Ubuntu 16.x 18.x VPS
# Overview
## Prerequisites
* Ability to use SSH (putty + public key for windows users)
* Ubuntu 16.04 or 18.04 VPS with root access
* Your login info ready
* Domain name with @ and www pointed at your VPS IP
* alternatively, specify http://localhost
* Ability to send 5+ LBRY credits to an address
* Noncommercial use
* _(configuration examples for nginx and certbot are included as an alternative)_
## You'll be installing:
* MySQL DB
* Default Port 3306
* NodeJS v8+
* Https proxy server
* Caddy for personal use
* Exposed ports: 22, 80, 443, 3333, 4444
* Reverse proxies 443 to App on 3000
* Spee.ch started on port 3000
* Lbrynet DAEMON started on ports 3333 and 4444
# 1. Update OS and install packages
## OS
### Secure your server by creating a non-root sudoer.
As root# _create user and add to sudo group_
```
adduser username
usermod -aG sudo username
su - username
```
As username: _paste public key in authorized_keys_
```
`cd`
`mkdir .ssh`
`nano ~/.ssh/authorized_keys`
```
### Prep
Log in as username@domainname or username@ip_address
`sudo apt-get update -y`
`ulimit -n 8192`
`wget -qO- https://deb.nodesource.com/setup_8.x | sudo -E bash -`
## Git, Curl, Tmux, Unzip, ffmpeg, Node
`sudo apt-get install git curl tmux unzip ffmpeg nodejs -y`
## Clone speech either from your own fork, or from the lbryio/spee.ch repo.
### For Developers or those with their own forked repo
`git clone -b master https://github.com/lbryio/spee.ch`
SSH:
`git clone git@github.com:{{youraccount}}/spee.ch`
HTTPS:
`git clone https://github.com/{{youraccount}}/spee.ch.git`
### For Publishers and Content creators
`git clone -b release https://github.com/lbryio/spee.ch`
### Prepare the scripts
`chmod 750 -R ~/spee.ch/docs/setup`
# 2 Secure the UFW firewall
## UFW
`sudo ~/spee.ch/docs/setup/scripts/firewall.sh`
# 3 Install Caddy to handle https and reverse proxy
## Get Caddy
`curl https://getcaddy.com | sudo bash -s personal`
## Set up Caddy reverse proxy and ssl
`sudo mkdir -p /opt/caddy/logs/`
`sudo mkdir -p /opt/caddy/store/`
`cp ~/spee.ch/docs/setup/conf/caddy/Caddyfile.template ~/spee.ch/docs/setup/conf/caddy/Caddyfile`
`nano ~/spee.ch/docs/setup/conf/caddy/Caddyfile`
( Change {{EXAMPLE.COM}} to YOURDOMAIN.COM )
`sudo cp ~/spee.ch/docs/setup/conf/caddy/Caddyfile /opt/caddy/`
## Set up Caddy to run as systemd service
`sudo cp ~/spee.ch/docs/setup/conf/caddy/caddy.service /etc/systemd/system/caddy.service`
`sudo chmod 644 /etc/systemd/system/caddy.service`
`sudo chown -R www-data:www-data /opt/caddy/`
`sudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/caddy`
`sudo systemctl daemon-reload`
`sudo systemctl start caddy`
`sudo systemctl status caddy`
`q` exits
At this point, navigating to yourdomain.com should give you a 502 bad gateway error. That's good!
# 4 Set up MySQL
## Install MySQL
`sudo apt-get install mysql-server -y`
( enter blank password each time if prompted)
`sudo systemctl status mysql` (q to exit)
## Secure Setup
`sudo mysql_secure_installation`
* Password abcd1234
* No to password validation
* Y to all other options
## Login to mysql from root to complete setup:
`sudo mysql` to enter mysql> console
mysql>
`ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'abcd1234';`
mysql>
`FLUSH PRIVILEGES;`
`Control+D` to exit
Verify:
`mysql -u root -p` and then entering your password abcd1234 should give you the mysql> shell
# 5 Get Lbrynet Daemon
## Start tmux
This just allows you to run multiple things in different sessions. Useful for manually starting daemons and watching its console logs.
`tmux`
* `Ctrl+b`, then `d` detaches leaving session running.
* `tmux`, reenters tmux, then
* `Ctrl+b`, `(` goes back to through sessions
## Get the daemon
`wget -O ~/latest_daemon.zip https://lbry.io/get/lbrynet.linux.zip`
`unzip -o -u ~/latest_daemon.zip`
## Start the daemon
`./lbrynet start`
## Detatch tmux session
* `Control + b`, then `d` to leave lbrynet daemon running and exit the session
`tmux` if you want to get back into tmux
`Control+b`, then `)` while in tmux session to cycle back to your lbrynet session to see output
## Display wallet address to which to send 5+ LBC.
_note: These commands work when `./lbrynet start` is already running in another tmux session_
`./lbrynet commands` to check out the current commands
`./lbrynet address_list` to get your wallet address
`Ctrl + Shift + C` after highlighting an address to copy.
Use a LBRY app or daemon to send LBC to the address. Sending LBC may take a few seconds or longer.
`./lbrynet account_balance` to check your balance after you've sent LBC.
## Optional/Production: Set up lbrynet to run as a systemd service
`//coming soon`
# 6 Set up spee.ch
## Build it
`cd spee.ch`
~/spee.ch:
`npm install`
`cp ~/spee.ch/docs/setup/conf/speech/chainqueryConfig.json ~/spee.ch/site/config/chainqueryConfig.json`
`npm run configure` (once your wallet balance has cleared)
* Database: lbry
* Username: root
* Password: abcd1234
* Port: 3000
* Site Title: Your Site Name
* Enter your site's domain name: https://freezepeach.fun (this must include 'https://')
* Enter a directory where uploads should be stored: (/home/lbry/Uploads)
`npm run start`
## Try it
Navigate to yourdomain.fun!
# 7 Production
## pm2 to keep your speech app running
```
npm install -g pm2
```
### 7 Maintenance Proceedures
#### Change daemon
* backup wallet (private keys!) to a safe place
* wget daemon from https://github.com/lbryio/lbry/releases
* wget -O ~/your_name_daemon.zip https://your_copied_file_path.zip
* rm ./lbrynet
* unzip -o -u ~/your_name_daemon.zip