Deploying to a VPS
This installs and runs both the web client and api, 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.
5.1. Run ./scripts/redeploy-web.sh web
( web
argument is the name of pm2 instance ) to rebuild the app since we changed the env file.
6. Edit the .env file for api ( nano ./api/.env.local
) values per provided comments.
6.1. Run ./scripts/redeploy-api.sh api
( api
argument is the name of pm2 instance ) to rebuild the app since we changed the env file.
7. cd /etc/nginx/sites-available/
and edit the domain names for web
and api
files, and whatever other Nginx config you want to add.
8. Add SSL certificate for your domain certbot --nginx
9. sudo systemctl reload nginx
OPTION 2. Manual installation
1. Install dependencies
2. Install NVM
3. Install pnpm
4. Install pm2
5. Create an empty folder in your home directory, ex. mkdir khofly
.
6. cd khofly
and type git clone https://github.com/cufta22/khofly.git .
6.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
7. Build and run web client
8. Create the ecosystem.config file for pm2
9. Create Nginx config for web, don't forget to update the server_name to your domain name.
10. Add SSL certificate for your domain certbot --nginx
11. sudo systemctl reload nginx
Updating
To update the web client run ./scripts/redeploy-web.sh web
, make sure to replace "web" with pm2 instance name for your web client.
To get a list of all pm2 instances run pm2 ls
Read more