Preserve Flutter mirror-os codebase
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
# OTA Update Server
|
||||
|
||||
Static file server for hosting Mirror OS remote APK updates. Runs on the homelab alongside workout-player on port 9091.
|
||||
|
||||
## Endpoints
|
||||
|
||||
| Path | Description |
|
||||
|------|-------------|
|
||||
| `GET /api/mirror-os/version` | Version manifest (JSON) |
|
||||
| `GET /mirror-os-remote.apk` | APK download |
|
||||
| `GET /health` | Health check |
|
||||
|
||||
## Deploy on Homelab
|
||||
|
||||
```bash
|
||||
# Copy files to homelab
|
||||
rsync -avz deploy/ota-server/ homelab:~/ota-server/
|
||||
|
||||
# Start the server
|
||||
ssh homelab 'cd ~/ota-server && docker compose up -d'
|
||||
```
|
||||
|
||||
The server runs nginx on port 9091 serving static files from `public/`.
|
||||
|
||||
## Publish an Update
|
||||
|
||||
From the repo root:
|
||||
|
||||
```bash
|
||||
# Build APK, bump version, copy to public/
|
||||
./deploy/publish-apk.sh "Added new feature X"
|
||||
|
||||
# Then sync to homelab
|
||||
rsync -avz deploy/ota-server/public/ homelab:~/ota-server/public/
|
||||
```
|
||||
|
||||
The script:
|
||||
1. Builds the release APK via `flutter build apk --release`
|
||||
2. Copies the APK to `deploy/ota-server/public/mirror-os-remote.apk`
|
||||
3. Increments the version number in `version.json`
|
||||
4. Sets the changelog from the argument (or defaults to "Bug fixes and improvements")
|
||||
|
||||
## How the App Checks for Updates
|
||||
|
||||
The remote app (`apps/remote`) has an `update_provider.dart` that:
|
||||
1. Fetches `http://192.168.86.172:9091/api/mirror-os/version`
|
||||
2. Compares the returned `version` number against the locally installed version
|
||||
3. If newer, shows a prompt to download and install the APK from `downloadUrl`
|
||||
|
||||
## Version Manifest Format
|
||||
|
||||
```json
|
||||
{
|
||||
"version": 1,
|
||||
"downloadUrl": "http://192.168.86.172:9091/mirror-os-remote.apk",
|
||||
"changelog": "Initial release"
|
||||
}
|
||||
```
|
||||
|
||||
The `version` field is a simple incrementing integer.
|
||||
@@ -0,0 +1,12 @@
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
ota-server:
|
||||
image: nginx:alpine
|
||||
container_name: mirror-os-ota
|
||||
ports:
|
||||
- "9091:80"
|
||||
volumes:
|
||||
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
- ./public:/usr/share/nginx/html:ro
|
||||
restart: unless-stopped
|
||||
@@ -0,0 +1,27 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
# Serve version manifest as JSON
|
||||
location = /api/mirror-os/version {
|
||||
alias /usr/share/nginx/html/version.json;
|
||||
default_type application/json;
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
add_header Access-Control-Allow-Origin "*";
|
||||
}
|
||||
|
||||
# Serve APK with correct content type
|
||||
location = /mirror-os-remote.apk {
|
||||
default_type application/vnd.android.package-archive;
|
||||
add_header Content-Disposition 'attachment; filename="mirror-os-remote.apk"';
|
||||
add_header Access-Control-Allow-Origin "*";
|
||||
}
|
||||
|
||||
# Health check
|
||||
location = /health {
|
||||
return 200 '{"status":"ok"}';
|
||||
default_type application/json;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"version": 1,
|
||||
"downloadUrl": "http://192.168.86.172:9091/mirror-os-remote.apk",
|
||||
"changelog": "Initial release"
|
||||
}
|
||||
Reference in New Issue
Block a user