diff --git a/config/config-local.yml b/config/config-dev.yml similarity index 100% rename from config/config-local.yml rename to config/config-dev.yml diff --git a/config/config-prod.yml b/config/config-prod.yml new file mode 100644 index 0000000..467e8d8 --- /dev/null +++ b/config/config-prod.yml @@ -0,0 +1,65 @@ +meta: + ProjectName: "PowerSSO" + ProjectURL: "http://localhost:3000" + +server: + Version: 1.0.0 + Port: :5000 + PprofPort: :5555 + Mode: production + JwtSecretKey: 234wdasfsgfsd34rewsfg5tergergdf + CookieName: jwt-power-sso + SSL: true + CtxDefaultTimeout: 12 + ReadTimeout: 5 + WriteTimeout: 5 + CSRF: true + Debug: false + StartHTTP: true + StartGRPC: false + AccessLogDirectory: /var/log/power-sso/access.log + ErrorLogDirectory: /var/log/power-sso/error.log + PermissionBase: github.com/isaqueveras/power-sso + +postgres: + Host: localhost + Port: 5432 + User: postgres + Password: postgres + Dbname: power-sso + Sslmode: true + Driver: pgx + MaxOpenConns: 60 + MaxIdleConns: 30 + ConnMaxLifetime: 120 + ConnMaxIdleTime: 20 + Timeout: 2 + +redis: + RedisAddr: localhost:6379 + RedisPassword: + RedisDb: 0 + RedisDefaultdb: 0 + MinIdleConns: 200 + PoolSize: 12000 + PoolTimeout: 240 + Password: "" + DB: 0 + +logger: + Development: true + DisableCaller: false + DisableStacktrace: false + Encoding: json + Level: info + +mailer: + Host: localhost + Port: 1025 + Email: contact@powersso.io + Password: password + TLS: true + +UserAuthToken: + SecretKey: kjnfdjksdbfsdhfbdskjfnamkndkn + Duration: 2592000 \ No newline at end of file diff --git a/config/config.go b/config/config.go index 739072a..27717f5 100644 --- a/config/config.go +++ b/config/config.go @@ -6,6 +6,7 @@ package config import ( "log" + "os" "github.com/spf13/viper" ) @@ -20,7 +21,7 @@ func LoadConfig(path ...string) { path[0] = "." } - v.SetConfigName("./config/config-local") + v.SetConfigName(getConfigPath(os.Getenv("CONFIG_POWER_SSO"))) v.AddConfigPath(path[0]) v.AutomaticEnv() @@ -44,3 +45,11 @@ func Get() *Config { } return config } + +// Get config path for dev or production +func getConfigPath(configPath string) string { + if configPath == modeProduction { + return "./config/config-prod" + } + return "./config/config-dev" +}