From d216c641544314a7d6e82bbbbb390831f84a97a0 Mon Sep 17 00:00:00 2001 From: RoyUP9 <87927115+RoyUP9@users.noreply.github.com> Date: Mon, 24 Jan 2022 10:34:50 +0200 Subject: [PATCH] Added support of ui split build (#682) --- Dockerfile | 1 + agent/main.go | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index a8565c556..9be281430 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,6 +54,7 @@ WORKDIR /app COPY --from=builder ["/app/agent-build/mizuagent", "."] COPY --from=builder ["/app/agent/build/extensions", "extensions"] COPY --from=site-build ["/app/ui-build/build", "site"] +COPY --from=site-build ["/app/ui-build/build-ent", "site-standalone"] RUN mkdir /app/data/ # gin-gonic runs in debug mode without this diff --git a/agent/main.go b/agent/main.go index 126edfe76..608d61c15 100644 --- a/agent/main.go +++ b/agent/main.go @@ -247,7 +247,12 @@ func hostApi(socketHarOutputChannel chan<- *tapApi.OutputChannelItem) { if err := setUIFlags(); err != nil { logger.Log.Errorf("Error setting ui mode, err: %v", err) } - app.Use(static.ServeRoot("/", "./site")) + + if config.Config.StandaloneMode { + app.Use(static.ServeRoot("/", "./site-standalone")) + } else { + app.Use(static.ServeRoot("/", "./site")) + } app.Use(middlewares.CORSMiddleware()) // This has to be called after the static middleware, does not work if its called before @@ -290,8 +295,7 @@ func setUIFlags() error { return err } - replacedContent := strings.Replace(string(read), "__IS_STANDALONE__", strconv.FormatBool(config.Config.StandaloneMode), 1) - replacedContent = strings.Replace(replacedContent, "__IS_OAS_ENABLED__", strconv.FormatBool(config.Config.OAS), 1) + replacedContent := strings.Replace(string(read), "__IS_OAS_ENABLED__", strconv.FormatBool(config.Config.OAS), 1) replacedContent = strings.Replace(replacedContent, "__IS_SERVICE_MAP_ENABLED__", strconv.FormatBool(config.Config.ServiceMap), 1) err = ioutil.WriteFile(uiIndexPath, []byte(replacedContent), 0)