feat: .env file is optional

This commit is contained in:
2025-06-01 12:55:05 +02:00
parent e8a74999c3
commit 3f8a4024ce
2 changed files with 3 additions and 5 deletions

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
"log" "log"
"os"
"gitea.local/admin/hspguard/cmd/hspguard/api" "gitea.local/admin/hspguard/cmd/hspguard/api"
"gitea.local/admin/hspguard/internal/config" "gitea.local/admin/hspguard/internal/config"
@ -16,9 +17,8 @@ import (
func main() { func main() {
err := godotenv.Load() err := godotenv.Load()
if err != nil { if err != nil && os.Getenv("ENV") != "production" {
log.Fatalln("ERR: Failed to load environment variables:", err) log.Fatalln("WARNING: .env file not found. Skipping...")
return
} }
var cfg config.AppConfig var cfg config.AppConfig

View File

@ -1,4 +1,3 @@
services: services:
db: db:
image: postgres image: postgres
@ -9,4 +8,3 @@ services:
POSTGRES_PASSWORD: guard POSTGRES_PASSWORD: guard
ports: ports:
- "5432:5432" - "5432:5432"