# Docker Deployment (Quickstart)

OnCallAlert runs as a single lightweight container backed by a PostgreSQL database (version 16 or newer). The server listens on `0.0.0.0:8080` inside the container and automatically initializes its database tables on startup.

## Prerequisites

- Docker Engine 20.10+ or Docker Compose
- PostgreSQL 16+ with the `pgcrypto` extension installed

## 1. Start the Server

Run the official image `oncallalert/oncallalert:latest` from Docker Hub:

```bash
docker run -d \
  --name oncallalert \
  --restart unless-stopped \
  -p 8080:8080 \
  -e ONCALLALERT_DB_URL="postgres://user:password@your-postgres:5432/oncallalert?sslmode=require" \
  -e ONCALLALERT_PUBLIC_URL="https://oncall.yourcompany.com" \
  -e ONCALLALERT_DATA_ENCRYPTION_KEY="a-long-random-secret" \
  oncallalert/oncallalert:latest
```

### Environment Variables Used

- `ONCALLALERT_DB_URL`: Connection URI to your PostgreSQL instance.
- `ONCALLALERT_PUBLIC_URL`: Externally accessible URL where responders and webhooks access your server.
- `ONCALLALERT_DATA_ENCRYPTION_KEY`: Secret string used to encrypt credentials at rest. Keep this value identical across restarts and upgrades.

## 2. Create the First Administrator

Because there is no open sign-up page, provision the initial administrator using the CLI inside the running container:

```bash
docker exec -it oncallalert oncallalert add-user \
  --user admin \
  --email admin@yourcompany.com \
  --admin
```

The command prompts for a secure password. You can also supply `--pass "<password>"` non-interactively.

## 3. Configure Single Sign-On (OIDC)

OnCallAlert supports OpenID Connect (OIDC) authentication using Google or GitHub. Configure OIDC client credentials in the admin settings page (`/admin/config`). Users can then authenticate directly using their corporate single sign-on accounts.

## 4. Sign In and Activate License

1. Navigate to your configured public URL (e.g., `https://oncall.yourcompany.com`).
2. Sign in with the administrator account created in step 2.
3. On the **Activate OnCallAlert** prompt, paste your license key.
4. Once activated, alert intake is opened, and all platform features become accessible.

## Health Check Endpoint

Monitor server health using the built-in HTTP health check:

```bash
curl -f http://localhost:8080/healthz
```
