# Images and license key

How the Cohorly images and your license key reach you under contract, three ways to get the images onto your host, where the key goes, and the exact messages the server prints when it refuses to start.

## Getting the images

The server and dashboard images and your license key arrive with your
contract. The same message gives you what you need for the way you will get
the images: the registry address, namespace and a credential, or a link to the
offline package. Nothing here works without them: the images are not available
from a public registry, and there is no anonymous `docker pull`.

The examples on this page use `registry.example.com/cohorly` as the registry
address and namespace. Use the values from your contract.

**Tags.** A tag is the version without a `v`, for example `1.0.0`. The `latest`
tag only moves to the newest stable version; a pre-release such as
`1.1.0-rc.1` gets only its own tag. Pin a version in `.env` instead of using
`latest`, so that a restart never changes what runs. The examples use `1.0.0`:
replace it with the version you were given.

Pick one of three ways to get the images.

### A. Pull from the Cohorly registry

Log in with the credential from your contract:

```bash
docker login registry.example.com
```

Then, in the `.env` file you create in [Install](/self-hosting/install):

```
COHORLY_SERVER_IMAGE=registry.example.com/cohorly/cohorly-server
COHORLY_DASHBOARD_IMAGE=registry.example.com/cohorly/cohorly-dashboard
COHORLY_IMAGE_TAG=1.0.0
```

and start the stack with `docker compose pull server error-worker dashboard && docker compose up -d --no-build`.

### B. Copy the images to your own registry

If your hosts pull only from your own registry, copy both images once, keeping
both architectures. Log in to both registries first:

```bash
docker login registry.example.com
docker login my-registry.example.com

docker buildx imagetools create \
  --tag my-registry.example.com/cohorly-server:1.0.0 \
  registry.example.com/cohorly/cohorly-server:1.0.0
docker buildx imagetools create \
  --tag my-registry.example.com/cohorly-dashboard:1.0.0 \
  registry.example.com/cohorly/cohorly-dashboard:1.0.0
```

Point `.env` at your registry, and pull only the three Cohorly services,
`docker compose pull server error-worker dashboard`: a plain
`docker compose pull` also tries to refresh `postgres` and `caddy` from Docker
Hub, which fails when the host cannot reach it.

`.env`:

```
COHORLY_SERVER_IMAGE=my-registry.example.com/cohorly-server
COHORLY_DASHBOARD_IMAGE=my-registry.example.com/cohorly-dashboard
COHORLY_IMAGE_TAG=1.0.0
```

The stack also runs two third-party images that the compose file names without
a variable: `postgres:17-alpine` and `caddy:2.11.9-alpine`. If the host cannot reach
Docker Hub, pull them from your mirror and give them those names, for example:

```bash
docker pull my-registry.example.com/postgres:17-alpine
docker tag my-registry.example.com/postgres:17-alpine postgres:17-alpine
```

and the same for `caddy:2.11.9-alpine`. Alternatively, set `registry-mirrors` in the
Docker daemon's `daemon.json`.

### C. Offline package

For a host with no internet access, the link in your contract gives you
`cohorly-1.0.0-linux-amd64.tar.gz` (or `-arm64`, for an Arm host) and a file
named `SHA256SUMS`. Download both, check the package against the checksum, and
load it:

```bash
sha256sum -c --ignore-missing SHA256SUMS
docker load < cohorly-1.0.0-linux-amd64.tar.gz
```

The package holds the four images of the stack: server, dashboard, PostgreSQL
and Caddy. `docker load` prints a `Loaded image:` line for each. Set
`COHORLY_SERVER_IMAGE` and `COHORLY_DASHBOARD_IMAGE` in `.env` to the
repository names it printed for the server and the dashboard, without the tag,
and `COHORLY_IMAGE_TAG` to the version. Then start without `pull`, because
there is no network:

```bash
docker compose up -d --no-build
```

Without internet access, Caddy cannot get a Let's Encrypt certificate for a
public domain: the containers start, but HTTPS does not work for that name.
Setting `COHORLY_DOMAIN=localhost` makes Caddy sign with its own internal
certificate authority, which needs no network, and browsers must then trust
that authority's root certificate (kept in the `selfhost-caddy-data` volume).
The compose file cannot take a certificate of your own yet, so serving
other machines over trusted HTTPS from a host with no internet access is not
covered by this guide.

The license key is required in all three cases.

## License key

The server and the error worker check your license key once, when they start.
Set one of these in `.env`:

- `COHORLY_LICENSE_KEY`: the key itself, in the form
  `cohorly-license.v1.<payload>.<signature>` (a v2 key,
  `cohorly-license.v2.<payload>.<signature>.<signature>`, is about 4,700
  characters on one line: paste it whole).
- `COHORLY_LICENSE_KEY_FILE`: the path, inside the containers, of a file that
  holds the key. When both are set, the file wins. A file that cannot be read
  stops the start; the server never falls back to the variable.

To use a file, mount it into both services with a `docker-compose.override.yml`
next to `docker-compose.yml` (Compose reads it automatically):

```yaml
services:
  server:
    volumes:
      - ./cohorly.license:/run/secrets/cohorly.license:ro
  error-worker:
    volumes:
      - ./cohorly.license:/run/secrets/cohorly.license:ro
```

and set `COHORLY_LICENSE_KEY_FILE=/run/secrets/cohorly.license` in `.env`.

What the check does:

- **It is offline.** The image carries the public key that verifies your key,
  and the date it was released (`/app/release.json`). Nothing is sent
  anywhere.
- **It covers releases up to a date.** The key holds an `updatesUntil` date,
  the last release date it covers. It runs every image released up to that
  date. An image released later refuses to start: keep running the previous
  version, or renew.
- **It never stops a running instance on a date.** An instance that is
  running, or restarted from an image the key covers, keeps working after
  `updatesUntil` has passed. `GET /api/usage` reports the license with a
  `status`: `current`, `expiring` (30 days or fewer left) or `expired`, with
  `customerName`, `updatesUntil` and `releaseDate`.
- **It runs only at start.** After you change the key, recreate the
  containers: `docker compose up -d` does it when `.env` has changed.
- **The key is never written to the logs.**

The org owner sees the license in the dashboard, under **Settings > Billing**:
until when this installation gets updates, the installed release and the
customer the key was issued to. Members do not see that tab. The screen only
shows the key's state, it never changes it: to change the key, set the new
one as above and restart the containers.

A refused start exits with one of these lines, shown by
`docker compose logs server` (the error worker prints the same lines). The
server also writes the same message as a JSON log line with `"level":60`:

| Message                                                                                                                   | What to do                                                                                                |
| ------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| `Cohorly self-host needs a license key: set COHORLY_LICENSE_KEY or COHORLY_LICENSE_KEY_FILE`                              | Set one of them.                                                                                          |
| `Cohorly license key has an invalid format: expected cohorly-license.v1.<payload>.<signature>`                            | The key was cut or altered when it was pasted. The line can end with a detail in parentheses.             |
| `Cohorly license key has an invalid format: expected cohorly-license.v2.<payload>.<signature>[.<signature>]`              | The same, for a key that starts with `cohorly-license.v2.`.                                               |
| `Cohorly license key has an invalid signature: it was not issued for this image`                                          | The key was not issued for these images, or it was edited. The line can end with a detail in parentheses. |
| `Cohorly license does not cover this image: this license covers releases up to <date>; this image was released on <date>` | Run an image released up to the first date, or renew the license.                                         |
| `Cohorly could not read COHORLY_LICENSE_KEY_FILE (<path>): <error>`                                                       | Check the mount and the path.                                                                             |
| `This Cohorly image has no release.json, so it cannot check a license key: run a published Cohorly self-host image`       | The image was not built by Cohorly. Use the delivered images.                                             |
| `This Cohorly image has an invalid release.json: <problem>` or `This Cohorly image could not read release.json: <error>`  | The image is damaged or was altered. Pull or load it again.                                               |
| `This Cohorly image is built for self-hosting: set COHORLY_DEPLOYMENT_MODE=self-host`                                     | A delivered image was started in `cloud` mode. The compose file sets `self-host`; do not override it.     |
