# Nagenli in Docker

For a computer that already runs Docker (Linux, 64-bit Intel/AMD or ARM). Host networking, which lets phones and TVs
find the server by themselves, works on Linux only.

## Start

1. Make a folder and get the files into it:

       mkdir nagenli && cd nagenli
       curl -fsSL https://nagenli.com/docker/nagenli-docker.tar.gz | tar xz

2. In `compose.yaml`, change the two `/path/to/...` lines to your video folders (keep `:ro`: Nagenli never writes
   to them), and set `PUID` and `PGID` to the numbers from `id -u` and `id -g`.
3. Run `docker compose up -d --build`.

The first start downloads Nagenli and checks it; give it a minute. Then open `http://<this computer>:8686` from a
phone, TV or another computer at home, or `http://localhost:8686` on the computer itself. In the app, add your
folders as `/media/films` and `/media/shows` (the paths inside the container).

## Change settings from another device

Settings open on the server computer itself, or on another device at home with a one-time code:

    docker exec nagenli /data/bin/nagenli -owner-code

Type the code in Settings on that device. It works for 10 minutes.

## Updates

By default Nagenli updates itself and restarts inside the container; nothing else to do. `docker compose pull` is never
needed. The program lives in `nagenli-data`, so it stays updated when the container is re-created. Rebuilding the image
only refreshes the small base system around it.

To update only when you decide: open Settings (on the server computer, or on another device with the code above) and
turn off automatic updates. Nagenli then never installs a new version by itself; Settings shows when one is available,
with an Update button. Pressing it downloads and checks the new version, backs up your data, replaces the program and
restarts it, within a minute or so. To have it off from the start, uncomment `NAGENLI_AUTO_UPDATE: "off"` in `compose.yaml`;
then Settings shows automatic updates as off and Nagenli never installs a version by itself.

## Back up

Stop the container (`docker compose stop`) and copy the `nagenli-data` folder. That is everything: settings, library,
watch progress, and the program. Put it back the same way. Nagenli also keeps its own backups inside it.

## If something fails

- `docker logs nagenli` shows what the container did; the program's own log is `nagenli-data/config/nagenli.log`.
- If the program file `nagenli-data/bin/nagenli` is damaged, delete just that file and start again: it is fetched
  again and your data is not touched.
- No host networking (Docker Desktop, some NAS)? See the commented `ports:` block in `compose.yaml` and what it costs.
- Video encoding on a graphics card is optional; see the commented blocks in `compose.yaml`.

## Remove

    docker compose down

This leaves your data. To remove it as well, delete the `nagenli-data` folder. Your video folders are never changed.
