From 876f801e533611fe24fb358c41e69635e07c9651 Mon Sep 17 00:00:00 2001 From: Phil Date: Wed, 8 Dec 2021 13:11:35 +0000 Subject: [PATCH] Make Redis as ENV Var --- docker-compose-proxy.yml | 3 ++- docker-compose.yml | 3 ++- utils/env.go | 22 ++++++++++++++++------ views/home.html | 2 +- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/docker-compose-proxy.yml b/docker-compose-proxy.yml index b416a0c..9c20d07 100644 --- a/docker-compose-proxy.yml +++ b/docker-compose-proxy.yml @@ -5,9 +5,10 @@ services: image: registry.ucode.space/phil/goshorly:latest environment: - HOST=example.org # Domain or IP-Adress + - PORT=3000 # The Port you want to use - HTTPS=true # If you want to use HTTPS - PROXY=true # If you want to use a Reverse Proxy - - PORT=3000 # The Port you want to use + - REDIS_URI=redis # The Redis-URI (name of redis container OOTB) depends_on: - redis restart: always diff --git a/docker-compose.yml b/docker-compose.yml index d17cea2..e9b008a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,9 +5,10 @@ services: image: registry.ucode.space/phil/goshorly:latest environment: - HOST=your_domain_or_ip # Domain or IP-Adress + - PORT=3000 # The Port you want to use - HTTPS=false # If you want to use HTTPS - PROXY=false # If you want to use a Reverse Proxy - - PORT=3000 # The Port you want to use + - REDIS_URI=redis # The Redis-URI (name of redis container OOTB) ports: - "3000:3000" depends_on: diff --git a/utils/env.go b/utils/env.go index e63ea7d..3eeec85 100644 --- a/utils/env.go +++ b/utils/env.go @@ -5,14 +5,17 @@ import ( "os" ) -var HOST string -var HTTPS string -var PROXY bool -var PORT string - -var URL string +var ( + HOST string + PORT string + HTTPS string + PROXY bool + URL string + REDIS_URI string +) func Init_env_vars() { + UHOST, err := os.LookupEnv("HOST") if !err { log.Fatal("HOST enviroment variable not found, please set it!") @@ -40,6 +43,13 @@ func Init_env_vars() { PORT = UPORT } + UREDIS_URI, err := os.LookupEnv("REDIS_URI") + if !err { + REDIS_URI = "redis" + } else { + REDIS_URI = UREDIS_URI + } + create_string() } diff --git a/views/home.html b/views/home.html index 1c857ba..b73f4fb 100644 --- a/views/home.html +++ b/views/home.html @@ -76,7 +76,7 @@ Made with Phil/goshorly {{ if .GitBuild }} - {{ .GitCommitShort }}/{{ .GitBranch }} + | {{ .GitCommitShort }}/{{ .GitBranch }} {{ end }}