# Deployment

## Platforms

### Kubernetes (ArgoCD)

Primary production deployment target. Manifests in `k8s/`.

<!-- TODO: Document cluster topology, resource requirements, scaling strategy -->

### Fly.io

Alternative deployment option. Configuration in `fly.toml`.

<!-- TODO: Document Fly.io deployment steps -->

### Docker

Multi-stage Docker build (`Dockerfile`).
- Build stage: Elixir compilation + asset bundling
- Release stage: Minimal runtime with Erlang/Elixir release

## Release Management

### Building

```bash
MIX_ENV=prod mix assets.deploy
mix release
```

### Database Migrations

`Aprsme.Release` module handles migrations during release startup.

<!-- TODO: Document migration strategy (rolling updates, advisory locks) -->

## Environment Configuration

Configuration files in `config/`:
- `config.exs` — Base configuration
- `dev.exs` — Development overrides
- `prod.exs` — Production defaults
- `runtime.exs` — Runtime configuration (from env vars)

### Key Environment Variables

<!-- TODO: Document required env vars (DATABASE_URL, SECRET_KEY_BASE, APRS_IS credentials, etc.) -->

## Development Environment

### Nix Shell

Nix-based reproducible dev environment via `flake.nix` / `shell.nix`. Provides Elixir, Erlang, PostgreSQL, and all tooling.

### Dev Containers

`.devcontainer/` configuration for VS Code / GitHub Codespaces.

## Clustering

Optional multi-node deployment via `libcluster`:
- Leader election determines which node maintains APRS-IS connection
- Packet distribution relayed across nodes
- Configuration in cluster modules under `lib/aprsme/cluster/`

## Health Checks

- `/health` — Kubernetes liveness (basic) and readiness (DB + PubSub, shutdown-aware)
- `/ready` — App readiness check
- `/status.json` — JSON status endpoint

Handled by `HealthCheck` plug before router.
