-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Tutorial showing how to install Trek server.
- VPS or just machine with public IP address
- Docker (with compose) and git installed
- domain (optional)
$ git clone https://github.com/jsfraz/trek-server.gitGo to the cloned folder and create .env file with following content and modify it as you need:
POSTGRES_USER=trek
POSTGRES_PASSWORD=12345678
POSTGRES_PORT=5432
POSTGRES_DB=trek
ACCESS_TOKEN_SECRET=...your secret text...
ACCESS_TOKEN_LIFESPAN=111600
TRACKER_TOKEN_SECRET=...your secret text...
SUPERUSER_USERNAME=root
SUPERUSER_PASSWORD=12345678
CLIENT_URL=https://your-trek.example.com| ENV | Example value | Description |
|---|---|---|
| POSTGRES_USER | trek | Database user |
| POSTGRES_PASSWORD | 12345678 | Database password |
| POSTGRES_PORT | 5432 | Database port |
| POSTGRES_DB | trek | Database name |
| ACCESS_TOKEN_SECRET | ...your secret text... | User access token secret, should be long unique secret text. |
| ACCESS_TOKEN_LIFESPAN | 111600 | User access token lifespan in seconds. |
| TRACKER_TOKEN_SECRET | ...your secret text... | Tracker access token secret, should be long unique secret text. |
| SUPERUSER_USERNAME | root | Trek admin username |
| SUPERUSER_PASSWORD | 12345678 | Trek admin password |
| CLIENT_URL | https://your-trek.example.com | Trek client URL |
The application uses GitHub Actions to automatically build and deploy when pushing to the main branch. For this process to work correctly, the following secret keys must be set in the repository settings (Settings > Secrets and variables > Actions):
| Secret | Description |
|---|---|
| VPS_HOST | IP address or domain name of the VPS server |
| VPS_USERNAME | Username for SSH access |
| VPS_SSH_KEY | Private SSH key for server access |
| VPS_PORT | SSH port (usually 22) |
| PROJECT_PATH | Absolute path to the directory to clone the project to on the VPS server |
This command runs the compose file and creates the container.
$ docker compose up --build -dYou can omit --build if you don't want to build server image again. Used when you modify .env and re-run compose.
Now the server is running on server's http://localhost:8080
Create DNS A record for subdomain pointing to your machine's public IP.
Create Nginx config file /etc/nginx/conf.d/your-trek-backend.conf with following config:
Replace your-trek-backend.example.com and public_ip with your machine's public IP or optionally DNS name.
server {
listen public_ip:80;
server_name your-trek-backend.example.com;
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}If you have used domain name in the Nginx configuration, you can generate SSL certificate to use SSL.
Install Certbot:
$ sudo apt install certbot python3-certbot-nginxAutomatically configure HTTPS using Let's Encrypt. Replace your-trek-backend.example.com with your DNS name:
$ sudo certbot --nginx -d your-trek-backend.example.comYou have installed Trek serever!