# Run همکادر locally with Docker (for testing)

A self-contained stack — app built from source + its own Postgres. It does **not** touch
production and does **not** send SMS.

## Start

```bash
docker compose -f docker-compose.local.yml up --build
```

Then open **http://localhost:18080**.

First run takes a few minutes (pulls the .NET images, restores NuGet from the Liara mirror,
builds, then applies EF migrations + seeds demo data on startup).

## Log in (OTP shown on screen — no SMS)

Because it runs in the **Development** environment, the login code is printed on the page
instead of being texted:

1. Go to **ورود / ثبت‌نام**, choose **کادر درمان**, enter **`09120000000`** (the admin phone).
2. Press **دریافت کد تأیید** → the 5-digit code appears in a green box on the page.
3. Enter it → you're in as **admin** (you'll see پنل مدیریت / تنظیمات in the nav).

> Kavenegar is never called in Development, even if SMS is toggled on.

## Test ingestion

1. Go to **پنل مدیریت → تنظیمات → منابع جمع‌آوری**.
2. Enable a source and fill its config, e.g. **مدجابز (medjobs.ir)** or **تلگرام** (channel
   usernames). For Telegram from inside Iran you'll need the proxy — tick **«از پروکسی استفاده شود»**
   under that source and set the proxy address (see `deploy/xray/README.md`); locally you can run
   your own Xray and point it at `socks5://host.docker.internal:PORT`.
3. Save, then trigger a run from **پنل مدیریت → صف آگهی‌ها** (Run-now), or set
   **«اجرای خودکار»** with a short interval.
4. Watch logs: `docker compose -f docker-compose.local.yml logs -f app`
   New items land in the review queue (Manual mode) or publish (Automatic mode).

## Inspect the database

Exposed on host port **5544** (5432/5433/5434 are used by other local containers):

```bash
docker exec -it hamkadr_local_db psql -U hamkadr -d hamkadr
```

## Stop / reset

```bash
docker compose -f docker-compose.local.yml down          # stop (keeps data)
docker compose -f docker-compose.local.yml down -v       # stop + wipe the DB volume
```

## Notes
- Host ports: app **18080**, Postgres **5544** (chosen to avoid clashing with your other
  local containers). Change them in `docker-compose.local.yml` if needed.
- If `mcr.microsoft.com` isn't reachable on your machine, edit `Dockerfile.local` and swap the
  two `FROM mcr.microsoft.com/dotnet/...` lines for `mirror.soroushasadi.com/dotnet/...`.
- Same for the Postgres image (`postgres:16-alpine` → `mirror.soroushasadi.com/postgres:16-alpine`).
