From 560c11c67b60627984a48716d2f5ef90f113b4de Mon Sep 17 00:00:00 2001 From: foxxy Date: Wed, 12 Mar 2025 13:14:48 +0300 Subject: [PATCH] MSP-5097 add env variables to Dockerfile --- .eslintrc | 55 ++++++++++++++++++++++++++++++++++++++---------- .prettierignore | 3 +++ Dockerfile | 2 ++ entrypoint.sh | 16 ++++++++++++++ index.html | 2 +- public/config.js | 0 6 files changed, 66 insertions(+), 12 deletions(-) create mode 100644 .prettierignore create mode 100755 entrypoint.sh delete mode 100644 public/config.js diff --git a/.eslintrc b/.eslintrc index 420c52b..a1bc645 100644 --- a/.eslintrc +++ b/.eslintrc @@ -13,7 +13,12 @@ "plugin:@typescript-eslint/recommended", "plugin:import/typescript" ], - "ignorePatterns": ["node_modules", "build", "generateVersionFile.cjs"], + "ignorePatterns": [ + "node_modules", + "build", + "generateVersionFile.cjs", + "config.template.js" + ], "parser": "@typescript-eslint/parser", "parserOptions": { "ecmaFeatures": { @@ -33,28 +38,48 @@ ], "rules": { "import/default": "off", - "import/no-named-as-default":"off", + "import/no-named-as-default": "off", "prettier/prettier": "off", - "quotes": ["error", "single"], + "quotes": [ + "error", + "single" + ], "react/jsx-filename-extension": [ 1, { - "extensions": [".js", ".jsx", ".tsx"] + "extensions": [ + ".js", + ".jsx", + ".tsx" + ] } ], "react/jsx-one-expression-per-line": "off", "react/prop-types": 0, "react/react-in-jsx-scope": "off", - "semi": ["error", "never"], - "@typescript-eslint/no-unused-vars": ["off"], - "@typescript-eslint/no-explicit-any": ["off", null], - "@typescript-eslint/no-non-null-assertion": ["off"], + "semi": [ + "error", + "never" + ], + "@typescript-eslint/no-unused-vars": [ + "off" + ], + "@typescript-eslint/no-explicit-any": [ + "off", + null + ], + "@typescript-eslint/no-non-null-assertion": [ + "off" + ], "import/no-unresolved": "error", "no-unused-vars": "off" }, "settings": { "import/parsers": { - "@typescript-eslint/parser": [".ts", ".tsx"] + "@typescript-eslint/parser": [ + ".ts", + ".tsx" + ] }, "react": { "version": "detect" @@ -64,8 +89,16 @@ "alwaysTryTypes": true }, "node": { - "extensions": [".js", ".jsx", ".ts", ".tsx"], - "moduleDirectory": ["node_modules", "src/"] + "extensions": [ + ".js", + ".jsx", + ".ts", + ".tsx" + ], + "moduleDirectory": [ + "node_modules", + "src/" + ] } } } diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..06893bf --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +build +cfg +/config.template.js diff --git a/Dockerfile b/Dockerfile index 44c1610..14e8d16 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,3 +26,5 @@ 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 entrypoint.sh /opt/msp/isp-admin-ui/entrypoint.sh +ENTRYPOINT ["/opt/msp/isp-admin-ui/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..9076b48 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +CONFIG_PATH="/opt/msp/isp-admin-ui/config.js" + +cat < $CONFIG_PATH +// DON'T TOUCH +// THIS FILE FOR PRODUCTION BUILD + +window.config = { + ENABLE_PASSWORD_LOGIN: ${ENABLE_PASSWORD_LOGIN:-true}, + APP_TOKEN: '${APP_TOKEN:-"default_token"}', +}; +EOF + + +exec nginx -g "daemon off;" diff --git a/index.html b/index.html index 29542bb..85cc9d6 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,7 @@ - + Панель администратора diff --git a/public/config.js b/public/config.js deleted file mode 100644 index e69de29..0000000