Changed env layout + Start info
This commit is contained in:
parent
5307f078c0
commit
03093a8b1b
6 changed files with 51 additions and 18 deletions
|
@ -4,13 +4,14 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
|
"git.ucode.space/Phil/goshorly/utils"
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/go-redis/redis/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ctx = context.Background()
|
var ctx = context.Background()
|
||||||
|
|
||||||
var Client *redis.Client = redis.NewClient(&redis.Options{
|
var Client *redis.Client = redis.NewClient(&redis.Options{
|
||||||
Addr: "redis:6379", // use default Addr
|
Addr: utils.REDIS_URI, // use default Addr
|
||||||
Password: "", // no password set
|
Password: "", // no password set
|
||||||
DB: 0, // use default DB
|
DB: 0, // use default DB
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,12 +4,12 @@ services:
|
||||||
# build: . # Only if you want to Build the image on your own Server!
|
# build: . # Only if you want to Build the image on your own Server!
|
||||||
image: registry.ucode.space/phil/goshorly:latest
|
image: registry.ucode.space/phil/goshorly:latest
|
||||||
environment:
|
environment:
|
||||||
- HOST=127.0.0.1 # Domain or IP-Adress
|
- HOST="127.0.0.1" # Domain or IP-Adress
|
||||||
- PORT=3000 # The Port you want to use
|
- PORT="3000" # The Port you want to use
|
||||||
- HTTPS=true # If you want to use HTTPS
|
- HTTPS="true" # If you want to use HTTPS
|
||||||
- PROXY=true # If you want to use a Reverse Proxy
|
- PROXY="true" # If you want to use a Reverse Proxy
|
||||||
- REDIS_URI=redis # The Redis-URI (name of redis container OOTB)
|
- REDIS_URI="redis" # The Redis-URI (name of redis container OOTB)
|
||||||
- ENABLE_STATS=true # Enables the /stats public frontend
|
- ENABLE_STATS="true" # Enables the /stats public frontend
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis
|
- redis
|
||||||
restart: always
|
restart: always
|
||||||
|
|
|
@ -4,12 +4,12 @@ services:
|
||||||
# build: . # Only if you want to Build the image on your own Server!
|
# build: . # Only if you want to Build the image on your own Server!
|
||||||
image: registry.ucode.space/phil/goshorly:latest
|
image: registry.ucode.space/phil/goshorly:latest
|
||||||
environment:
|
environment:
|
||||||
- HOST=127.0.0.1 # Domain or IP-Adress
|
- HOST="127.0.0.1" # Domain or IP-Adress
|
||||||
- PORT=3000 # The Port you want to use
|
- PORT="3000" # The Port you want to use
|
||||||
- HTTPS=false # If you want to use HTTPS
|
- HTTPS="false" # If you want to use HTTPS
|
||||||
- PROXY=false # If you want to use a Reverse Proxy
|
- PROXY="false" # If you want to use a Reverse Proxy
|
||||||
- REDIS_URI=redis # The Redis-URI (name of redis container OOTB)
|
- REDIS_URI="redis" # The Redis-URI (name of redis container OOTB)
|
||||||
- ENABLE_STATS=true # Enables the /stats public frontend (Default: true)
|
- ENABLE_STATS="true" # Enables the /stats public frontend (Default: true)
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "3000:3000"
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|
1
main.go
1
main.go
|
@ -17,6 +17,7 @@ import (
|
||||||
var viewsfs embed.FS
|
var viewsfs embed.FS
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
utils.Print_Starting_Screen()
|
||||||
utils.Init_env_vars()
|
utils.Init_env_vars()
|
||||||
utils.Init_build_vars()
|
utils.Init_build_vars()
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
package utils
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
CI_COMMIT_SHORT_SHA string
|
CI_COMMIT_SHORT_SHA string
|
||||||
CI_COMMIT_BRANCH string
|
CI_COMMIT_BRANCH string
|
||||||
|
@ -20,3 +25,16 @@ func Init_build_vars() {
|
||||||
CI_TAGGED = true
|
CI_TAGGED = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Print_Starting_Screen() {
|
||||||
|
if CI_BUILD {
|
||||||
|
if CI_TAGGED {
|
||||||
|
fmt.Println("---- Starting goshorly " + CI_COMMIT_TAG + " ----")
|
||||||
|
} else {
|
||||||
|
fmt.Println("---- Starting goshorly " + CI_COMMIT_SHORT_SHA + " ----")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fmt.Println("---- Starting goshorly " + "unknown version" + " ----")
|
||||||
|
}
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
}
|
||||||
|
|
19
utils/env.go
19
utils/env.go
|
@ -1,6 +1,7 @@
|
||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
@ -16,12 +17,14 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init_env_vars() {
|
func Init_env_vars() {
|
||||||
|
fmt.Println("-- Initializing environment variables... --")
|
||||||
|
|
||||||
UHOST, err := os.LookupEnv("HOST")
|
UHOST, err := os.LookupEnv("HOST")
|
||||||
if !err {
|
if !err {
|
||||||
log.Fatal("HOST enviroment variable not found, please set it!")
|
log.Fatal("HOST enviroment variable not found, please set it!")
|
||||||
}
|
}
|
||||||
HOST = UHOST
|
HOST = UHOST
|
||||||
|
fmt.Println("HOST: ", HOST)
|
||||||
|
|
||||||
UHTTPS, _ := os.LookupEnv("HTTPS")
|
UHTTPS, _ := os.LookupEnv("HTTPS")
|
||||||
if UHTTPS != "true" {
|
if UHTTPS != "true" {
|
||||||
|
@ -29,6 +32,7 @@ func Init_env_vars() {
|
||||||
} else {
|
} else {
|
||||||
HTTPS = "https"
|
HTTPS = "https"
|
||||||
}
|
}
|
||||||
|
fmt.Println("Proto: ", HTTPS)
|
||||||
|
|
||||||
UPROXY, _ := os.LookupEnv("PROXY")
|
UPROXY, _ := os.LookupEnv("PROXY")
|
||||||
if UPROXY != "true" {
|
if UPROXY != "true" {
|
||||||
|
@ -36,6 +40,7 @@ func Init_env_vars() {
|
||||||
} else {
|
} else {
|
||||||
PROXY = true
|
PROXY = true
|
||||||
}
|
}
|
||||||
|
fmt.Println("Own reverse proxy: ", PROXY)
|
||||||
|
|
||||||
UPORT, err := os.LookupEnv("PORT")
|
UPORT, err := os.LookupEnv("PORT")
|
||||||
if !err {
|
if !err {
|
||||||
|
@ -43,11 +48,15 @@ func Init_env_vars() {
|
||||||
} else {
|
} else {
|
||||||
PORT = UPORT
|
PORT = UPORT
|
||||||
}
|
}
|
||||||
|
fmt.Println("Port: ", PORT)
|
||||||
|
|
||||||
UREDIS_URI, _ := os.LookupEnv("REDIS_URI")
|
UREDIS_URI, err := os.LookupEnv("REDIS_URI")
|
||||||
if UREDIS_URI != "" {
|
if !err {
|
||||||
REDIS_URI = "redis"
|
REDIS_URI = "redis:6379"
|
||||||
|
} else {
|
||||||
|
REDIS_URI = UREDIS_URI
|
||||||
}
|
}
|
||||||
|
fmt.Println("Redis URI: ", REDIS_URI)
|
||||||
|
|
||||||
UESTATS, _ := os.LookupEnv("ENABLE_STATS")
|
UESTATS, _ := os.LookupEnv("ENABLE_STATS")
|
||||||
if UESTATS != "false" {
|
if UESTATS != "false" {
|
||||||
|
@ -55,6 +64,7 @@ func Init_env_vars() {
|
||||||
} else {
|
} else {
|
||||||
ESTATS = "false"
|
ESTATS = "false"
|
||||||
}
|
}
|
||||||
|
fmt.Println("Stats enabled: ", ESTATS)
|
||||||
|
|
||||||
create_string()
|
create_string()
|
||||||
|
|
||||||
|
@ -66,4 +76,7 @@ func create_string() {
|
||||||
} else {
|
} else {
|
||||||
URL = HTTPS + "://" + HOST + "/"
|
URL = HTTPS + "://" + HOST + "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println("URL: ", URL)
|
||||||
|
fmt.Println("-- Environment variables initialized! / Starting Webserver --")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue