# Install on one Linux server

Run HelixIAM in production on one Linux server with Docker Compose, without Kubernetes. The install bundle provided
with your licence, `helixiam-linux-server.tar.gz`, holds everything:

- **a TLS front door (Caddy)** on ports 80 and 443, with your own certificate or one from Let's Encrypt;
- **the server and the dashboard**, the same signed images as on Kubernetes;
- **PostgreSQL 16**, or your own PostgreSQL.

It uses two host names:

| Host name | Example | For |
| --- | --- | --- |
| Sign-in host | `id.example.com` | Users and applications: sign-in, OpenID Connect, SAML, the account console. |
| Admin host | `admin.example.com` | Administrators only: the dashboard, the admin API and the `master` realm. |

The admin API and the `master` realm answer `404` on the sign-in host. The admin host answers only for the addresses
you allow. Health and metrics are never published.

!!! info "Requires a HelixIAM licence"
    The bundle and the images are delivered to licensed customers: you receive registry credentials and the release
    files from KubeDNA B.V. For a licence, contact [contact@helixiam.com](mailto:contact@helixiam.com).

!!! info "Tested setup"
    This guide was followed as written on a new Hetzner cloud server with 2 vCPU and 4 GB of memory, Ubuntu 24.04,
    Docker Engine 29.10 and Compose 5.7, with a Let's Encrypt certificate and with an own certificate: install, sign-in
    with a second factor, a realm with an application and its tokens, the admin restrictions, an upgrade, a backup and
    restore, and a reboot. During the upgrade sign-in was unavailable for about 20 seconds; after a reboot it was back
    within a minute.

!!! note "One server, no failover"
    One server has no failover: when it is down, sign-in is down. For high availability run HelixIAM on Kubernetes
    with the [Helm chart](install.md#kubernetes-helm) (see [High availability](../operations/high-availability.md)).

## Requirements

- **A Linux server, x86-64 (amd64) or ARM64 (arm64),** with at least 2 vCPU, 4 GB of memory and 40 GB of disk. From
  1.1.0 every HelixIAM image is built for both, under one tag.
- **Docker Engine 24 or later with the Compose plugin 2.20 or later** (`docker compose version`). Install it from
  [Docker's packages for your distribution](https://docs.docker.com/engine/install/).
- **Two DNS names** pointing at the server, for the sign-in host and the admin host.
- **Ports 80 and 443** free on the server and reachable by your users. Port 80 only redirects to HTTPS (and answers
  Let's Encrypt's challenge).
- **Outbound HTTPS to `ghcr.io`** to pull the images (or a registry mirror you load them into).
- **The JDBC driver of your database**: one jar, from Maven Central or your mirror (step 5). HelixIAM ships none.
- **A TLS certificate** valid for both names, or a server that Let's Encrypt can reach on ports 80 and 443.
- **An SMTP server** for verification and password-reset emails.

## Install

**1. Unpack the bundle,** for example in `/opt`; it creates `/opt/helixiam`. If it came with a `.sigstore.json` file,
verify it first (see [Verify the release files](#verify-the-release-files)).

```bash
sudo tar -xzf helixiam-linux-server.tar.gz -C /opt --no-same-owner
cd /opt/helixiam
```

**2. Create `.env`** from the example and make it readable by root only. It holds the database password and the
encryption key.

```bash
sudo cp .env.example .env
sudo chmod 600 .env
```

**3. Fill in `.env`.** Every setting has a comment. The ones you must set:

| Setting | Set it to |
| --- | --- |
| `HELIX_IDP_HOST` | The sign-in host name, for example `id.example.com`. |
| `HELIX_ADMIN_HOST` | The admin host name, for example `admin.example.com`. |
| `HELIX_ADMIN_ALLOW` | Who may open the admin host: IP addresses or CIDR ranges, separated by spaces, for example your office and VPN ranges. Others get `403`. |
| `HELIX_TLS` | `files` (your own certificate), `acme` (Let's Encrypt) or `internal` (test certificate, for a trial only). |
| `DB_PASSWORD` | A new random password: `openssl rand -hex 24`. |
| `DB_ENCRYPTION` | The key that encrypts secrets in the database: `openssl rand -hex 16`. |
| `HELIX_SMTP_HOST`, `HELIX_SMTP_PORT`, `HELIX_SMTP_USERNAME`, `HELIX_SMTP_PASSWORD`, `HELIX_SMTP_TLS_MODE`, `HELIX_SMTP_FROM` | Your SMTP server, account and sender address. |

!!! danger "Keep DB_ENCRYPTION safe, and never change it"
    `DB_ENCRYPTION` encrypts secrets in the database. Without the exact same key a backup cannot be read. Store a copy
    apart from your backups, in your password vault, and never change it.

**4. Add the certificate** (with `HELIX_TLS=files`). Put the certificate with its full chain and its key in `certs/`.
The certificate must be valid for both host names.

```bash
sudo cp fullchain.pem certs/tls.crt
sudo cp privkey.pem certs/tls.key
sudo chmod 644 certs/tls.crt
sudo chmod 600 certs/tls.key
```

With `HELIX_TLS=acme`, Caddy requests and renews the certificates from Let's Encrypt itself; both host names must be
reachable from the internet on ports 80 and 443.

**5. Add the JDBC driver.** The bundle's `drivers/` folder is empty: put the one jar of your database's driver in
it, checked and read-only. For the bundled PostgreSQL (for MySQL, the jar of
[the table](../operations/database-driver.md#the-drivers-of-this-release)):

```bash
cd "$(mktemp -d)" &&
  curl -fLO https://repo1.maven.org/maven2/org/postgresql/postgresql/42.7.14/postgresql-42.7.14.jar &&
  echo "73914527305a40cce504b0d3d90b23caf565136912d607ae8ae7c5895512332c  postgresql-42.7.14.jar" | sha256sum -c &&
  sudo cp postgresql-42.7.14.jar /opt/helixiam/drivers/ &&
  sudo chmod 0444 /opt/helixiam/drivers/postgresql-42.7.14.jar &&
  sudo chmod 0555 /opt/helixiam/drivers
cd /opt/helixiam
```

`sha256sum -c` prints `postgresql-42.7.14.jar: OK`; on `FAILED` the chain stops before the copy. The server refuses
a missing, writable, second or untested jar, naming it: see
[What the server says](../operations/database-driver.md#12-what-the-server-says).

**6. Start HelixIAM.** Log in to the registry with the credentials of your licence, then start. The first start takes
a few minutes: it creates the database schema.

```bash
sudo docker login ghcr.io
sudo docker compose up -d --wait
sudo docker compose ps
```

`server`, `console` and `postgres` show `healthy`, and `caddy` shows `Up`.

**7. Sign in.** The first start creates the administrator `admin` with a generated password. It is never logged:
read it once from the server.

```bash
sudo docker compose exec server cat /tmp/helixiam-admin-password
```

Open `https://<admin host>`, sign in as `admin` and set up the second factor (an authenticator app). Then change the
password. To choose the first password yourself instead, set `HELIX_ADMIN_PASSWORD` in `.env` before the first start.

**8. Check from the outside.** From a machine outside the admin allow-list:

```bash
curl -s https://id.example.com/realms/master/.well-known/openid-configuration -o /dev/null -w '%{http_code}\n'   # 404
curl -s https://admin.example.com/ -o /dev/null -w '%{http_code}\n'                                              # 403
```

Next, create a realm and an application: see [Core concepts](concepts.md) and the
[OIDC quickstart](../integration/oidc-quickstart.md). Applications use the sign-in host, for example
`https://id.example.com/realms/<realm>` as issuer.

## Your own PostgreSQL

To use a PostgreSQL 16 you already run, in `.env`:

1. delete the line `COMPOSE_PROFILES=bundled-db`;
2. set `DB_HOST`, and `DB_PORT`, `DB_NAME` and `DB_USERNAME` where they differ from the defaults;
3. set `DB_SSLMODE=verify-full` and mount the CA that signed the database's certificate (see
   [Database TLS](install.md#database-tls)).

Create the database and its owner first; HelixIAM creates and migrates its own schema.

## Settings not in `.env`

Server settings that `.env` does not cover go in `config/helixiam.yaml`, which the server loads if it exists, for
example a [key custody backend](../operations/key-custody.md). Restart the server after a change:

```bash
sudo docker compose up -d --wait server
```

For a Thales Luna HSM, see [Set up without Kubernetes](../operations/thales-luna.md#set-up-without-kubernetes): add
its volumes to a `docker-compose.override.yml` next to `docker-compose.yml`, which Compose reads automatically.

Do not edit `docker-compose.yml` itself: an upgrade replaces it.

## Backup and restore

Back up three things:

- **the database,** daily, with `pg_dump`;
- **`.env`,** which holds `DB_ENCRYPTION`: keep it apart from the database dumps;
- **`certs/` and `config/`,** if you use them.

```bash
cd /opt/helixiam
sudo docker compose exec -T postgres sh -c 'pg_dump -U "$POSTGRES_USER" -d "$POSTGRES_DB" -Fc' > helixiam-$(date +%F).dump
```

Run it from cron or a systemd timer and copy the dump off the server. With your own PostgreSQL, use your usual
database backups instead.

To restore, on an empty install with the same `.env`:

```bash
sudo docker compose up -d --wait postgres
sudo docker compose exec -T postgres sh -c 'pg_restore -U "$POSTGRES_USER" -d "$POSTGRES_DB" --no-owner' < helixiam-<date>.dump
sudo docker compose up -d --wait
```

See [Backup & disaster recovery](../operations/backup.md) for realm exports and recovery times.

## Upgrade

1. Read the [breaking changes](../operations/upgrades.md#breaking-changes) between your version and the new one.
2. Take a backup (above).
3. Unpack the new bundle over the old one. It replaces `docker-compose.yml`, `Caddyfile` and `.env.example`, and
   leaves your `.env`, `certs/`, `config/` and the driver in `drivers/` alone. When the new release is tested with
   another driver version ([the table](../operations/database-driver.md#the-drivers-of-this-release) of its docs),
   replace the jar in `drivers/` as in step 5 of the install.
4. Set `HELIX_VERSION` in `.env` to the new release, and add any new settings from `.env.example`.
5. Pull and restart. The server migrates the database schema at start-up.

```bash
sudo tar -xzf helixiam-linux-server.tar.gz -C /opt --no-same-owner
sudo docker compose pull
sudo docker compose up -d --wait
```

Sign-in is down while the server restarts, usually under a minute. Then check it as in
[Verify the upgrade](../operations/upgrades.md#verify-the-upgrade).

## Logs and health

- **Status:** `sudo docker compose ps` shows each service and whether it is healthy.
- **Logs:** `sudo docker compose logs -f server` (JSON, one line per event). The bundle keeps 5 files of 50 MB per
  service. The audit trail is in the server log and in the console under **Audit**.
- **Restarts:** every service restarts by itself after a failure or a reboot of the server, as long as Docker starts
  at boot (`sudo systemctl enable docker`).

## Verify the release files

Each release file comes with a Sigstore bundle. With [cosign](https://docs.sigstore.dev/cosign/system_config/installation/):

```bash
cosign verify-blob --bundle helixiam-linux-server.tar.gz.sigstore.json \
  --certificate-identity https://github.com/melmarzgioui/helixiam/.github/workflows/release.yml@refs/tags/v<version> \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com helixiam-linux-server.tar.gz
```

## Troubleshooting

| Symptom | Cause and fix |
| --- | --- |
| `Pool overlaps with other one on this address space` at start | The bundle's network (`10.213.70.0/24`) overlaps a Docker network on the server. Set `HELIX_SUBNET` in `.env` to a free `/24`. |
| `port is already allocated` | Another service uses port 80 or 443. Stop it, or set `HELIX_HTTP_PORT` / `HELIX_HTTPS_PORT` and put your own proxy in front. |
| `no matching manifest for linux/arm64` | The server is ARM and `HELIX_VERSION` names a release before 1.1.0, which had amd64 images only. Use 1.1.0 or later. |
| `password authentication failed` in the server log | `DB_PASSWORD` changed after the first start. The bundled database keeps the first password: set it back. |
| The browser shows a certificate warning | `HELIX_TLS=internal`, or `certs/tls.crt` does not cover the host name. Use `files` or `acme`. |
| `403` on the admin host | Your address is not in `HELIX_ADMIN_ALLOW`. Add it and run `sudo docker compose up -d caddy`. |
| `404` for the dashboard or `/realms/master` on the sign-in host | Expected: the admin side answers only on the admin host. |
