readme.md 3.56 KB
Newer Older
beardedwarrior's avatar
beardedwarrior committed
1

xiphon's avatar
xiphon committed
2
# About Monero CCS
beardedwarrior's avatar
beardedwarrior committed
3

xiphon's avatar
xiphon committed
4 5 6 7
Monero CCS is a simple web system for capturing donations made to fund community projects

# CCS Deployment Quickstart

8
## Requirements
xiphon's avatar
xiphon committed
9 10 11 12 13
```
mysql >= 5.7.7
php >= 7.1
```

14 15
## Deployment

xiphon's avatar
xiphon committed
16 17
```
apt update
18 19
apt install -y jekyll mysql-server nginx php php-curl php-fpm php-gd php-mbstring php-mysql php-xml unzip
```
xiphon's avatar
xiphon committed
20

21
Install `Composer` following the instructions at https://getcomposer.org/download/
xiphon's avatar
xiphon committed
22

23
```
xiphon's avatar
xiphon committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
cd /var/www/html

git clone --recursive https://repo.getmonero.org/monero-project/ccs-back.git
git -C ccs-back/storage/app/proposals checkout master

git clone https://repo.getmonero.org/monero-project/ccs-front.git
rm -rf ccs-front/proposals
ln -s /var/www/html/ccs-back/storage/app/proposals ccs-front/proposals
ln -fs /var/www/html/ccs-back/storage/app/proposals.json ccs-front/_data/proposals.json
ln -fs /var/www/html/ccs-back/storage/app/complete.json ccs-front/_data/completed-proposals.json

cd ccs-back
composer update
cp .env.example .env
```

Run Monero RPC wallet in background with `--disable-rpc-login` option
Example:
``` 
./monero-wallet-rpc --wallet-file=wallet --password=secret --disable-rpc-login --rpc-bind-port=28080
```

Spin up MYSQL server, create new database, user and grant user access to it  
Open `.env` in editor of choice and edit the following lines:
```
APP_URL=http://<YOUR_DOMAIN>

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=<DB_NAME>
DB_USERNAME=<DB_USER_NAME>
DB_PASSWORD=<DB_USER_PASSWORD>

RPC_URL=http://127.0.0.1:28080/json_rpc

GITLAB_URL=https://repo.getmonero.org/api/v4/projects/54
```

Initialize the system
```
php artisan migrate:fresh
php artisan up
php artisan key:generate
php artisan proposal:process
php artisan proposal:update
```

Grant `www-data` user access to the files
```
cd ..
chown -R www-data ccs-back/
chown -R www-data ccs-front/
```

Remove Nginx example config 
```
rm /etc/nginx/sites-enabled/default
```
Create new file `/etc/nginx/sites-enabled/ccs` in editor of choice and paste the following lines replacing `<IP_ADDRESS>` and `<PHP_VERSION>` with appropriate values

```
server {
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/html/ccs-front/_site/;
    index index.php index.html;
    server_name <IP_ADDRESS>;
    
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    
    # pass the PHP scripts to FastCGI server
    #
    
    location ~ \.php$ {
        root /var/www/html/ccs-back/public/;
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php<PHP_VERSION>-fpm.sock;
    }
}
```

```
service nginx reload
```

Set up a cron job that will run periodic updates (every minute) and generate static HTML files
```
* * * * * git -C /var/www/html/ccs-back/storage/app/proposals/ pull; php /var/www/html/ccs-back/artisan schedule:run; jekyll build --source /var/www/html/ccs-front --destination /var/www/html/ccs-front/_site
```

## Optional
Instead of scheduling a cron job you can run the following commands in no particular order
1. Update CCS system proposals intenal state
    ```
    php /var/www/html/ccs-back/artisan proposal:process
    php /var/www/html/ccs-back/artisan generate:addresses
    php /var/www/html/ccs-back/artisan monero:notify
    php /var/www/html/ccs-back/artisan proposal:update
    ```
3. Process incoming donations  
*Run it either on new block/tx notification or schedule it to run every minute or so*
    ```
    php /var/www/html/ccs-back/artisan monero:notify
    ```
2. Generate static HTML files
    ```
    jekyll build --source /var/www/html/ccs-front --destination /var/www/html/ccs-front/_site
xiphon's avatar
xiphon committed
134
    ```