fix: serve console env from os (not statik) (#187)

* fix: serve console env from os (not statik)

* ZITADEL_CONSOLE_ENV_PATH for (local) overwrite possibility

* name EnvOverwritePath
This commit is contained in:
Livio Amstutz 2020-06-09 07:38:44 +02:00 committed by GitHub
parent c0f18832e7
commit 0da6dc1d66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 3 deletions

View File

@ -45,4 +45,7 @@ export ZITADEL_AUTHORIZE=http://localhost:50022
export ZITADEL_OAUTH=http://localhost:50022
export ZITADEL_CONSOLE=http://localhost:4200
export CAOS_OIDC_DEV=true
export ZITADEL_COOKIE_DOMAIN=localhost
export ZITADEL_COOKIE_DOMAIN=localhost
#Console
export ZITADEL_CONSOLE_ENV_PATH=../../console/src/

View File

@ -191,6 +191,7 @@ Admin:
Console:
Port: 50050
EnvOverwritePath: $ZITADEL_CONSOLE_ENV_PATH
Notification:

View File

@ -72,7 +72,7 @@ spec:
- name: zitadel-secret
mountPath: /secret
- name: console-config
mountPath: /app/console/dist/assets/environment.json
mountPath: /assets/environment.json
subPath: environment.json
imagePullSecrets:
- name: githubsecret

View File

@ -12,13 +12,18 @@ import (
)
type Config struct {
Port string
Port string
EnvOverwritePath string
}
type spaHandler struct {
fileSystem http.FileSystem
}
const (
envRequestPath = "/assets/environment.json"
)
func (i *spaHandler) Open(name string) (http.File, error) {
ret, err := i.fileSystem.Open(name)
if !os.IsNotExist(err) || path.Ext(name) != "" {
@ -33,6 +38,11 @@ func Start(ctx context.Context, config Config) error {
if err != nil {
return err
}
envPath := envRequestPath
if config.EnvOverwritePath != "" {
envPath = config.EnvOverwritePath
}
http.Handle("/", http.FileServer(&spaHandler{statikFS}))
http.Handle(envRequestPath, http.FileServer(http.Dir(envPath)))
return http.ListenAndServe(":"+config.Port, nil)
}