Skip to content

Commit

Permalink
fix: env var fetch method
Browse files Browse the repository at this point in the history
  • Loading branch information
proffapt committed Jun 29, 2024
1 parent 9d05fe4 commit dd969d8
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 15 deletions.
2 changes: 2 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env.example
.env
1 change: 0 additions & 1 deletion backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions backend/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
13 changes: 4 additions & 9 deletions backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import (
"database/sql"
"encoding/json"
"fmt"
"log"
"math/rand"
"net/http"
"os"
"strconv"
"strings"
"time"

"github.com/joho/godotenv"
_ "github.com/mattn/go-sqlite3"
"github.com/rs/cors"
)
Expand Down Expand Up @@ -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")
Expand Down
5 changes: 2 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit dd969d8

Please sign in to comment.