Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions frontend-new/public/env-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

window.__ENV__ = window.__ENV__ || {};
window.__ENV__.API_BASE_URL = "";
1 change: 1 addition & 0 deletions frontend-new/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<meta name="keywords" content=""/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title>RocketMQ Dashboard</title>
<script src="./env-config.js"></script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
2 changes: 1 addition & 1 deletion frontend-new/src/api/remoteApi/remoteApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

const appConfig = {
apiBaseUrl: process.env.REACT_APP_API_BASE_URL || window.location.origin
apiBaseUrl: (window.__ENV__ && window.__ENV__.API_BASE_URL) || process.env.REACT_APP_API_BASE_URL || window.location.origin
};

let _redirectHandler = null;
Expand Down
5 changes: 4 additions & 1 deletion src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ VOLUME /tmp
ADD rocketmq-dashboard-*.jar rocketmq-dashboard.jar
RUN sh -c 'touch /rocketmq-dashboard.jar'
ENV JAVA_OPTS=""
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -jar /rocketmq-dashboard.jar" ]
ENV API_BASE_URL=""
COPY env-config-entrypoint.sh /env-config-entrypoint.sh
RUN chmod +x /env-config-entrypoint.sh
ENTRYPOINT [ "/env-config-entrypoint.sh" ]
31 changes: 31 additions & 0 deletions src/main/docker/env-config-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# If API_BASE_URL is set, extract env-config.js from the jar and update it
if [ -n "$API_BASE_URL" ]; then
TMP_DIR=$(mktemp -d)
cd "$TMP_DIR"
jar xf /rocketmq-dashboard.jar BOOT-INF/classes/static/env-config.js
cat > BOOT-INF/classes/static/env-config.js << EOF
window.__ENV__ = window.__ENV__ || {};
window.__ENV__.API_BASE_URL = "$API_BASE_URL";
EOF
jar uf /rocketmq-dashboard.jar BOOT-INF/classes/static/env-config.js
cd /
rm -rf "$TMP_DIR"
fi

exec java $JAVA_OPTS -jar /rocketmq-dashboard.jar