diff --git a/README.md b/README.md index bfc41b3..8cc969a 100644 --- a/README.md +++ b/README.md @@ -65,22 +65,24 @@ A plain `go build -o bin/sondad ./cmd/sondad` needs no Node and gives the API on The image holds `sondad` with the web app inside, and nothing else: it builds the app itself, so you need no Node on your machine. It runs as an ordinary user, keeps the database and the files Sonda makes under `/data`, listens on port 8080 inside the container, and does not start without `SONDA_JWT_SECRET`. +The image is published on the registry of git.kmalloc.org, so you do not have to build it: `git.kmalloc.org/squid/sonda:latest` is the last one, and `git.kmalloc.org/squid/sonda:` (the first seven characters of a commit of `main`) is one you can stay on. Anyone can pull it, with no login. To build it yourself instead, run `docker build -t sonda .` and use `sonda` where the commands below say `git.kmalloc.org/squid/sonda:latest`. + ```bash -docker build -t sonda . +docker pull git.kmalloc.org/squid/sonda:latest (umask 077; echo "SONDA_JWT_SECRET=$(openssl rand -hex 32)" > sonda.env) # once: keep this file docker run -d --name sonda --restart unless-stopped --stop-timeout 15 \ -p 127.0.0.1:8080:8080 \ --env-file sonda.env \ -v sonda-data:/data \ -v "$HOME/Music":/music:ro \ - sonda + git.kmalloc.org/squid/sonda:latest ``` Mount your music read-only wherever you like (only if you want Sonda to delete duplicate files, mount it writable and set `SONDA_ALLOW_DELETE=true`: see **Duplicates**), then add the library through the API with the path *inside* the container, `/music` above (not the folder of your host): the [Demo](#demo) works the same way with `BASE=http://127.0.0.1:8080/api/v1`, except that step 4 creates the library with `"path":"/music"`. Keep `sonda.env` and pass it every time you run a new container, for example after an upgrade: a new secret signs out everybody. The container's health check asks the port in `SONDA_LISTEN`, so it works for `0.0.0.0`, `[::]` and a port alone, but not if you bind the server to one interface address. Published like this the server answers only on this machine; to serve your network, publish the port without `127.0.0.1:` and put a reverse proxy with https in front. The other settings are the environment variables of the [table below](#configure) (`SONDA_DB_DRIVER` and `SONDA_DB_DSN` for PostgreSQL); the image sets `SONDA_LISTEN`, `SONDA_DB_PATH` and `SONDA_DATA_DIR` for the volume. To keep the data in a folder of the host instead of a volume, run the container as the owner of that folder, or it cannot write there: add `--user "$(id -u):$(id -g)"` and `-v /path/to/sonda-data:/data`. Back up `sonda.db` (and treat the backup like a secret: it holds the API keys of the providers); the rest of `/data` is built from your music. -`compose.yaml` is the same as an example: put `SONDA_JWT_SECRET` and `MUSIC_DIR` (and `SONDA_PORT` if 8080 is taken) in a `.env` file next to it and run `docker compose up -d --build`. The image has a health check on `/api/v1/health`, which is logged at debug level when it succeeds. +`compose.yaml` is the same as an example: put `SONDA_JWT_SECRET` and `MUSIC_DIR` (and `SONDA_PORT` if 8080 is taken) in a `.env` file next to it and run `docker compose up -d --build` (to use the published image and not build one, swap the `build: .` and `image:` lines for the one in the comment of the file, and run `docker compose pull && docker compose up -d`). The image has a health check on `/api/v1/health`, which is logged at debug level when it succeeds. If you prefer a config file to environment variables (it can hold the secret and the other settings, so a Docker or Compose secret can provide it), put a `sonda.toml` in `/data` or pass `--config /run/secrets/sonda.toml`; the variables the image sets still win over the file. diff --git a/compose.yaml b/compose.yaml index 041bc88..bf456f3 100644 --- a/compose.yaml +++ b/compose.yaml @@ -6,6 +6,9 @@ # SONDA_PORT=8080 # optional, the port on this machine # # then: docker compose up -d --build +# +# To use the image that is published, and not build one: delete the two lines "build: ." and "image: sonda:local" below, +# put "image: git.kmalloc.org/squid/sonda:latest" in their place, and run: docker compose pull && docker compose up -d services: sonda: build: .