From 1450888dd235d6e44ddb321920c4e871b7da175d Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Fri, 13 Oct 2023 19:05:03 +0800 Subject: [PATCH] feat: support custom encryption root key for local dev --- internal/db/start/start.go | 4 +++- internal/utils/config.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/db/start/start.go b/internal/db/start/start.go index 53d826c14..8d9656328 100644 --- a/internal/db/start/start.go +++ b/internal/db/start/start.go @@ -69,9 +69,11 @@ func NewContainerConfig() container.Config { Timeout: 2 * time.Second, Retries: 3, }, - Entrypoint: []string{"sh", "-c", `cat <<'EOF' > /etc/postgresql.schema.sql && docker-entrypoint.sh postgres -D /etc/postgresql + Entrypoint: []string{"sh", "-c", `cat <<'EOF' > /etc/postgresql.schema.sql && cat <<'EOF' > /etc/postgresql-custom/pgsodium_root.key && docker-entrypoint.sh postgres -D /etc/postgresql ` + initialSchema + ` EOF +` + utils.Config.Db.RootKey + ` +EOF `}, } if utils.Config.Db.MajorVersion >= 14 { diff --git a/internal/utils/config.go b/internal/utils/config.go index 6b2311518..7a7a231cf 100644 --- a/internal/utils/config.go +++ b/internal/utils/config.go @@ -111,6 +111,7 @@ var Config = config{ Db: db{ Image: Pg15Image, Password: "postgres", + RootKey: "d4dc5b6d4a1d6a10b2c1e76112c994d65db7cec380572cc1839624d4be3fa275", }, Realtime: realtime{ IpVersion: AddressIPv6, @@ -185,7 +186,7 @@ type ( config struct { ProjectId string `toml:"project_id"` Api api `toml:"api"` - Db db `toml:"db"` + Db db `toml:"db" mapstructure:"db"` Realtime realtime `toml:"realtime"` Studio studio `toml:"studio"` Inbucket inbucket `toml:"inbucket"` @@ -212,6 +213,7 @@ type ( ShadowPort uint `toml:"shadow_port"` MajorVersion uint `toml:"major_version"` Password string `toml:"-"` + RootKey string `toml:"-" mapstructure:"root_key"` Pooler pooler `toml:"pooler"` }