From 21acf441fbcbb663a7b600733e8daed7a3daf8e7 Mon Sep 17 00:00:00 2001 From: mo khan Date: Mon, 14 Apr 2025 17:20:42 -0600 Subject: chore: load env vars from .env files --- .env | 4 ++++ .gitignore | 1 + Makefile | 10 ++++++++-- go.mod | 3 +++ go.sum | 2 ++ 5 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..39ae24e --- /dev/null +++ b/.env @@ -0,0 +1,4 @@ +OAUTH_CLIENT_ID=client_id +OAUTH_CLIENT_SECRET=client_secret +OAUTH_REDIRECT_URL=http://localhost:8080/session/callback +OIDC_ISSUER=https://gitlab.com diff --git a/.gitignore b/.gitignore index 53c1797..6be0ff9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /sparkled +.env.local diff --git a/Makefile b/Makefile index 8a66869..1b615fa 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,8 @@ clean: setup: @mise install + @go install tool + @command -v godotenv build: sparkled @@ -31,10 +33,14 @@ build-builder-image: @docker build --target build --tag $(IMAGE_TAG) . run: clean build - BIND_ADDR=:8080 ./sparkled + @godotenv -f .env.local,.env ./sparkled run-image: build-image - @docker run -p 8080:80 -it $(IMAGE_TAG) + @if [ -f ".env.local" ]; then \ + docker run --env BIND_ADDR=:http --env-file .env.local -p 8080:80 -it $(IMAGE_TAG); \ + else \ + docker run --env BIND_ADDR=:http --env-file .env -p 8080:80 -it $(IMAGE_TAG); \ + fi sh-image: build-builder-image @docker run -it $(IMAGE_TAG) /bin/sh diff --git a/go.mod b/go.mod index 2b129af..1a9d8c6 100644 --- a/go.mod +++ b/go.mod @@ -36,6 +36,7 @@ require ( github.com/google/go-cmp v0.7.0 // indirect github.com/google/jsonapi v1.0.0 // indirect github.com/google/uuid v1.6.0 // indirect + github.com/joho/godotenv v1.5.1 // indirect github.com/klauspost/compress v1.17.4 // indirect github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect github.com/magiconair/properties v1.8.9 // indirect @@ -71,3 +72,5 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) + +tool github.com/joho/godotenv/cmd/godotenv diff --git a/go.sum b/go.sum index 7e527e2..5b3dfd7 100644 --- a/go.sum +++ b/go.sum @@ -55,6 +55,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 h1:VNqngBF40hVlDloBruUehVYC3ArSgIyScOAyMRqBxRg= github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1/go.mod h1:RBRO7fro65R6tjKzYgLAFo0t1QEXY1Dp+i/bvpRiqiQ= +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4= -- cgit v1.2.3