Merge branch 'develop' into feature/multiarch_build

This commit is contained in:
M. Mert Yildiran 2022-01-24 16:41:35 +03:00
commit 724c86bd3b
No known key found for this signature in database
GPG Key ID: D42ADB236521BF7A
12 changed files with 4702 additions and 949 deletions

View File

@ -2,7 +2,6 @@
.dockerignore .dockerignore
.editorconfig .editorconfig
.gitignore .gitignore
**/.env*
Dockerfile Dockerfile
Makefile Makefile
LICENSE LICENSE

View File

@ -91,6 +91,7 @@ WORKDIR /app
COPY --from=builder ["/app/agent-build/mizuagent", "."] COPY --from=builder ["/app/agent-build/mizuagent", "."]
COPY --from=builder ["/app/agent/build/extensions", "extensions"] COPY --from=builder ["/app/agent/build/extensions", "extensions"]
COPY --from=front-end ["/app/ui-build/build", "site"] COPY --from=front-end ["/app/ui-build/build", "site"]
COPY --from=front-end ["/app/ui-build/build-ent", "site-standalone"]
# gin-gonic runs in debug mode without this # gin-gonic runs in debug mode without this
ENV GIN_MODE=release ENV GIN_MODE=release

View File

@ -247,7 +247,12 @@ func hostApi(socketHarOutputChannel chan<- *tapApi.OutputChannelItem) {
if err := setUIFlags(); err != nil { if err := setUIFlags(); err != nil {
logger.Log.Errorf("Error setting ui mode, err: %v", err) logger.Log.Errorf("Error setting ui mode, err: %v", err)
} }
if config.Config.StandaloneMode {
app.Use(static.ServeRoot("/", "./site-standalone"))
} else {
app.Use(static.ServeRoot("/", "./site")) 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 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 return err
} }
replacedContent := strings.Replace(string(read), "__IS_STANDALONE__", strconv.FormatBool(config.Config.StandaloneMode), 1) replacedContent := strings.Replace(string(read), "__IS_OAS_ENABLED__", strconv.FormatBool(config.Config.OAS), 1)
replacedContent = strings.Replace(replacedContent, "__IS_OAS_ENABLED__", strconv.FormatBool(config.Config.OAS), 1)
replacedContent = strings.Replace(replacedContent, "__IS_SERVICE_MAP_ENABLED__", strconv.FormatBool(config.Config.ServiceMap), 1) replacedContent = strings.Replace(replacedContent, "__IS_SERVICE_MAP_ENABLED__", strconv.FormatBool(config.Config.ServiceMap), 1)
err = ioutil.WriteFile(uiIndexPath, []byte(replacedContent), 0) err = ioutil.WriteFile(uiIndexPath, []byte(replacedContent), 0)

2
ui/.env.basic Normal file
View File

@ -0,0 +1,2 @@
REACT_APP_OVERRIDE_WS_URL="ws://localhost:8899/ws"
REACT_APP_OVERRIDE_API_URL="http://localhost:8899/"

3
ui/.env.enterprise Normal file
View File

@ -0,0 +1,3 @@
REACT_APP_OVERRIDE_WS_URL="ws://localhost:8899/ws"
REACT_APP_OVERRIDE_API_URL="http://localhost:8899/"
REACT_APP_OVERRIDE_IS_ENTERPRISE="true"

1
ui/.gitignore vendored
View File

@ -16,6 +16,7 @@
# production # production
/build /build
/build-ent
# misc # misc
.DS_Store .DS_Store

15
ui/craco.config.js Normal file
View File

@ -0,0 +1,15 @@
// this workaround fix a warning of mini-css-extract-plugin throws "Conflicting order" during build
// https://github.com/facebook/create-react-app/issues/5372
module.exports = {
webpack: {
configure: (webpackConfig) => {
const instanceOfMiniCssExtractPlugin = webpackConfig.plugins.find(
(plugin) => plugin.options && plugin.options.ignoreOrder != null,
);
if(instanceOfMiniCssExtractPlugin)
instanceOfMiniCssExtractPlugin.options.ignoreOrder = true;
return webpackConfig;
},
}
}

5547
ui/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,7 @@
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@craco/craco": "^6.4.3",
"@material-ui/core": "^4.11.3", "@material-ui/core": "^4.11.3",
"@material-ui/icons": "^4.11.2", "@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.60", "@material-ui/lab": "^4.0.0-alpha.60",
@ -32,7 +33,6 @@
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"react-graph-vis": "^1.0.7", "react-graph-vis": "^1.0.7",
"react-lowlight": "^3.0.0", "react-lowlight": "^3.0.0",
"react-scripts": "4.0.3",
"react-scrollable-feed-virtualized": "^1.4.9", "react-scrollable-feed-virtualized": "^1.4.9",
"react-syntax-highlighter": "^15.4.3", "react-syntax-highlighter": "^15.4.3",
"react-toastify": "^8.0.3", "react-toastify": "^8.0.3",
@ -43,11 +43,15 @@
"web-vitals": "^1.1.1", "web-vitals": "^1.1.1",
"xml-formatter": "^2.6.0" "xml-formatter": "^2.6.0"
}, },
"devDependencies": {
"env-cmd": "^10.0.1"
},
"scripts": { "scripts": {
"start": "react-scripts start", "start": "craco start",
"build": "react-scripts build", "start-ent": "./node_modules/.bin/env-cmd -f .env.enterprise craco start",
"test": "react-scripts test", "build": "./node_modules/.bin/env-cmd -f .env.basic craco build & BUILD_PATH='./build-ent' ./node_modules/.bin/env-cmd -f .env.enterprise craco build",
"eject": "react-scripts eject" "test": "craco test",
"eject": "craco eject"
}, },
"eslintConfig": { "eslintConfig": {
"extends": [ "extends": [

View File

@ -28,7 +28,6 @@
<script> <script>
try { try {
// Injected from server // Injected from server
window.isEnt = __IS_STANDALONE__
window.isOasEnabled = __IS_OAS_ENABLED__ window.isOasEnabled = __IS_OAS_ENABLED__
window.isServiceMapEnabled = __IS_SERVICE_MAP_ENABLED__ window.isServiceMapEnabled = __IS_SERVICE_MAP_ENABLED__
} }

18
ui/src/AppChooser.tsx Normal file
View File

@ -0,0 +1,18 @@
import React, {Suspense} from 'react';
import LoadingOverlay from "./components/LoadingOverlay";
const AppChooser = () => {
let MainComponent;
if (process.env.REACT_APP_OVERRIDE_IS_ENTERPRISE === "true") {
MainComponent = React.lazy(() => import('./EntApp'));
} else {
MainComponent = React.lazy(() => import('./App'));
}
return <Suspense fallback={<LoadingOverlay/>}>
<MainComponent/>
</Suspense>;
}
export default AppChooser;

View File

@ -1,17 +1,16 @@
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import './index.sass'; import './index.sass';
import App from './App';
import EntApp from "./EntApp";
import {ToastContainer} from "react-toastify"; import {ToastContainer} from "react-toastify";
import 'react-toastify/dist/ReactToastify.css'; import 'react-toastify/dist/ReactToastify.css';
import {RecoilRoot} from "recoil"; import {RecoilRoot} from "recoil";
import AppChooser from "./AppChooser";
ReactDOM.render( ReactDOM.render(
<React.StrictMode> <React.StrictMode>
<RecoilRoot>
<> <>
{window["isEnt"] ? <EntApp/> : <App/>} <RecoilRoot>
<AppChooser/>
<ToastContainer <ToastContainer
position="bottom-right" position="bottom-right"
autoClose={5000} autoClose={5000}
@ -23,8 +22,7 @@ ReactDOM.render(
draggable draggable
pauseOnHover pauseOnHover
/> />
</>
</RecoilRoot> </RecoilRoot>
</>
</React.StrictMode>, </React.StrictMode>,
document.getElementById('root') document.getElementById('root'));
);