# Docker

The image `ghcr.io/openkedai/openkedai` runs on `linux/amd64` and `linux/arm64` (Raspberry Pi
4/5, ARM servers, most NAS boxes). Everything the hub keeps is in `/data`.

## With Docker Compose (recommended)

```sh
mkdir openkedai && cd openkedai
curl -fsSLO https://raw.githubusercontent.com/OpenKedai/openkedai/main/deploy/compose.yaml
docker compose up -d
docker compose logs openkedai | grep "Setup code"
```

Then open `http://<this machine's address>:8080` and choose **Set up a new shop**.

The compose file uses **host networking**, so devices on the shop's network find the hub on their
own (mDNS) and pairing QR codes carry this machine's real address. Host networking works on Linux.
On Docker Desktop (Mac, Windows), edit `compose.yaml`: remove `network_mode: host`, uncomment
`ports`, and set `OPENKEDAI_PUBLIC_URL` to the computer's address (e.g. `http://192.168.1.20:8080`).

Settings go under `environment:` in `compose.yaml`; see [Configuration](https://docs.openkedai.com/self-hosting/configuration/). After
a change: `docker compose up -d`.

## With docker run

```sh
docker run -d --name openkedai --restart unless-stopped \
  --network host -v openkedai-data:/data \
  ghcr.io/openkedai/openkedai:latest
```

On a server where devices connect over the internet, publish the port instead and say where the
hub is reached:

```sh
docker run -d --name openkedai --restart unless-stopped \
  -p 8080:8080 -v openkedai-data:/data \
  -e OPENKEDAI_PUBLIC_URL=https://pos.example.my \
  ghcr.io/openkedai/openkedai:latest
```

## Updating

```sh
docker compose pull && docker compose up -d
```

Tags: `latest`, a minor version such as `0.9` (patch updates only), or an exact version such as
`0.9.0`. Pin one of the last two if you prefer to update on your own schedule.

## Backups and files

Snapshots are in the volume's `backups/` folder. To copy them out:

```sh
docker run --rm -v openkedai-data:/data -v "$PWD":/out alpine cp -r /data/backups /out/
```

See [Backups](https://docs.openkedai.com/self-hosting/backups/) for copying them to S3-compatible storage and for restoring.

## Building the image yourself

From a clone of the repository:

```sh
docker build -f deploy/Dockerfile -t openkedai .
```

The image runs as the unprivileged `node` user, with no source maps loaded (they cost about
75 MB of memory). For readable stack traces while debugging, add
`-e NODE_OPTIONS=--enable-source-maps`.
