From dd969d874b52befc88a6e5cae2b944bafe73e099 Mon Sep 17 00:00:00 2001 From: proffapt Date: Sat, 29 Jun 2024 10:20:49 +0530 Subject: [PATCH] fix: env var fetch method --- backend/.dockerignore | 2 ++ backend/go.mod | 1 - backend/go.sum | 2 -- backend/main.go | 13 ++++--------- docker-compose.yml | 5 ++--- 5 files changed, 8 insertions(+), 15 deletions(-) create mode 100644 backend/.dockerignore diff --git a/backend/.dockerignore b/backend/.dockerignore new file mode 100644 index 0000000..9a44f49 --- /dev/null +++ b/backend/.dockerignore @@ -0,0 +1,2 @@ +.env.example +.env \ No newline at end of file diff --git a/backend/go.mod b/backend/go.mod index aa286fb..66ea4ba 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -3,7 +3,6 @@ module github.com/metakgp/naarad/backend go 1.22.4 require ( - github.com/joho/godotenv v1.5.1 github.com/mattn/go-sqlite3 v1.14.22 github.com/rs/cors v1.11.0 golang.org/x/oauth2 v0.21.0 diff --git a/backend/go.sum b/backend/go.sum index d0d8b4b..29eeb69 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -56,8 +56,6 @@ github.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfF github.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0= github.com/googleapis/gax-go/v2 v2.12.5 h1:8gw9KZK8TiVKB6q3zHY3SBzLnrGp6HQjyfYBYGmXdxA= github.com/googleapis/gax-go/v2 v2.12.5/go.mod h1:BUDKcWo+RaKq5SC9vVYL0wLADa3VcfswbOMMRmB9H3E= -github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= -github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/backend/main.go b/backend/main.go index 3bc7baf..58b43bd 100644 --- a/backend/main.go +++ b/backend/main.go @@ -4,7 +4,6 @@ import ( "database/sql" "encoding/json" "fmt" - "log" "math/rand" "net/http" "os" @@ -12,7 +11,6 @@ import ( "strings" "time" - "github.com/joho/godotenv" _ "github.com/mattn/go-sqlite3" "github.com/rs/cors" ) @@ -148,19 +146,16 @@ func register(res http.ResponseWriter, req *http.Request) { } func main() { - err := godotenv.Load() - if err != nil { - log.Println(err) - } - initMailer() - ntfyServerAddr = os.Getenv("NTFY_SERVER") - pswdSize, err = strconv.Atoi(os.Getenv("PASSWORD_SIZE")) + passwordSize, err := strconv.Atoi(os.Getenv("PASSWORD_SIZE")) if err != nil { pswdSize = 18 + } else { + pswdSize = passwordSize } + ntfyServerAddr = os.Getenv("NTFY_SERVER") fileLoc := os.Getenv("NTFY_AUTH_FILE") if fileLoc == "" || ntfyServerAddr == "" { panic("NTFY Server or NTFY auth file location cannot be empty") diff --git a/docker-compose.yml b/docker-compose.yml index f81a01e..2e10858 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,9 +33,8 @@ services: dockerfile: Dockerfile environment: - TZ=IST - - NTFY_SERVER=http://naarad:8000 - - NTFY_AUTH_FILE=/src/user.db - - PASSWORD_SIZE=18 + env_file: + - .env networks: metaploy-network: aliases: