chore: parametrize db path
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 47s

This commit is contained in:
2024-10-01 22:44:24 +02:00
parent d30b9f8c30
commit 763104a916
2 changed files with 8 additions and 1 deletions

View File

@@ -40,7 +40,7 @@ func run(ctx context.Context, env func(string) string) {
serverSettings := types.NewServerSettingsFromEnv(env) serverSettings := types.NewServerSettingsFromEnv(env)
// init db // init db
db, err := sql.Open("sqlite3", "./data.db") db, err := sql.Open("sqlite3", serverSettings.DbPath)
if err != nil { if err != nil {
log.Fatal("Could not open Database data.db: ", err) log.Fatal("Could not open Database data.db: ", err)
} }

View File

@@ -8,6 +8,7 @@ import (
type ServerSettings struct { type ServerSettings struct {
BaseUrl string BaseUrl string
Environment string Environment string
DbPath string
Smtp *SmtpSettings Smtp *SmtpSettings
} }
@@ -21,6 +22,12 @@ type SmtpSettings struct {
} }
func NewServerSettingsFromEnv(env func(string) string) *ServerSettings { func NewServerSettingsFromEnv(env func(string) string) *ServerSettings {
dbPath := env("DB_PATH")
if dbPath == "" {
dbPath = "./data.db"
}
var smtp *SmtpSettings var smtp *SmtpSettings
if env("SMTP_ENABLED") == "true" { if env("SMTP_ENABLED") == "true" {
smtp = &SmtpSettings{ smtp = &SmtpSettings{