server: env-driven config via dotenv; Dockerfile BuildKit cache mounts; db in data.volume

This commit is contained in:
2026-08-01 02:32:01 +02:00
parent 95eab7f584
commit c562a816f9
5 changed files with 24 additions and 9 deletions
+13 -3
View File
@@ -9,9 +9,17 @@ import (
"path/filepath"
"strings"
"github.com/joho/godotenv"
"github.com/spf13/pflag"
)
func envOr(key, def string) string {
if v := os.Getenv(key); v != "" {
return v
}
return def
}
func buildFrontend() error {
cmd := "npm"
if _, err := exec.LookPath("npm"); err != nil {
@@ -43,11 +51,13 @@ func spaHandler() http.HandlerFunc {
}
func main() {
_ = godotenv.Load()
dev := pflag.Bool("dev", false, "run `npm run build` before serving dist/")
devServer := pflag.Bool("dev-server", false, "frontend served by the vite dev server, do not serve dist/")
addr := pflag.String("addr", ":5000", "listen address")
configPath := pflag.StringP("config", "c", "config.local.yaml", "yaml config file")
dbPath := pflag.String("db", "data.volume/history.db", "sqlite history database file")
addr := pflag.String("addr", envOr("ADDR", ":5000"), "listen address")
configPath := pflag.StringP("config", "c", envOr("CONFIG", "config.local.yaml"), "yaml config file")
dbPath := pflag.String("db", envOr("DB", "data.volume/history.db"), "sqlite history database file")
pflag.Parse()
if dir := filepath.Dir(*dbPath); dir != "." {