diff --git a/Jenkinsfile b/Jenkinsfile index be1c6e46ec1df1fce993b66f0ec39ef207d39699..acac81a6f460186252c48fd4e07c4a5bcb373983 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -75,6 +75,7 @@ tools { go 'go-1.22.0' } chmod +x ./buf ./buf generate #to compile go statically with these tags, so that the binary is not dynamically linked and from scratch in Dockerfile will work + APP_ENV=production go build -tags osusergo,netgo cmd/antragsraum-proxy/main.go ''' diff --git a/cmd/antragsraum-proxy/main.go b/cmd/antragsraum-proxy/main.go index 4c86d80f887d44d03df509fa775cd137080cee66..1af85470f48499cdf271a7e522ffc94221ae9cf2 100644 --- a/cmd/antragsraum-proxy/main.go +++ b/cmd/antragsraum-proxy/main.go @@ -29,12 +29,16 @@ import ( "antragsraum-proxy/internal/config" "antragsraum-proxy/internal/mock" "antragsraum-proxy/internal/server" + "fmt" ) var version = "v1.1.0-beta.1" func main() { conf := config.LoadConfig() + fmt.Printf("HTTP Server Port: %d\n", conf.Http.Server.Port) + fmt.Printf("gRPC Server Port: %d\n", conf.Grpc.Server.Port) + fmt.Printf("Logging Level: %s\n", conf.Logging.Level) if conf.Grpc.Server.Mock { go mock.StartGrpcServer() diff --git a/config/config.yml b/config/config-development.yml similarity index 100% rename from config/config.yml rename to config/config-development.yml diff --git a/config/config-production.yml b/config/config-production.yml new file mode 100755 index 0000000000000000000000000000000000000000..06bfbdaa6d7c3593a9a569d73c91f2d5a45c2c7e --- /dev/null +++ b/config/config-production.yml @@ -0,0 +1,11 @@ +http: + server: + port: 8082 +grpc: + server: + mock: false + port: 9090 + router: + port: 50051 +logging: + level: "INFO" \ No newline at end of file diff --git a/internal/config/config.go b/internal/config/config.go index 5089b4c88fa50b41aeb198d711deda4c4fb933a6..ad387b09c3528f01657cac7ca0ffdac70ff9a450 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -31,40 +31,45 @@ import ( "log" "os" "testing" + "fmt" ) const ( - defaultFilePath = "config/config.yml" - testFilePath = "testdata/test_config.yml" + defaultEnv = "development" + testFilePath = "testdata/test_config.yml" ) type Config struct { Http struct { Server struct { - Port int `yaml:"port" envconfig:"HTTP_SERVER_PORT"` + Port int `yaml:"port"` } `yaml:"server"` } `yaml:"http"` Grpc struct { Server struct { - Mock bool `yaml:"mock" envconfig:"GRPC_SERVER_MOCK"` + Mock bool `yaml:"mock"` Port int `yaml:"port" envconfig:"GRPC_SERVER_PORT"` } `yaml:"server"` Router struct { - Port int `yaml:"port" envconfig:"GRPC_ROUTER_PORT"` + Port int `yaml:"port"` } `yaml:"router"` } `yaml:"grpc"` Logging struct { - Level string `yaml:"level" envconfig:"LOGGING_LEVEL"` + Level string `yaml:"level"` } `yaml:"logging"` } -func LoadConfig(configFilePath ...string) Config { +func LoadConfig() Config { var config Config - fp := defaultFilePath - if len(configFilePath) > 0 { - fp = configFilePath[0] - } else if testing.Testing() { + env := os.Getenv("APP_ENV") + if env == "" { + env = defaultEnv + } + + fp := fmt.Sprintf("config/config-%s.yml", env) + + if testing.Testing() { fp = testFilePath } diff --git a/src/main/helm/templates/deployment.yaml b/src/main/helm/templates/deployment.yaml index 5d7733ed9e3d571c044c544f47d5a1ea61ac314f..0020d63a9e903c48490745587aade82f31b9953c 100644 --- a/src/main/helm/templates/deployment.yaml +++ b/src/main/helm/templates/deployment.yaml @@ -58,14 +58,8 @@ spec: app.kubernetes.io/name: {{ .Release.Name }} containers: - env: - - name: LOGGING_LEVEL - value: "INFO" - - name: HTTP_SERVER_PORT - value: "8082" - - name: GRPC_SERVER_MOCK - value: "false" - name: GRPC_SERVER_PORT - value: "9090" + value: "{{ .Values.grpc.server.port }}" {{- with include "app.getCustomList" . }} {{ . | indent 10 }} {{- end }}