Deploying Vigil
Vigil ships as one OCI image (Dockerfile): a Debian runner with the
release under /app, running as nobody under tini, started by
bin/server. CI builds and pushes it on every push to main
(.forgejo/workflows/image.yml). It needs Postgres (17; no extensions) and
nothing else. The three Rust NIFs are built from source into the release,
and the runner image carries no extra system libraries for them.
docker build -t vigil .
docker run --rm -e DATABASE_URL=... -e SECRET_KEY_BASE=... vigil /app/bin/migrate
docker run -p 4000:4000 -v vigil-storage:/data/storage \
-e DATABASE_URL=... -e SECRET_KEY_BASE=... -e PHX_HOST=vigil.example.com vigil
Release commands
All under /app/bin/ in the image (rel/overlays/bin/):
| Command | What |
|---|---|
server |
Starts the app (sets PHX_SERVER=true). The image’s default command |
migrate |
Runs the migrations. Run it before a new version’s server starts |
invite [--email E] [--note T] [--days N] [--by E] |
Prints a registration invite link. The first account is made this way while registration is closed |
invite-link EMAIL |
Prints a fresh link for the newest active invite to EMAIL |
token EMAIL LABEL SCOPE[,SCOPE...] |
Makes an API token for an existing user (for sentry-cli and similar) and prints it once. mix vigil.token in development |
Scopes are org:read org:write org:admin org:integrations member:read member:write member:admin team:read team:write team:admin project:read project:write project:admin project:releases event:read event:write event:admin. In each organization a token is narrowed to the user’s role
there.
Health
The image’s HEALTHCHECK fetches GET /_health/ on 127.0.0.1:$PORT, with
Host: localhost so the HTTPS redirect leaves it alone. Point liveness
probes there.
Environment
Required (prod)
| Variable | |
|---|---|
DATABASE_URL |
ecto://USER:PASS@HOST/DATABASE |
SECRET_KEY_BASE |
64+ random bytes: mix phx.gen.secret |
PHX_HOST |
The public hostname. URLs and DSNs are built as https://PHX_HOST. Default example.com, which is never right |
Web and database
| Variable | Default | |
|---|---|---|
PORT |
4000 |
HTTP listen port. TLS is terminated in front of Vigil |
POOL_SIZE |
10 |
Postgres connections per node |
ECTO_IPV6 |
off | true to reach Postgres over IPv6 |
REGISTRATION_OPEN |
false |
true lets anyone sign up; otherwise sign-up needs an invite |
VIGIL_ORG_GROUP_RULES |
unset | Org membership from identity-provider groups: org:group:role[:provider],... |
Storage
Uploaded files (source maps, artifact bundles) go to local disk unless
S3_BUCKET is set.
| Variable | Default | |
|---|---|---|
VIGIL_STORAGE_ROOT |
/data/storage in the image (storage/ otherwise) |
Local storage root. The image declares a volume there; with several replicas it must be shared (or use S3) |
S3_BUCKET |
unset | Switches storage to an S3-compatible bucket. The rest are then required, except S3_REGION |
S3_ENDPOINT |
e.g. https://s3.us-west-004.backblazeb2.com |
|
S3_REGION |
us-east-1 |
|
S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY |
Login links, account emails and alert emails. Without SMTP_RELAY, mail
is only logged (Swoosh’s Logger adapter at info), so nothing is sent but
the pod log shows what would have been.
| Variable | Default | |
|---|---|---|
SMTP_RELAY |
unset | The relay’s hostname. Setting it turns SMTP on |
SMTP_PORT |
587 |
|
SMTP_USERNAME, SMTP_PASSWORD |
unset | |
SMTP_TLS |
if_available |
STARTTLS: always, if_available or never |
SMTP_SSL |
false |
true for implicit TLS (port 465) |
SMTP_AUTH |
if_available |
always, if_available or never |
SMTP_TLS_VERIFY |
verify_peer |
verify_none for a self-signed private relay |
SMTP_CACERTFILE |
/etc/ssl/certs/ca-certificates.crt |
Fallback CA bundle when the OS store can’t be loaded |
MAIL_FROM_ADDRESS |
noreply@PHX_HOST |
Sender of every email |
MAIL_FROM_NAME |
Vigil |
TLS is pinned to 1.2 and 1.3 and the peer is verified against the OS CA
store; see the comments in config/runtime.exs.
Clustering
Replicas work unclustered: ingest is stateless apart from a per-node key cache, which then lags a key, project or organization change by up to 30 seconds on the other nodes. Clustered, Phoenix PubSub spans the nodes, so such changes flush every node’s cache at once and live updates reach users wherever they are connected. Ingest rate limits are counted per node either way, so with N replicas a key can take up to N times its limit.
| Variable | Default | |
|---|---|---|
POD_IP |
unset | Turns on libcluster’s Kubernetes strategy, and names the node vigil@POD_IP (rel/env.sh.eex). Set it from the downward API (status.podIP) |
POD_NAMESPACE |
vigil |
Where to look for peers |
CLUSTER_SELECTOR |
name=vigil |
Label selector for the peer pods. The service account needs list on pods |
CLUSTER_SERVICE |
vigil-headless |
Headless Service name |
RELEASE_COOKIE |
generated at image build | Must be the same on every replica; set it from a Secret rather than rely on the baked-in one |
DNS_CLUSTER_QUERY |
unset | Alternative to libcluster: cluster by DNS (dns_cluster) |
With POD_IP set, the Erlang distribution listens on port 9100 only.
Sign in with NEIAM (OIDC)
Off unless OIDC_ENABLED=true. OIDC_LOGIN_MODE, PUBLIC_URL,
OIDC_PROVIDERS and the per-provider OIDC_* variables are neiam_auth’s;
see its README (deps/neiam_auth/README.md).