# CRITICAL CHANGES FOR BETA ISO BUILD

## ⚠️ MUST-HAVE CHANGES - Without these, the beta will NOT work!

### 1. Backend: Podman Detection Fix
**File:** `core/container/src/podman_client.rs`

```rust
fn podman_async(&self) -> TokioCommand {
    // Always use sudo podman to access system-wide containers
    let mut cmd = TokioCommand::new("sudo");
    cmd.arg("podman");
    cmd
}
```

**System Config:** `/etc/sudoers.d/archipelago-podman`
```
archipelago ALL=(ALL) NOPASSWD: /usr/bin/podman
```

### 2. Backend: Bitcoin UI Container Mapping
**File:** `core/archipelago/src/container/docker_packages.rs`

Add special case for bitcoin-knots (line ~95):
```rust
} else if app_id == "bitcoin-knots" {
    // Check if bitcoin-ui exists (maps to "bitcoin" but serves bitcoin-knots)
    if let Some(ui_address) = ui_containers.get("bitcoin") {
        debug!("Using bitcoin-ui for bitcoin-knots: {}", ui_address);
        Some(ui_address.clone())
    } else {
        extract_lan_address(&container.ports)
    }
```

### 3. Backend: IndeedHub Metadata
**File:** `core/archipelago/src/container/docker_packages.rs`

Add to `get_app_metadata()` function (line ~327):
```rust
"indeedhub" => AppMetadata {
    title: "IndeedHub".to_string(),
    description: "Decentralized media streaming platform".to_string(),
    icon: "/assets/img/app-icons/indeedhub.png".to_string(),
    repo: "https://github.com/indeedhub/indeedhub".to_string(),
},
```

### 4. Frontend: Marketplace Bitcoin Knots
**File:** `neode-ui/src/views/Marketplace.vue`

```javascript
{
  id: 'bitcoin-knots',  // CHANGED from 'bitcoin'
  title: 'Bitcoin Knots',
  version: '28.1.0',    // UPDATED version
  dockerImage: 'docker.io/bitcoinknots/bitcoin:latest',  // CHANGED image
  // ... rest of config
}
```

### 5. Auto-Installer: Profile Script Fix
**File:** `image-recipe/build-auto-installer-iso.sh` (line ~850)

Remove `|| [ ! -t 0 ]` check:
```bash
# CORRECT:
if [ -n "$INSTALLER_STARTED" ]; then
    return 0
fi

# WRONG (will break auto-login):
# if [ -n "$INSTALLER_STARTED" ] || [ ! -t 0 ]; then
```

### 6. Nginx Configuration
**File:** Captured from `/etc/nginx/sites-available/default`

MUST include:
- HTTPS on port 443
- HTTP redirect to HTTPS
- Backend proxy: `/rpc/`, `/ws/`, `/health`
- Root: `/opt/archipelago/web-ui`
- SSL certificates in `/etc/nginx/ssl/`

### 7. Bitcoin UI Files
**Files:** `docker/bitcoin-ui/index.html` and `Dockerfile`

MUST be included in ISO or downloadable, so users can deploy the web UI container.

---

## Build Verification Before Beta Release

Run these checks:

```bash
# 1. Verify all source changes are committed
cd /Users/dorian/Projects/archy
git status  # Should show all critical files committed

# 2. Build ISO from live server
cd image-recipe
DEV_SERVER=archipelago@192.168.1.228 ./build-auto-installer-iso.sh

# 3. Test ISO on clean VM
# - Boot ISO
# - Verify auto-installer runs
# - System should boot to login
# - Access http://SERVER-IP
# - Complete onboarding
# - Install Bitcoin Knots from App Store
# - Verify "Already Installed" shows after install
# - Verify "Launch" button works
# - Verify web UI loads on port 8334

# 4. Test all critical features
# - Bitcoin node syncing
# - RPC accessible
# - Web UI functional
# - Backend detects container
# - App Store shows proper status
```

---

## Critical Files Checklist

Before building beta ISO, ensure these files have the latest changes:

- [ ] `core/container/src/podman_client.rs` - sudo podman
- [ ] `core/archipelago/src/container/docker_packages.rs` - app metadata + UI mapping
- [ ] `neode-ui/src/views/Marketplace.vue` - bitcoin-knots ID
- [ ] `neode-ui/src/utils/dummyApps.ts` - IndeedHub data
- [ ] `image-recipe/build-auto-installer-iso.sh` - auto-start fix
- [ ] `docker/bitcoin-ui/` - UI files present
- [ ] `scripts/deploy-bitcoin-knots.sh` - deployment script
- [ ] All assets: `neode-ui/public/assets/img/app-icons/*.png`

---

## Testing Matrix

| Feature | Expected | Status |
|---------|----------|--------|
| Bitcoin Knots container runs | Running | ✅ |
| Bitcoin UI container runs | Running | ✅ |
| Backend detects bitcoin-knots | Detected | ✅ |
| Backend maps bitcoin-ui → bitcoin-knots | Port 8334 | ✅ |
| App shows in My Apps | Listed | ✅ |
| App Store shows "Already Installed" | Badge shown | ✅ (after ID fix) |
| Launch button visible | Clickable | ✅ |
| Launch opens web UI | Port 8334 | ✅ |
| RPC accessible | Port 8332 | ✅ |
| Blockchain syncing | Active | ✅ |

---

## Roll-Back Plan

If beta ISO fails:

1. Check `/var/log/archipelago.log` on installed system
2. Verify containers with `sudo podman ps -a`
3. Check nginx status: `sudo systemctl status nginx`
4. Test backend: `curl http://localhost:5678/health`
5. Rebuild ISO with `BUILD_FROM_SOURCE=1` if server state is corrupt

---

## Support Commands for Users

```bash
# Check Bitcoin status
sudo podman logs -f bitcoin-knots

# Check blockchain sync progress
curl --user archipelago:archipelago123 \
  --data-binary '{"jsonrpc":"1.0","id":"test","method":"getblockchaininfo","params":[]}' \
  -H 'content-type: text/plain;' http://localhost:8332/ | grep blocks

# Restart if needed
sudo podman restart bitcoin-knots bitcoin-ui

# View Archipelago backend logs
sudo journalctl -u archipelago -f
```
