serve frontend + backend as a one binary

This commit is contained in:
2024-11-19 17:16:36 +05:30
parent 5954ec2501
commit e378db58b8
14 changed files with 87 additions and 26 deletions

View File

@@ -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)