serve frontend + backend as a one binary
This commit is contained in:
@@ -18,17 +18,13 @@ import (
|
||||
|
||||
const (
|
||||
// projDir need to be same as project code root dir name
|
||||
projDir = "rano"
|
||||
EnvDev = "development"
|
||||
EnvProd = "production"
|
||||
EnvStage = "staging"
|
||||
|
||||
projDir = "rano"
|
||||
AuthUserCtxKey = "AuthUser"
|
||||
)
|
||||
|
||||
var (
|
||||
conf *Config
|
||||
AppEnv Env = EnvDev
|
||||
AppEnv = "development" // production | staging
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -47,7 +43,7 @@ type (
|
||||
|
||||
func init() {
|
||||
var base string
|
||||
if AppEnv == EnvDev {
|
||||
if AppEnv == "development" { // AppEnv will be changed on build time using ldflags -X
|
||||
wd, _ := os.Getwd()
|
||||
idx := strings.Index(wd, projDir)
|
||||
if idx > -1 {
|
||||
@@ -57,6 +53,8 @@ func init() {
|
||||
base, _ = os.Executable()
|
||||
}
|
||||
|
||||
logger.Info("*** %s", AppEnv)
|
||||
|
||||
envVar, err := dotenv.Read(base, fmt.Sprintf(".env.%s", AppEnv))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
Reference in New Issue
Block a user