# Raspberry Pi 5 Docker Run

This repository now contains a Dockerized server path for Raspberry Pi 5.

Files used for this deployment:

- `Dockerfile.server`
- `docker-compose.rpi5.yml`
- `.env.example`
- `.env.server`

## What This Runs

- ASP.NET Core server from `src/Ikar.Server`
- SQLite database, attachments, update APKs, and secrets persisted under `/app/Data`
- host-side data path controlled by `IKAR_DATA_PATH`
- host-side backend port bound only to `127.0.0.1:5099`; external access should go through the reverse proxy and HTTPS domain

## Prerequisites On Raspberry Pi 5

1. Install Docker Engine using the official Docker docs: `https://docs.docker.com/engine/install/debian/`
2. Install Docker Compose plugin using the official Docker docs: `https://docs.docker.com/compose/install/`
3. Clone this repository onto the Raspberry Pi 5.
4. Create `.env` from `.env.example` and set `IKAR_DATA_PATH` to the desired host path.
5. Edit `.env.server` and replace `Jwt__SigningKey` before exposing the server outside your LAN.

## Start

Run from the repository root:

```bash
cp .env.example .env
docker compose -f docker-compose.rpi5.yml up -d --build
```

## Stop

```bash
docker compose -f docker-compose.rpi5.yml down
```

## Logs

```bash
docker compose -f docker-compose.rpi5.yml logs -f ikar-server
```

## Update After Pulling New Code

```bash
docker compose -f docker-compose.rpi5.yml up -d --build
```

## Verify

Health endpoint:

```bash
curl http://127.0.0.1:5099/health
```

Expected response:

```json
{"status":"ok"}
```

## Data Location

Docker bind mount:

- host: `${IKAR_DATA_PATH}`
- container: `/app/Data`

On the current Raspberry Pi 5 deployment, `IKAR_DATA_PATH` is set to `/media/myDrive/ikar-data`, which places the SQLite database, attachments, uploaded APK updates, and secrets on the external 1 TB disk instead of the SD card.

The following data stays persistent there:

- `ikar.db`
- `ikar.db-wal`
- `ikar.db-shm`
- `Attachments/`
- `AppUpdates/Android/`
- `secrets/firebase-admin.json`

## Client Access

For the current production deployment, clients should use the reverse-proxied HTTPS endpoint instead of direct access to port `5099`:

- Android / browser / admin: `https://ikar.kusoft.xyz`

Direct host access to `http://<pi-ip>:5099` is intentionally not exposed outside the Raspberry Pi loopback interface.

## Optional Firebase Push

If you want real Android FCM delivery:

1. Put the Firebase service account JSON onto the Raspberry Pi 5.
2. Set either `Push__ServiceAccountJsonPath` or `Push__ServiceAccountJson` in `.env.server`.
3. Set `Push__FirebaseProjectId` in `.env.server`.

If those values stay empty, device registration still works but actual FCM delivery is skipped by the server.
