MSP-6791 add support public-path
This commit is contained in:
1 parent
8c9531010c
commit
b04b790a4d
8 files changed
+55
-24
No files matched your search
@@ -1,2 +1,3 @@
|
||||
PROXY_URL=
|
||||
PUBLIC_PATH=
|
||||
VITE_APP_TOKEN=
|
||||
+7
-4
@@ -1,5 +1,5 @@
|
||||
ARG NODE_VERSION=lts
|
||||
|
||||
ARG PUBLIC_PATH=/
|
||||
FROM node:${NODE_VERSION}-alpine as base
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
@@ -22,9 +22,12 @@ COPY . .
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:alpine-slim as final
|
||||
|
||||
ENV PUBLIC_PATH=$PUBLIC_PATH
|
||||
|
||||
RUN rm -f /etc/nginx/conf.d/default.conf
|
||||
COPY cfg/80_isp-admin-ui.conf /etc/nginx/conf.d/80_isp-admin-ui.conf
|
||||
COPY --from=build /usr/src/app/build /opt/msp/isp-admin-ui
|
||||
COPY --from=build /usr/src/app/build /opt/msp/isp-admin-ui${PUBLIC_PATH}
|
||||
|
||||
COPY entrypoint.sh /opt/msp/isp-admin-ui/entrypoint.sh
|
||||
ENTRYPOINT ["/opt/msp/isp-admin-ui/entrypoint.sh"]
|
||||
COPY entrypoint.sh /opt/msp/isp-admin-ui${PUBLIC_PATH}entrypoint.sh
|
||||
ENTRYPOINT sh -c "/opt/msp/isp-admin-ui${PUBLIC_PATH}entrypoint.sh"
|
||||
@@ -7,7 +7,7 @@ server {
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
add_header Pragma "no-cache"; # Для совместимости с HTTP/1.0
|
||||
expires off;
|
||||
try_files $uri /index.html;
|
||||
try_files $uri __PUBLIC_PATH__index.html;
|
||||
}
|
||||
|
||||
location /api {
|
||||
|
||||
+29
-4
@@ -1,16 +1,41 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
CONFIG_PATH="/opt/msp/isp-admin-ui/config.js"
|
||||
PUBLIC_PATH="${PUBLIC_PATH:-/}"
|
||||
|
||||
cat <<EOF > $CONFIG_PATH
|
||||
// DON'T TOUCH
|
||||
// THIS FILE FOR PRODUCTION BUILD
|
||||
PUBLIC_PATH="$(echo "$PUBLIC_PATH" | sed -E 's|^/*|/|; s|/*$|/|')"
|
||||
|
||||
echo "Using normalized PUBLIC_PATH: '$PUBLIC_PATH'"
|
||||
|
||||
# Генерация конфигурации приложения
|
||||
CONFIG_DIR="/opt/msp/isp-admin-ui${PUBLIC_PATH}"
|
||||
CONFIG_PATH="${CONFIG_DIR}config.js"
|
||||
|
||||
mkdir -p "$CONFIG_DIR"
|
||||
|
||||
cat <<EOF > "$CONFIG_PATH"
|
||||
window.config = {
|
||||
ENABLE_PASSWORD_LOGIN: ${ENABLE_PASSWORD_LOGIN:-true},
|
||||
APP_TOKEN: '${APP_TOKEN:-"default_token"}',
|
||||
};
|
||||
EOF
|
||||
|
||||
echo "Generated config at: $CONFIG_PATH"
|
||||
|
||||
# Подготовка nginx-конфига: заменяем __PUBLIC_PATH__ на реальное значение
|
||||
NGINX_SRC="/etc/nginx/conf.d/80_isp-admin-ui.conf"
|
||||
TMP_FILE="${NGINX_SRC}.tmp"
|
||||
|
||||
echo "Substituting __PUBLIC_PATH__ with: '${PUBLIC_PATH}'"
|
||||
sed "s|__PUBLIC_PATH__|${PUBLIC_PATH}|g" "$NGINX_SRC" > "$TMP_FILE"
|
||||
|
||||
# Проверка результата
|
||||
echo "=== Generated nginx config ==="
|
||||
cat "$TMP_FILE"
|
||||
echo "=== End nginx config ==="
|
||||
|
||||
# Заменяем оригинальный конфиг
|
||||
mv "$TMP_FILE" "$NGINX_SRC"
|
||||
|
||||
echo "Starting nginx..."
|
||||
exec nginx -g "daemon off;"
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
<script type="module">
|
||||
window.AppVersion = APP_VERSION
|
||||
</script>
|
||||
<script src="/config.js"></script>
|
||||
<script src="%BASE_URL%config.js"></script>
|
||||
<title>Панель администратора</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Generated
+12
-12
@@ -12,8 +12,8 @@
|
||||
"@reduxjs/toolkit": "^2.2.3",
|
||||
"axios": "^1.7.7",
|
||||
"dayjs": "^1.11.10",
|
||||
"isp-admin-ui-kit": "^1.4.1",
|
||||
"isp-ui-kit": "^0.22.1",
|
||||
"isp-admin-ui-kit": "^1.5.2",
|
||||
"isp-ui-kit": "^0.23.0",
|
||||
"monaco-editor": "^0.52.0",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
@@ -9709,9 +9709,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/isp-admin-ui-kit": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/isp-admin-ui-kit/-/isp-admin-ui-kit-1.4.1.tgz",
|
||||
"integrity": "sha512-H3EIFDRUzlLsJVI01S6KxvN73hSkuV6FtK3C5djKbWoPmd+LK8rlodAmY2TjBfHoG9upJbwyJMHKdWRpiXYJLQ==",
|
||||
"version": "1.5.2",
|
||||
"resolved": "https://registry.npmjs.org/isp-admin-ui-kit/-/isp-admin-ui-kit-1.5.2.tgz",
|
||||
"integrity": "sha512-lwg7q4UD0fP+YE8bCSIz/KZKg/+WjBrRsnfQeuNydcznpZjuUuJm9GaE50Hu3WVd2HqBeD4mMlHeN55onBQP0g==",
|
||||
"dependencies": {
|
||||
"@apidevtools/json-schema-ref-parser": "^9.0.6",
|
||||
"@rjsf/antd": "^5.21.2",
|
||||
@@ -9726,7 +9726,7 @@
|
||||
"simplebar-react": "^3.2.4"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@rollup/rollup-linux-x64-gnu": "^4.52.5"
|
||||
"@rollup/rollup-linux-x64-gnu": "^4.53.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@monaco-editor/react": "^4.6.0",
|
||||
@@ -9744,9 +9744,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/isp-admin-ui-kit/node_modules/@rollup/rollup-linux-x64-gnu": {
|
||||
"version": "4.52.5",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.52.5.tgz",
|
||||
"integrity": "sha512-hXGLYpdhiNElzN770+H2nlx+jRog8TyynpTVzdlc6bndktjKWyZyiCsuDAlpd+j+W+WNqfcyAWz9HxxIGfZm1Q==",
|
||||
"version": "4.53.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.53.3.tgz",
|
||||
"integrity": "sha512-3EhFi1FU6YL8HTUJZ51imGJWEX//ajQPfqWLI3BQq4TlvHy4X0MOr5q3D2Zof/ka0d5FNdPwZXm3Yyib/UEd+w==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@@ -9757,9 +9757,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/isp-ui-kit": {
|
||||
"version": "0.22.1",
|
||||
"resolved": "https://registry.npmjs.org/isp-ui-kit/-/isp-ui-kit-0.22.1.tgz",
|
||||
"integrity": "sha512-8eJy4g7rW2MAGUpQxiUvuuYyaRXZ3jcrSg0UZknfMY4cGt6Sae4C1816H/okMojs2spI8RkDV5w6YqBTfC2J0w==",
|
||||
"version": "0.23.0",
|
||||
"resolved": "https://registry.npmjs.org/isp-ui-kit/-/isp-ui-kit-0.23.0.tgz",
|
||||
"integrity": "sha512-VH7VlGEwFO59xlZBwAJLlNZZp1Gi4k9QiSjVspDXosMK0c48WHOi6nYeKQxYtR3owGFm4lPsDNH85C67457CiA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dayjs": "^1.11.13",
|
||||
|
||||
+2
-2
@@ -18,8 +18,8 @@
|
||||
"@reduxjs/toolkit": "^2.2.3",
|
||||
"axios": "^1.7.7",
|
||||
"dayjs": "^1.11.10",
|
||||
"isp-admin-ui-kit": "^1.4.1",
|
||||
"isp-ui-kit": "^0.22.1",
|
||||
"isp-admin-ui-kit": "^1.5.2",
|
||||
"isp-ui-kit": "^0.23.0",
|
||||
"monaco-editor": "^0.52.0",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
|
||||
@@ -8,7 +8,9 @@ import tsconfigPaths from 'vite-tsconfig-paths'
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, process.cwd(), '')
|
||||
|
||||
return {
|
||||
base: env.PUBLIC_PATH || '/',
|
||||
optimizeDeps: { exclude: [] },
|
||||
define: {
|
||||
__APP_ENV__: env.APP_ENV,
|
||||
|
||||
Reference in new issue
Block a user