import fs from 'node:fs'; // `.env` loading is a local/dev convenience only. // In the repo-driven Hetzner+k3s bootstrap flow, Kubernetes injects runtime // environment variables from Secrets/ConfigMaps and already-present process.env // values always win over anything on disk. export function loadDotenv(path = '.env') { if (!fs.existsSync(path)) return; const lines = fs.readFileSync(path, 'utf8').split(/\r?\n/); for (const raw of lines) { const line = raw.trim(); if (!line || line.startsWith('#') || !line.includes('=')) continue; const [key, ...rest] = line.split('='); const value = rest.join('=').trim().replace(/^['"]|['"]$/g, ''); if (!(key.trim() in process.env)) process.env[key.trim()] = value; } }