github.com/decred/politeia@v1.4.0/politeiawww/README.md (about)

     1  politeiawww
     2  ====
     3  
     4  ## Installing and running
     5  
     6  ### Install dependencies
     7  
     8  <details><summary><b>Go 1.18 or 1.19</b></summary>
     9  
    10    Installation instructions can be at https://golang.org/doc/install.
    11    Ensure Go was installed properly and is a supported version:
    12    ```
    13    $ go version
    14    $ go env GOROOT GOPATH
    15    ```
    16    NOTE: `GOROOT` and `GOPATH` must not be on the same path. Since Go 1.8
    17    (2016), `GOROOT` and `GOPATH` are set automatically, and you do not need to
    18    change them. However, you still need to add `$GOPATH/bin` to your `PATH` in
    19    order to run binaries installed by `go get` and `go install` (On Windows,
    20    this happens automatically).
    21  
    22    Unix example -- add these lines to .profile:
    23  
    24    ```
    25    PATH="$PATH:/usr/local/go/bin"  # main Go binaries ($GOROOT/bin)
    26    PATH="$PATH:$HOME/go/bin"       # installed Go projects ($GOPATH/bin)
    27    ```
    28  
    29  </details>
    30  
    31  <details><summary><b>Git</b></summary>
    32  
    33    Installation instructions can be found at https://git-scm.com or
    34    https://gitforwindows.org.
    35    ```
    36    $ git version
    37    ```
    38  
    39  </details>
    40  
    41  ### Install politeia
    42  
    43  This step downloads and installs the politeiad and politeiawww binaries. This
    44  can be skipped if you already completed it while setting up politeiad.
    45  
    46      ```
    47      $ mkdir -p $GOPATH/src/github.com/decred
    48      $ cd $GOPATH/src/github.com/decred
    49      $ git clone git@github.com:decred/politeia.git
    50      $ cd politeia
    51      $ go install -v ./...
    52      ```
    53  
    54  ### Setup MySQL (optional)
    55  
    56  This repo includes a script to setup a MySQL user database, it creates the 
    57  needed databases, the politeiawww user and assigns user privileges. Password 
    58  authentication is used for all database connections.
    59  
    60  **Note:** This is an optional step. By default, politeiawww will use a LevelDB 
    61  instance that does not require any additional setup.
    62  
    63  The setup script assumes MySQL is running on localhost:3306 and the users will 
    64  be accessing the databse from localhost. See the setup script comments for more 
    65  complex setups.
    66  
    67  Run the following commands. You will need to replace rootpass with the existing 
    68  password of your root user. The politeiawwwpass is the password that will be 
    69  set for the politeiawww user when it's created.
    70  
    71  ```
    72  $ cd $GOPATH/src/github.com/decred/politeia/politeiawww/scripts
    73  $ env \
    74    MYSQL_ROOT_PASSWORD=rootpass \
    75    MYSQL_POLITEIAWWW_PASSWORD=politeiawwwpass \
    76    ./userdb-mysql-setup.sh
    77  ```
    78  
    79  You will need to use the `--userdb=mysql` flag when starting politeiawww or 
    80  add `userdb=mysql` to the `politeiawww.conf` file that is setup in the steps
    81  below.
    82  
    83  An encryption key is required when using a MySQL database, use
    84  `politeiawww_dbutil` cmd tool to create one: 
    85  
    86  ```
    87  politeiawww_dbutil -createkey 
    88  ```
    89  
    90  ### Setup and run politeiawww
    91  
    92  [politeiad](https://github.com/decred/politeia/tree/master/politeiad#politeiad)
    93  must already be setup and running before you attempt to run politeiawww.
    94  
    95  1. Setup the politeiawww configuration file.
    96  
    97     [`sample-politeiawww.conf`](https://github.com/decred/politeia/blob/master/politeiawww/sample-politeiawww.conf)
    98  
    99     Copy the sample configuration file to the politeiawww app data directory.
   100     The app data directory will depend on your OS.
   101  
   102     * **macOS**
   103  
   104       `/Users/<username>/Library/Application Support/Politeiawww/politeiawww.conf`
   105  
   106     * **Windows**
   107  
   108       `C:\Users\<username>\AppData\Local\Politeiawww/politeiawww.conf`
   109  
   110     * **Unix**
   111  
   112       `~/.politeiawww/politeiawww.conf`
   113  
   114      ``` 
   115      $ mkdir -p ${HOME}/.politeiawww/
   116      $ cd $GOPATH/src/github.com/decred/politeia/politeiawww
   117      $ cp ./sample-politeiawww.conf ${HOME}/.politeiawww/politeiawww.conf
   118      ```
   119  
   120      Use the following config settings to spin up a development politeiawww
   121      instance.
   122  
   123     **politeiawww.conf**
   124  
   125      ```
   126      ; politeiad host and auth credentials
   127      rpchost=127.0.0.1
   128      rpcuser=user
   129      rpcpass=pass
   130      rpccert=~/.politeiad/https.cert
   131  
   132      testnet=true
   133      ```
   134      **Pi configuration**
   135  
   136      Pi, Decred's proposal system, requires adding the following additional
   137      settings to your configuration file.  
   138  
   139      ```
   140      ; Uncomment to enable paywall (optional)
   141      ; paywallxpub=tpubVobLtToNtTq6TZNw4raWQok35PRPZou53vegZqNubtBTJMMFmuMpWybFCfweJ52N8uZJPZZdHE5SRnBBuuRPfC5jdNstfKjiAs8JtbYG9jx
   142      ; paywallamount=10000000
   143      ```
   144  
   145  2. Fetch the politeiad identity. The first time you start politeiawww you will
   146     need to fetch the public key that politeiad uses to sign all responses. This
   147     is referred to as politeiad's identity and can be retrieved using the
   148     `--fetchidentity` flag. politeiawww will save the identity locally so that
   149     this only needs to be done once.
   150      ```
   151      $ politeiawww --fetchidentity
   152      ```
   153  3. Start up politeiawww.
   154      ```
   155      $ politeiawww
   156      ```
   157  ## API
   158  
   159  The [politeiawww APIs](https://github.com/decred/politeia/tree/master/politeiawww/api/)
   160  and [politeiawww client](https://github.com/decred/politeia/tree/master/politeiawww/client)
   161  can be treated as stable. All other APIs and libraries should be treated as
   162  unstable and subject to breaking changes.
   163  
   164  **Docs**:
   165  
   166   - Records API [docs](api/records/v1/api.md).
   167   - Legacy Politeiwww API [docs](api/www/v1/api.md) - will be deprecated.
   168  
   169  ## Tools and reference clients
   170  
   171  * [politeiavoter](https://github.com/decred/politeia/tree/master/politeiawww/cmd/politeiavoter) - 
   172    Tool for voting on Decred proposals using DCR tickets.
   173  * [politeiaverify](https://github.com/decred/politeia/tree/master/politeiawww/cmd/politeiaverify) - 
   174    Tool for verifying data and timestamps downloaded from politeiagui.
   175  * [politeiawww_dbutil](https://github.com/decred/politeia/tree/master/politeiawww/cmd/politeiawww_dbutil) - 
   176    Tool for making manual changes to the user database.
   177  * [pictl](https://github.com/decred/politeia/tree/master/politeiawww/cmd/pictl) -
   178    Reference client for pi, Decred's proposal system.
   179