Trying to make it from scratch
I was thinking of modifying existing templates for react app, but after some thinking I decided to make my own structure and that way understand better how everything works. If this experiment is successuful I will set some time a side and write a detailed tutorial how to build PWAs.
To run webpack dev server:
npm test
To create a bundle:
npm run build
To run server after bundle is made:
npm start
usage: forever [start | stop | stopall | list] [options] SCRIPT [script options]
options:
start --> start SCRIPT as a daemon
stop --> stop the daemon SCRIPT
stopall --> stop all running forever scripts
list --> list all running forever scripts
sudo systemctl start mongod
sudo systemctl stop mongod
sudo systemctl reload mongod
sudo systemctl restart mongod
- Create a CentOS droplet on Digital Ocean
- Setup a user and password
- Node, follow instructions at https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-a-centos-7-server
- Install the latest node 7 https://www.liquidweb.com/kb/how-to-install-nvm-node-version-manager-for-node-js-on-centos-7/
- Install git https://www.digitalocean.com/community/tutorials/how-to-install-git-on-centos-7
- Install web-push:
sudo npm install -g web-push
- git clone https://github.com/Danilo-Zekovic/pwa
- cd pwa
- npm install
- Instructions can be found https://certbot.eff.org/#centosrhel7-other
- yum -y install yum-utils
- yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional
- sudo yum install certbot
- Link a domain name to the IP of the server (domain-name)
- Instructions found https://certbot.eff.org/#centosrhel7-other, below is commnd you are looking for
- certbot certonly --standalone -d www.example.com
- Certificates are placed in /etc/letsencrypt/live/www.example.com/fullchain.pem
- /etc/letsencrypt/live/www.example.com/privkey.pem
- In file KEY_RING.js replace PRIVATE_KEY_PATH with path to privkey.pem and CERTIFICATE_PATH with path to fullchain.pem
- Create keys: web-push generate-vapid-keys
- Copy the key values
- In file KEY_RING.js replace PUBLIC_KEY and PRIVATE_KEY with generated values
- Also, change the email to match email that you hae access to
- Replace applicationServerPublicKey in ./public/scripts/push.js with the value of the publicKey
- sudo npm install forever -g
- sudo forever start index.js
- In the browser open https://your.domain.name