# CI Observer Operations Runbook

## Purpose
Operational guide for running CI Observer on the runner VM with one stable production instance and optional temporary test instances.

## Standard Layout on Runner
- Production folder: `/webapps/ci-observer-dashboard-prod`
- Temporary test folder example: `/webapps/ci-observer-dashboard-<feature>`
- One folder per instance. No nested folder-in-folder setup.

## Production Deploy (main branch)
```bash
cd /webapps/ci-observer-dashboard-prod
git checkout main
git pull
docker compose up -d --build
docker compose ps
```

## Required `.env`
```env
GITHUB_TOKEN=...
GH_REPOS=Wolkabout/IoT-Platform-Core,Wolkabout/argocd
GH_WORKFLOWS=unit-tests.yml,deploy-be.yml,deploy-fe.yml
REFRESH_SECONDS=5
DASHBOARD_TITLE="CI Observer Dashboard"
```

Notes:
- `GH_WORKFLOWS` must be set in current app behavior.
- Private repos require PAT scopes: `repo`, `read:org`, `workflow`.

## Production Compose (8089)
`docker-compose.yml` should use:
- `container_name: ci-observer-dashboard-prod`
- `ports: "8089:8088"`
- `volumes: ./data:/app/data`

## Quick Health Check
```bash
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" | grep ci-observer-dashboard-prod
curl -s http://127.0.0.1:8089/api/config
curl -s http://127.0.0.1:8089/api/runs | head -c 800; echo
```

## Temporary Test Instance Flow
```bash
cd /webapps
git clone https://github.com/Wolkabout/ci-observer-dashboard.git ci-observer-dashboard-mytest
cd ci-observer-dashboard-mytest
cp /webapps/ci-observer-dashboard-prod/.env .env
git checkout <feature-branch>
```

Edit `docker-compose.yml` for test:
- `container_name: ci-observer-dashboard-mytest`
- `ports: "8090:8088"` (or any free test port)
- `volumes: ./data-mytest:/app/data`

Run:
```bash
docker compose up -d --build
```

Cleanup after test:
```bash
docker compose down --remove-orphans
cd /webapps
rm -rf /webapps/ci-observer-dashboard-mytest
```

## Final Cleanup Checklist
```bash
docker rm -f ci-observer-dashboard ci-observer-dashboard-filters ci-observer-dashboard-metadata-test 2>/dev/null || true
find /webapps -maxdepth 1 -type d -name "ci-observer-dashboard-*" ! -name "ci-observer-dashboard-prod"
```

Expected final state:
- Only `/webapps/ci-observer-dashboard-prod` is active for production.
- Production container on `8089`.

