b6cdf8c88e
- Add Dockerfile (pre-built binary) and Dockerfile.source - Add docker-compose.yml, docker-compose.prod.yml, docker-compose.override.yml - Add docker-entrypoint.sh with non-root user support - Add .dockerignore and helper scripts (scripts/docker-build.sh, scripts/docker-run.sh) - Add docs/en/docker.md with full Docker guide - Update docs/en/deployment.md and README.md - Fix src/barabadb/core/config.nim to read BARADB_ADDRESS, BARADB_PORT, BARADB_DATA_DIR from env - Fix src/barabadb/core/httpserver.nim missing wire import
56 lines
1.3 KiB
Nim
56 lines
1.3 KiB
Nim
import std/os
|
|
import std/strutils
|
|
|
|
type
|
|
BaraConfig* = object
|
|
address*: string
|
|
port*: int
|
|
dataDir*: string
|
|
maxConnections*: int
|
|
walEnabled*: bool
|
|
compactionStrategy*: CompactionStrategy
|
|
tlsEnabled*: bool
|
|
certFile*: string
|
|
keyFile*: string
|
|
idleTimeoutMs*: int
|
|
queryTimeoutMs*: int
|
|
slowQueryThresholdMs*: int
|
|
slowQueryLogPath*: string
|
|
|
|
CompactionStrategy* = enum
|
|
csSizeTiered = "size_tiered"
|
|
csLeveled = "leveled"
|
|
|
|
proc defaultConfig*(): BaraConfig =
|
|
BaraConfig(
|
|
address: "127.0.0.1",
|
|
port: 9472,
|
|
dataDir: "./data",
|
|
maxConnections: 1000,
|
|
walEnabled: true,
|
|
compactionStrategy: csLeveled,
|
|
tlsEnabled: false,
|
|
certFile: "",
|
|
keyFile: "",
|
|
idleTimeoutMs: 300_000,
|
|
queryTimeoutMs: 30_000,
|
|
slowQueryThresholdMs: 1_000,
|
|
slowQueryLogPath: "",
|
|
)
|
|
|
|
proc loadConfig*(): BaraConfig =
|
|
result = defaultConfig()
|
|
# Docker / Environment overrides
|
|
let envAddress = getEnv("BARADB_ADDRESS", "")
|
|
if envAddress.len > 0:
|
|
result.address = envAddress
|
|
let envPort = getEnv("BARADB_PORT", "")
|
|
if envPort.len > 0:
|
|
try:
|
|
result.port = parseInt(envPort)
|
|
except ValueError:
|
|
discard
|
|
let envDataDir = getEnv("BARADB_DATA_DIR", "")
|
|
if envDataDir.len > 0:
|
|
result.dataDir = envDataDir
|