Files
i-want-to-heal-2/docs/truenas-deploy.md
T

153 lines
3.6 KiB
Markdown

# I Want To Heal 2 Deployment
Do not hard-code Gitea tokens in repo files. Export `GITEA_TOKEN` in your shell.
## One-Time Local Git Setup
```bash
cd /Users/warren/Documents/action-mode
git init
git branch -M main
git remote add origin https://git.whoagland.com/phenom/i-want-to-heal-2.git
```
If the remote already exists:
```bash
cd /Users/warren/Documents/action-mode
git remote set-url origin https://git.whoagland.com/phenom/i-want-to-heal-2.git
```
## Step 1: Build APK For Thor
```bash
set -e
cd /Users/warren/Documents/action-mode
export JAVA_HOME="/Applications/Android Studio.app/Contents/jbr/Contents/Home"
export PATH="$JAVA_HOME/bin:$PATH"
VERSION="1.0.0"
CURRENT_CODE=$(grep -E 'versionCode [0-9]+' android/app/build.gradle | awk '{print $2}')
NEXT_CODE=$((CURRENT_CODE + 1))
perl -0pi -e "s/versionCode\s+\d+/versionCode $NEXT_CODE/" android/app/build.gradle
perl -0pi -e "s/versionName\s+\"[^\"]+\"/versionName \"$VERSION\"/" android/app/build.gradle
npm ci
VITE_API_BASE_URL="https://iwanttoheal.phenomrom.com" npm run android:sync
cd android
./gradlew clean assembleDebug
cd ..
cp android/app/build/outputs/apk/debug/app-debug.apk "IWantToHeal2-Thor-v$VERSION.apk"
ls -lh "IWantToHeal2-Thor-v$VERSION.apk"
```
## Step 2: Web/Server Build Check
```bash
set -e
cd /Users/warren/Documents/action-mode
npm run lint
npm run build
```
## Step 3: Commit And Push Code
```bash
set -e
cd /Users/warren/Documents/action-mode
VERSION="1.0.0"
git add .
git commit -m "I Want To Heal 2 build v$VERSION"
git push origin main
```
## Step 4: Create Gitea Release
```bash
set -e
cd /Users/warren/Documents/action-mode
export GITEA_URL="https://git.whoagland.com"
export GITEA_OWNER="phenom"
export GITEA_REPO="i-want-to-heal-2"
# export GITEA_TOKEN="paste-current-token-in-shell-only"
VERSION="1.0.0"
APK="IWantToHeal2-Thor-v$VERSION.apk"
RELEASE_JSON=$(curl -sS -X POST "$GITEA_URL/api/v1/repos/$GITEA_OWNER/$GITEA_REPO/releases" \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"tag_name\":\"v$VERSION\",\"target_commitish\":\"main\",\"name\":\"v$VERSION\",\"body\":\"I Want To Heal 2 Android and web/server build v$VERSION\",\"draft\":false,\"prerelease\":false}")
RELEASE_ID=$(python3 -c 'import sys,json; data=json.load(sys.stdin); print(data.get("id") or data)' <<< "$RELEASE_JSON")
echo "Release ID: $RELEASE_ID"
curl -sS -X POST "$GITEA_URL/api/v1/repos/$GITEA_OWNER/$GITEA_REPO/releases/$RELEASE_ID/assets?name=$APK" \
-H "Authorization: token $GITEA_TOKEN" \
-F "attachment=@$APK"
```
## Step 5: First TrueNAS Install
In the TrueNAS shell:
```bash
set -e
mkdir -p /mnt/usbssds/apps/iwanttoheal2
cd /mnt/usbssds/apps/iwanttoheal2
git clone https://git.whoagland.com/phenom/i-want-to-heal-2.git app
mkdir -p data db
```
Create the TrueNAS custom app from `docker-compose.truenas.yml`, or paste that compose file into the custom app UI.
Set these app environment values:
```text
POSTGRES_PASSWORD=<strong unique password>
```
Only set this after the reverse proxy/auth layer strips spoofed inbound auth headers and injects trusted user headers:
```text
TRUST_AUTH_HEADERS=1
```
## Step 6: Update TrueNAS
In the TrueNAS shell:
```bash
set -e
cd /mnt/usbssds/apps/iwanttoheal2/app
git pull origin main
```
Then restart the TrueNAS custom app.
## Admin Changes
There is no separate admin server yet. Mechanic admin is currently inside the web app under Action Mode settings. This command serves the same app on port `4174` for local admin work:
```bash
cd /Users/warren/Documents/action-mode
DATABASE_URL="postgres://iwanttoheal:<password>@127.0.0.1:5432/iwanttoheal" PORT=4174 npm run admin:start
```