readme.md 3.99 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
apt install -y cron git jekyll mysql-server nginx php php-curl php-fpm php-gd php-mbstring php-mysql php-xml unzip
19
```
xiphon's avatar
xiphon committed
20

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

23
Checkout and configure CCS backend, frontend and proposals repositories (replace `<REPOSITORY_CCS_BACKEND>`, `<REPOSITORY_CCS_FRONTEND>`, `<REPOSITORY_CCS_PROPOSALS>` with the actual URLs)
24
```
xiphon's avatar
xiphon committed
25 26
cd /var/www/html

27 28 29
git clone <REPOSITORY_CCS_BACKEND>
git clone <REPOSITORY_CCS_FRONTEND>
git clone <REPOSITORY_CCS_PROPOSALS> ccs-back/storage/app/proposals
xiphon's avatar
xiphon committed
30 31 32 33 34 35 36 37 38 39 40 41

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
```

Spin up MYSQL server, create new database, user and grant user access to it  
42 43 44 45
Open `.env` in editor of choice and edit the following lines:  
> `COIN` - choose one of supported coins: `monero` or `zcoin`  
> `REPOSITORY_URL` - CCS proposals Github URL or GitLab API endpoint (e.g. https://\<GITLAB_DOMAIN>/api/v4/projects/\<PROJECT_ID>)>  
> `GITHUB_ACCESS_TOKEN` - leave empty if you are not using Github or visit https://github.com/settings/tokens to generate new `public_repo` token
xiphon's avatar
xiphon committed
46
```
47
APP_URL=http://<HOSTNAME>
xiphon's avatar
xiphon committed
48 49 50 51 52 53 54 55 56

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
57 58
RPC_USER=
RPC_PASSWORD=
xiphon's avatar
xiphon committed
59

60 61 62 63
COIN=<COIN>

REPOSITORY_URL=<REPOSITORY_URL>
GITHUB_ACCESS_TOKEN=
xiphon's avatar
xiphon committed
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
```

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/
```

82
Remove Nginx example config
xiphon's avatar
xiphon committed
83 84 85
```
rm /etc/nginx/sites-enabled/default
```
86
Create new file `/etc/nginx/sites-enabled/ccs` in editor of choice and paste the following lines replacing `<HOSTNAME>` and `<PHP_VERSION>` with appropriate values
xiphon's avatar
xiphon committed
87 88 89 90 91 92 93

```
server {
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/html/ccs-front/_site/;
    index index.php index.html;
94 95
    server_name <HOSTNAME>;

xiphon's avatar
xiphon committed
96 97 98
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
99

xiphon's avatar
xiphon committed
100 101
    # pass the PHP scripts to FastCGI server
    #
102

xiphon's avatar
xiphon committed
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
    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
126
    php /var/www/html/ccs-back/artisan wallet:notify
xiphon's avatar
xiphon committed
127 128
    php /var/www/html/ccs-back/artisan proposal:update
    ```
129
2. Process incoming donations  
xiphon's avatar
xiphon committed
130 131 132 133
*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
    ```
134
1. Generate static HTML files
xiphon's avatar
xiphon committed
135 136
    ```
    jekyll build --source /var/www/html/ccs-front --destination /var/www/html/ccs-front/_site
xiphon's avatar
xiphon committed
137
    ```
138
2. Get the full list of processed transactions in JSON format
139 140 141
    ```
    php /var/www/html/ccs-back/artisan deposit:list
    ```