mirror of
https://github.com/aziis98/statuspage.git
synced 2026-10-06 14:45:01 +00:00
server: env-driven config via dotenv; Dockerfile BuildKit cache mounts; db in data.volume
This commit is contained in:
+13
-3
@@ -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 != "." {
|
||||
|
||||
Reference in New Issue
Block a user