# SparkyFitness Setup (rayserver) ## Deployment - Docker Compose: `/mnt/seagate8tb/Websites/SparkyFitness/docker-compose.yml` - Env config: `/mnt/seagate8tb/Websites/SparkyFitness/.env` - Backup dir: `/mnt/seagate8tb/Websites/SparkyFitness/backup/` - Uploads dir: `/mnt/seagate8tb/Websites/SparkyFitness/uploads/` ## Architecture ``` [Internet] → nginx (home server, port 3451 SSL) → localhost:3004 → frontend container (nginx, port 80) ↕ (Docker network) server container (port 3010) ↕ Postgres container (port 5432) ``` The frontend container runs its own nginx that reverse-proxies API calls to the server container over the Docker internal network. The home server nginx just proxies HTTP to port 3004. ## Nginx Reverse Proxy Config Home nginx (`/etc/nginx/sites-available/sparkyfitness`): ```nginx server { listen 3451 ssl; server_name sparkyfitness.graj-media.com grajmedia.duckdns.org; ssl_certificate /etc/letsencrypt/live/grajmedia.duckdns.org/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/grajmedia.duckdns.org/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!aNULL:!MD5; client_max_body_size 100M; location / { proxy_pass http://127.0.0.1:3004; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_read_timeout 86400; } } ``` Then symlink and reload: ```bash sudo ln -sf /etc/nginx/sites-available/sparkyfitness /etc/nginx/sites-enabled/sparkyfitness sudo nginx -t && sudo systemctl reload nginx ``` ## Env Var Changes When Exposing Publicly In `.env`, change these from the default: ```bash SPARKY_FITNESS_FRONTEND_URL=https://sparkyfitness.graj-media.com SPARKY_FITNESS_EXTRA_TRUSTED_ORIGINS=https://sparkyfitness.graj-media.com,http://localhost:3004,http://192.168.50.98:3004 ``` After changing `.env`, restart the stack: ```bash cd /mnt/seagate8tb/Websites/SparkyFitness docker compose up -d --force-recreate ``` ## Android Mobile App - Download: `app-release.apk` from https://github.com/CodeWithCJ/SparkyFitness/releases/latest (v0.17.3, ~188MB) - Sideload on Android phone - Configure the app to point at `https://sparkyfitness.graj-media.com` (or whichever subdomain) - **Requires HTTPS** — the app won't connect over plain HTTP - Integrates with Android Health Connect for data sync - Play Store beta: Join https://groups.google.com/g/sparkyfitness first, then https://play.google.com/store/apps/details?id=com.SparkyApps.SparkyFitnessMobile ## Verification ```bash # Local access curl -sk https://localhost:3451/ # Check response includes the SparkyFitness HTML curl -sk https://localhost:3451/ | grep -o '.*' # nginx logs sudo tail -20 /var/log/nginx/access.log | grep 3451 ```