5.6 KiB · text History 98ad9a4
# This file is responsible for configuring your application
# and its dependencies with the aid of the Config module.
#
# This configuration file is loaded before any dependency and
# is restricted to this project.

# General application configuration
import Config

config :vigil, :scopes,
  user: [
    default: true,
    module: Vigil.Accounts.Scope,
    assign_key: :current_scope,
    access_path: [:user, :id],
    schema_key: :user_id,
    schema_type: :binary_id,
    schema_table: :users,
    test_data_fixture: Vigil.AccountsFixtures,
    test_setup_helper: :register_and_log_in_user
  ]

config :vigil,
  ecto_repos: [Vigil.Repo],
  generators: [timestamp_type: :utc_datetime, binary_id: true]

# Registration is invite-only, as the sibling apps: a registration invite
# (the Invites page, `mix vigil.invite`, the release's `bin/invite`).
# REGISTRATION_OPEN=true (runtime.exs) lets anyone sign up.
config :vigil, :registration_open, false

# "Sign in with NEIAM" (OIDC), as the sibling apps. Inert until
# OIDC_ENABLED=true; providers and the login mode come from OIDC_* env,
# read at start (see the neiam_auth README).
config :neiam_auth,
  repo: Vigil.Repo,
  user_schema: Vigil.Accounts.User,
  adapter: Vigil.NeiamAuthAdapter

# Background work, all of it (ROADMAP.md, Architecture). Queues are sized
# per kind of work; crontab entries are added by the slices that need them.
config :vigil, Oban,
  engine: Oban.Engines.Basic,
  repo: Vigil.Repo,
  queues: [default: 10, ingest: 10, processing: 5, notify: 10, checks: 20, maintenance: 1],
  plugins: [
    {Oban.Plugins.Pruner, max_age: 60 * 60 * 24 * 7},
    {Oban.Plugins.Lifeline, rescue_after: :timer.minutes(30)},
    {Oban.Plugins.Cron,
     crontab: [
       # Partitions ahead of time for the partitioned tables (Vigil.Partitions).
       {"17 3 * * *", Vigil.Partitions.MaintainWorker},
       # Alert rules against the issues events touched (Vigil.Alerts).
       {"* * * * *", Vigil.Alerts.EvaluateWorker},
       # Cron monitors: missed check-ins and timed-out runs (Vigil.Monitors).
       {"* * * * *", Vigil.Monitors.TickWorker},
       # Uptime checks whose self-rescheduling chain stopped (Vigil.Uptime).
       {"* * * * *", Vigil.Uptime.ReconcileWorker},
       # Chunk blobs and assemble statuses past a day (Vigil.Artifacts).
       {"41 3 * * *", Vigil.Artifacts.CleanupWorker},
       # Retention: per-org limits, stale issues and releases, purges.
       {"53 3 * * *", Vigil.Retention.SweepWorker}
     ]}
  ]

# The partitioned tables (Vigil.Partitions): how far ahead partitions are
# made, and how long data is kept (days).
config :vigil, Vigil.Partitions,
  tables: [
    %{table: "issue_events", kind: :uuid7_daily, ahead_days: 3, keep_days: 90},
    %{table: "issue_tags", kind: :weekly, ahead_days: 21, keep_days: 90},
    %{table: "issue_counts", kind: :weekly, ahead_days: 21, keep_days: 90},
    %{table: "project_counts", kind: :weekly, ahead_days: 21, keep_days: 400},
    # Spans are many and short-lived; their rollups last longer.
    %{table: "spans", kind: :uuid7_daily, ahead_days: 3, keep_days: 14},
    %{table: "transaction_counts", kind: :weekly, ahead_days: 21, keep_days: 90},
    %{table: "uptime_checks", kind: :uuid7_daily, ahead_days: 3, keep_days: 30},
    %{table: "log_events", kind: :uuid7_daily, ahead_days: 3, keep_days: 30},
    %{table: "session_counts", kind: :weekly, ahead_days: 21, keep_days: 400},
    %{table: "session_users", kind: :weekly, ahead_days: 21, keep_days: 90}
  ]

# Self-reporting (Vigil.SelfReport): inert until VIGIL_SELF_DSN sets a DSN
# (runtime.exs). Oban job errors and every cron job, as cron monitors.
config :sentry,
  dsn: nil,
  enable_source_code_context: false,
  integrations: [oban: [capture_errors: true, cron: [enabled: true]]],
  before_send: {Vigil.SelfReport, :before_send}

# Configure the endpoint
config :vigil, VigilWeb.Endpoint,
  url: [host: "localhost"],
  adapter: Bandit.PhoenixAdapter,
  render_errors: [
    formats: [html: VigilWeb.ErrorHTML, json: VigilWeb.ErrorJSON],
    layout: false
  ],
  pubsub_server: Vigil.PubSub,
  live_view: [signing_salt: "bngKK78G"]

# Configure LiveView
config :phoenix_live_view,
  # the attribute set on all root tags. Used for Phoenix.LiveView.ColocatedCSS.
  root_tag_attribute: "phx-r"

# Configure the mailer
#
# By default it uses the "Local" adapter which stores the emails
# locally. You can see the emails in your browser, at "/dev/mailbox".
#
# For production it's recommended to configure a different adapter
# at the `config/runtime.exs`.
config :vigil, Vigil.Mailer, adapter: Swoosh.Adapters.Local

# Configure esbuild (the version is required)
config :esbuild,
  version: "0.25.4",
  vigil: [
    args:
      ~w(js/app.js --bundle --target=es2022 --outdir=../priv/static/assets/js --external:/fonts/* --external:/images/* --alias:@=.),
    cd: Path.expand("../assets", __DIR__),
    env: %{"NODE_PATH" => [Path.expand("../deps", __DIR__), Mix.Project.build_path()]}
  ]

# Configure tailwind (the version is required)
config :tailwind,
  version: "4.3.0",
  vigil: [
    args: ~w(
      --input=assets/css/app.css
      --output=priv/static/assets/css/app.css
    ),
    cd: Path.expand("..", __DIR__),
    env: %{"NODE_PATH" => [Path.expand("../deps", __DIR__), Mix.Project.build_path()]}
  ]

# Configure Elixir's Logger
config :logger, :default_formatter,
  format: "$time $metadata[$level] $message\n",
  metadata: [:request_id]

# Use Jason for JSON parsing in Phoenix
config :phoenix, :json_library, Jason

# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{config_env()}.exs"