|
| 1 | +Firebase Cloud Messaging Node.js |
| 2 | +=========================================== |
| 3 | + |
| 4 | +## API Documentation |
| 5 | +https://app.swaggerhub.com/apis/vaiol/npfsb-push/ |
| 6 | + |
| 7 | +# Docker version |
| 8 | +Docker version of program require only docker and docker compose program installed, web server, postgres and nginx will be provided in docker containers. |
| 9 | + |
| 10 | +## Dependency |
| 11 | +- docker |
| 12 | +- docker-compose |
| 13 | + |
| 14 | +## Installing |
| 15 | +1. Install Docker [guide](https://docs.docker.com/install/linux/docker-ce/ubuntu/) |
| 16 | +1. Install Docker Compose [guide](https://docs.docker.com/compose/install/#prerequisites) |
| 17 | + |
| 18 | +## Configuration |
| 19 | +Configuring project you must manipulate only with this files: |
| 20 | +- docker-compose.prod.yml |
| 21 | +- nginx/nginx.conf |
| 22 | +- nginx/privkey.pem |
| 23 | +- nginx/fullchain.pem |
| 24 | +- nginx/dhparam.pem |
| 25 | +- conf/serviceAccountKey.json |
| 26 | + |
| 27 | +1. Firebase configuration: |
| 28 | +To send your push to users you need to connect your Firebase service account to this program, this could be made by 3 simple steps: |
| 29 | + - First of all, you should create service account in Firebase Console, if you have one, skip this step. |
| 30 | + To create service account open your Firebase console, then open your application, after that open settings -> service accounts and create one. After creating you will recieve 'serviceAccountKey.json' file also in this page you can find firebase 'databaseURL' strng. |
| 31 | + - Put your 'serviceAccountKey.json' into ./config/ folder in the root of project, ou should get ./config/serviceAccountKey.json as result. |
| 32 | + - Change FIREBASE_DB environment in admin1 block in docker-compose.prod.yml to your 'databaseURL' of your service account. |
| 33 | +1. web configuration: |
| 34 | + - You can disable https, create different servers and others just by changing nginx.conf file placed in ./nginx/ folder. |
| 35 | + This is simple nginx conf file. |
| 36 | + - By default https is enabled, and you couldn't run server without valid ssl key and certificate, so if you want launch server without https you can change nginx.conf file. |
| 37 | + - You can change url for checking user session, by change all SESSION_URL environment fields in docker-compose.prod.yml file. By default they are set to `https://lk.npfsb.ru/api/user/authorized`. |
| 38 | +1. https configuration: |
| 39 | +To start project with HTTPS you need to get SSL certificate and key and connect it to program. |
| 40 | + - If you don't have SSL certificate you can get it simply with certbot [guide](https://certbot.eff.org/lets-encrypt/ubuntuxenial-other) |
| 41 | + - You should put your private key file to folder ./nginx/ in root of project with name 'privkey.pem', you should get ./nginx/privkey.pem as result. (it is basic name for letsencrypt files) |
| 42 | + - You should put your chain of certificate and intermidiate certificate to folder ./nginx/ in root of project with name 'fullchain.pem', you should get ./nginx/fullchain.pem as result. (it is a basic name of letsencrypt) |
| 43 | + - You should generate dhparam.pem key and place it to ./nginx/ folder in root of project, you should get ./nginx/dhparam.pem as result. |
| 44 | + `openssl dhparam -out ./nginx/dhparam.pem 4096` - command for generating dhparam key (it may take long time). |
| 45 | + Or you can use existed key in this folder and do nothing. |
| 46 | +1. DB configuration: |
| 47 | +DB fully configured to work, make this changes only if you understand what are you doing. |
| 48 | + - Change db name, user, and password if needed, fields: POSTGRES_PASSWORD, POSTGRES_DB, POSTGRES_USER. |
| 49 | + - If db configurations was changed, changing db connection url also required: field DB_URL in each web block (should be changed 4 urls for web1, web2, web3, admin1 blocks). |
| 50 | + - By default postgres will run into the container, and won't be accessible outside. If you want make it accessible, just 'ports' filed in db block should be uncommented. Make sure that you don't have ulready launched postgres instance, port 5432 should be free. |
| 51 | + |
| 52 | +## Build |
| 53 | +In root of project: |
| 54 | +`docker-compose -f docker-compose.prod.yml up --build` |
| 55 | +After project will be builded, (process not finished automatically) you could press `ctrl c` and start it. |
| 56 | + |
| 57 | +## Start |
| 58 | +In root of project: |
| 59 | +`docker-compose -f docker-compose.prod.yml up -d` |
| 60 | + |
| 61 | + |
| 62 | +# Manipulation after deploying |
| 63 | +### Get Logs |
| 64 | + - logs is placed in ./logs/ folder in root of project. |
| 65 | +### Get list of all awailable notifications |
| 66 | +- conf/notifications.json - is file with all possible notifications to send. (file will be generated after first http request to /admin/send endpoint, so, make your test request) |
0 commit comments