2ce68cb098
- Move db/schema.sql to supabase/migrations/ as the first supabase CLI migration (manual `db push` only, no automated runner); re-add the gebos_ingest role + grants there since init.sql never re-runs - Add gebos-postgres-passwords oneshot on db-host: syncs role passwords from sops (LoadCredential, journal-safe), makes supabase_admin SUPERUSER and hands the auth schema to supabase_auth_admin to match the upstream supabase/postgres image; add pg_hba rule for 10.0.0.0/8 - Vendor the official docker-compose (studio/kong/auth/rest/meta only, external Postgres, loopback Studio with no Kong dashboard route) plus kong.yml (trimmed) and kong-entrypoint.sh (verbatim); tested: compose config, Kong config parse, migration applied on TimescaleDB pg17 - Document decisions as ADRs 0001-0004 (migrations, passwords, vendored stack, JWT API keys incl. verify/mint procedure) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
78 lines
2.6 KiB
Nix
78 lines
2.6 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
cfg = config.services.gebos.supabase;
|
|
composeDir = ../supabase;
|
|
in
|
|
{
|
|
options.services.gebos.supabase = {
|
|
enable = lib.mkEnableOption "Supabase stack via vanilla docker-compose";
|
|
|
|
postgresHost = lib.mkOption {
|
|
type = lib.types.str;
|
|
description = "External Postgres host (db-host).";
|
|
};
|
|
postgresPort = lib.mkOption {
|
|
type = lib.types.port;
|
|
default = 5432;
|
|
};
|
|
studioBindAddress = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "127.0.0.1";
|
|
description = "Studio is intentionally never exposed publicly.";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
virtualisation.docker.enable = true;
|
|
|
|
systemd.tmpfiles.rules = [
|
|
"d /var/lib/gebos-supabase 0750 root root - -"
|
|
];
|
|
|
|
# Copy the vendored compose bundle into place at activation time so
|
|
# changes under nix/supabase/ are deployed atomically. Kong's declarative
|
|
# config is mounted from here by the compose file (relative ./kong.yml
|
|
# resolves against WorkingDirectory).
|
|
environment.etc."gebos/supabase/docker-compose.yml".source =
|
|
"${composeDir}/docker-compose.yml";
|
|
environment.etc."gebos/supabase/kong.yml".source =
|
|
"${composeDir}/kong.yml";
|
|
environment.etc."gebos/supabase/kong-entrypoint.sh".source =
|
|
"${composeDir}/kong-entrypoint.sh";
|
|
|
|
systemd.services.gebos-supabase = {
|
|
description = "Gebos — Supabase compose stack";
|
|
after = [ "docker.service" "network-online.target" ];
|
|
wants = [ "docker.service" "network-online.target" ];
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
# `docker compose up -d` only recreates containers whose definition
|
|
# changed, but the unit must re-run for it to notice at all.
|
|
restartTriggers = [
|
|
"${composeDir}/docker-compose.yml"
|
|
"${composeDir}/kong.yml"
|
|
"${composeDir}/kong-entrypoint.sh"
|
|
];
|
|
|
|
environment = {
|
|
POSTGRES_HOST = cfg.postgresHost;
|
|
POSTGRES_PORT = toString cfg.postgresPort;
|
|
POSTGRES_DB = "postgres";
|
|
STUDIO_BIND = cfg.studioBindAddress;
|
|
};
|
|
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
RemainAfterExit = true;
|
|
WorkingDirectory = "/etc/gebos/supabase";
|
|
# POSTGRES_PASSWORD, JWT_SECRET, ANON_KEY, SERVICE_ROLE_KEY, DASHBOARD_PASSWORD.
|
|
# Rendered by sops-nix from nix/secrets/secrets.yaml — see gebos-secrets module.
|
|
EnvironmentFile = config.services.gebos.secrets.envFile;
|
|
ExecStart = "${pkgs.docker}/bin/docker compose up -d --remove-orphans";
|
|
ExecStop = "${pkgs.docker}/bin/docker compose down";
|
|
};
|
|
};
|
|
};
|
|
}
|