2026-06-04 20:51:03 +00:00

96 lines
2.4 KiB
Markdown

# VM hosting (Option A)
Production layout on the app VM:
| Service | systemd unit | Listen | Process |
|---------|----------------|--------|---------|
| Dart API | `cyberhybridhub-api` | `0.0.0.0:3000` | `dart run bin/server.dart` in `server/` |
| Flutter web | `cyberhybridhub-web` | `0.0.0.0:80` | `scripts/web_static_server.dart` → `build/web` |
**OpenWrt / HAProxy** terminates HTTPS on `:443` and should proxy:
- `/` → `10.10.101.106:80` (Flutter static)
- `/v1`, `/hubs` → `10.10.101.106:3000` (API + SignalR)
Port **3000 is not published on the WAN**. See `haproxy-openwrt.example.cfg`.
Local development uses `./startup.sh` (API 3000, web 8080, localhost-only).
## API URL for Flutter web builds
Set the same public origin the browser uses (no `:3000` on WAN):
| File | Variable |
|------|----------|
| `hosting/hosting.env` | `API_PUBLIC_URL=https://cyberhybridhub.com` |
| `server/.env` | `API_BASE_URL=https://cyberhybridhub.com` (optional; used if hosting unset) |
Build (reads hosting → server → default):
```bash
./scripts/build-production-web.sh
```
Verify baked URL:
```bash
grep -o 'https://cyberhybridhub.com[^"]*' build/web/main.dart.js | head -5
```
Should show `https://cyberhybridhub.com` for API calls, not `:3000`.
## First-time setup
```bash
cd /home/chh/cyberhybridhub.com
cp server/.env.example server/.env
nano server/.env
cp hosting/hosting.env.example hosting/hosting.env
nano hosting/hosting.env
source scripts/flutter-env.sh
./scripts/deploy-production.sh
chmod +x hosting/install-systemd.sh scripts/*.sh
./hosting/install-systemd.sh
```
## OpenWrt HAProxy
Copy `hosting/haproxy-openwrt.example.cfg` into `/etc/haproxy.cfg` (merge with mygit rules), then:
```sh
haproxy -c -f /etc/haproxy.cfg && /etc/init.d/haproxy reload
curl -skI https://cyberhybridhub.com/v1/me/profile | head -3
```
## Updates
```bash
git pull
./scripts/deploy-production.sh
sudo systemctl restart cyberhybridhub-api cyberhybridhub-web
```
Quick redeploy (code only, no `pub get`, restarts services):
```bash
git pull
./scripts/deploy-dev.sh
```
## Firebase authorized domains
```bash
./scripts/check-firebase-auth-domains.sh
```
Must include `cyberhybridhub.com` (and `www.cyberhybridhub.com` if used).
## Legacy Fresh app
The old unit `cyberhybridhub.service` pointed at `/home/chh/publish/server` on port 80.
`install-systemd.sh` stops and disables it when installing the Flutter units.