Deploying to a VPS
This runs the app with pm2 on the machine directly. The setup is easier but less secure.
Script installs and runs the web client, API and PV. If you want just the web client move to manual installation steps.
install.sh works on debian based distros only, for now. If you're running any other system move to manual installation steps and find replacements for the used packages.
Requirements:
- a VPS
- Fully qualified domain name
OPTION 1. Install script ( Recommended )
1. SSH into your VPS and create an empty folder in your home directory, ex. mkdir khofly
2. cd khofly and type git clone https://github.com/cufta22/khofly.git .
2.1. Pick a branch, by default it will be on master but if you want more frequent updates git fetch origin staging and git checkout -b staging origin/staging
3. Once the code is fetched, make sure that you can execute the install script chmod +x ./scripts/install.sh
3.1. Don't blindly trust any script you pull from the internet, you can inspect it with cat ./scripts/install.sh
4. Now you can run the script with sudo ./scripts/install.sh, if you didn't get any errors the installation was successful.
5. Edit the .env file for web ( nano ./web/.env.local ) values per provided comments.
6. Edit the .env file for api ( nano ./api/.env.local ) values per provided comments.
7. Edit the .env file for pv ( nano ./pv/.env.local ) values per provided comments.
8. Run ./scripts/update.sh to rebuild the everything since we changed the env files.
9. cd /etc/nginx/sites-available/ and edit the domain names for web and api files, and whatever other Nginx config you want to add.
10. Add SSL certificate for your domain certbot --nginx
11. sudo systemctl reload nginx
OPTION 2. Manual installation
1. Install dependencies
2. Install NVM
3. Install pnpm
4. Install pm2
5. Install Bun
6. Create an empty folder in your home directory, ex. mkdir khofly.
7. cd khofly and type git clone https://github.com/cufta22/khofly.git .
7.1. Pick a branch, by default it will be on master but if you want more frequent updates git fetch origin staging and git checkout -b staging origin/staging
8. Build and run web client
9. Create the ecosystem.config file for pm2
10. Create Nginx config for web, don't forget to update the server_name to your domain name.
11. Add SSL certificate for your domain certbot --nginx
12. sudo systemctl reload nginx
Updating
To update the web client, API and PV run ./scripts/update.sh. This will fetch the latest code and rebuild everything.
Make sure it is executable chmod +x ./scripts/update.sh.
Read more