diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 7371e4e..2aa2823 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,7 +1,7 @@ version: '3' services: polaris-redis: - image: redis:latest # 使用官方Redis镜像 + image: ${REGISTRY}redis:latest # 使用官方Redis镜像 restart: unless-stopped healthcheck: test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ] @@ -21,7 +21,7 @@ services: command: redis-server /opt/polaris/redis/redis.conf --appendonly yes polaris-mysql: - image: mysql:8 # 使用官方MySQL 8镜像 + image: ${REGISTRY}mysql:8 # 使用官方MySQL 8镜像 restart: unless-stopped healthcheck: test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/3306" ] @@ -54,7 +54,7 @@ services: ] polaris-media: - image: zlmediakit/zlmediakit:master # 替换为官方镜像 + image: ${REGISTRY}zlmediakit/zlmediakit:master # 替换为官方镜像 restart: always networks: - media-net @@ -80,7 +80,7 @@ services: ] polaris-wvp: - image: polaris-wvp:2.7.7 + image: ${REGISTRY}polaris-wvp:2.7.7 restart: always networks: - media-net @@ -128,10 +128,8 @@ services: RecordPushLive: ${RecordPushLive:-false} polaris-nginx: - # 显式指定构建上下文和Dockerfile路径 - build: - context: .. # 构建上下文的根路径 - dockerfile: ./docker/nginx/Dockerfile # 相对于上下文路径的Dockerfile位置 + image: ${REGISTRY}polaris-nginx:latest + restart: always ports: - "${WebHttp:-8080}:8080" depends_on: diff --git a/docker/nginx/Dockerfile b/docker/nginx/Dockerfile index 5e57aab..83d0d90 100644 --- a/docker/nginx/Dockerfile +++ b/docker/nginx/Dockerfile @@ -5,7 +5,7 @@ RUN apt-get update && \ apt-get install -y nodejs npm && \ rm -rf /var/lib/apt/lists/* -COPY ./web /build +COPY ./docker/nginx/web /build WORKDIR /build RUN npm --registry=https://registry.npmmirror.com install diff --git a/docker/nginx/Dockerfile.registry b/docker/nginx/Dockerfile.registry new file mode 100644 index 0000000..b26ccac --- /dev/null +++ b/docker/nginx/Dockerfile.registry @@ -0,0 +1,27 @@ +FROM registry.t-aaron.com/ubuntu:24.04 AS builder + + +RUN apt-get update && \ + apt-get install -y nodejs npm && \ + rm -rf /var/lib/apt/lists/* + +COPY ./docker/nginx/web /build +WORKDIR /build + +RUN npm --registry=https://registry.npmmirror.com install +RUN npm run build:prod + +WORKDIR /src/main/resources +RUN ls + +WORKDIR /src/main/resources/static +RUN ls + +FROM registry.t-aaron.com/nginx:alpine + +ARG TZ=Asia/Shanghai + + +COPY --from=builder /src/main/resources/static /opt/dist + +CMD ["nginx","-g","daemon off;"] diff --git a/docker/nginx/build-and-push-nginx.sh b/docker/nginx/build-and-push-nginx.sh new file mode 100755 index 0000000..fa4dd21 --- /dev/null +++ b/docker/nginx/build-and-push-nginx.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# 构建并推送 nginx 镜像到私有仓库 +# 使用方法: 在 docker/nginx 目录下执行 ./build-and-push-nginx.sh + +set -e + +# 获取脚本所在目录 +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# 项目根目录(脚本所在目录的上两级) +PROJECT_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)" + +# 配置变量 +REGISTRY="registry.t-aaron.com" +IMAGE_NAME="polaris-nginx" +VERSION="latest" +PLATFORM="linux/amd64" +DOCKERFILE="Dockerfile.registry" + +# 完整镜像名称 +FULL_IMAGE_NAME="${REGISTRY}/${IMAGE_NAME}:${VERSION}" + +echo "==========================================" +echo "开始构建 Nginx 镜像" +echo "==========================================" +echo "脚本目录: ${SCRIPT_DIR}" +echo "项目根目录: ${PROJECT_ROOT}" +echo "镜像名称: ${FULL_IMAGE_NAME}" +echo "平台架构: ${PLATFORM}" +echo "Dockerfile: ${SCRIPT_DIR}/${DOCKERFILE}" +echo "==========================================" + +# 检查 Dockerfile 是否存在 +if [ ! -f "${SCRIPT_DIR}/${DOCKERFILE}" ]; then + echo "错误: 未找到 Dockerfile: ${SCRIPT_DIR}/${DOCKERFILE}" + exit 1 +fi + +# 检查 buildx 是否可用 +if ! docker buildx version &> /dev/null; then + echo "错误: docker buildx 不可用" + echo "请先安装 docker buildx" + exit 1 +fi + +# 切换到项目根目录作为构建上下文 +cd "${PROJECT_ROOT}" + +# 构建并推送镜像 +echo "" +echo "开始构建镜像..." +docker buildx build \ + --no-cache \ + --platform ${PLATFORM} \ + -t ${FULL_IMAGE_NAME} \ + -f docker/nginx/${DOCKERFILE} \ + --push \ + . + +echo "" +echo "==========================================" +echo "构建完成!" +echo "镜像已推送到: ${FULL_IMAGE_NAME}" +echo "==========================================" diff --git a/docker/nginx/build.sh b/docker/nginx/build.sh index 717d546..d449d19 100755 --- a/docker/nginx/build.sh +++ b/docker/nginx/build.sh @@ -1,11 +1,36 @@ -#/bin/bash +#!/bin/bash + +# 本地构建 nginx 镜像 +# 使用方法: 在 docker/nginx 目录下执行 ./build.sh + set -e -version=2.7.3 +# 获取脚本所在目录 +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# 项目根目录(脚本所在目录的上两级) +PROJECT_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)" -rm ./dist/static/js/config.js -cp ./config.js ./dist/static/js/ +# 配置变量 +IMAGE_NAME="polaris-nginx" +VERSION="latest" -docker build -t polaris-nginx:${version} . -docker tag polaris-nginx:${version} polaris-tian-docker.pkg.coding.net/qt/polaris/polaris-nginx:${version} -docker tag polaris-nginx:${version} polaris-tian-docker.pkg.coding.net/qt/polaris/polaris-nginx:latest \ No newline at end of file +echo "==========================================" +echo "开始构建本地 Nginx 镜像" +echo "==========================================" +echo "项目根目录: ${PROJECT_ROOT}" +echo "镜像名称: ${IMAGE_NAME}:${VERSION}" +echo "==========================================" + +# 切换到项目根目录作为构建上下文 +cd "${PROJECT_ROOT}" + +# 构建镜像 +echo "" +echo "开始构建镜像..." +docker build -t ${IMAGE_NAME}:${VERSION} -f docker/nginx/Dockerfile . + +echo "" +echo "==========================================" +echo "构建完成!" +echo "本地镜像: ${IMAGE_NAME}:${VERSION}" +echo "==========================================" \ No newline at end of file diff --git a/docker/nginx/web/.editorconfig b/docker/nginx/web/.editorconfig new file mode 100644 index 0000000..ea6e20f --- /dev/null +++ b/docker/nginx/web/.editorconfig @@ -0,0 +1,14 @@ +# http://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +insert_final_newline = false +trim_trailing_whitespace = false diff --git a/docker/nginx/web/.env.development b/docker/nginx/web/.env.development new file mode 100644 index 0000000..de583d0 --- /dev/null +++ b/docker/nginx/web/.env.development @@ -0,0 +1,5 @@ +# just a flag +ENV = 'development' + +# base api +VUE_APP_BASE_API = '/dev-api' diff --git a/docker/nginx/web/.env.production b/docker/nginx/web/.env.production new file mode 100644 index 0000000..8994f69 --- /dev/null +++ b/docker/nginx/web/.env.production @@ -0,0 +1,6 @@ +# just a flag +ENV = 'production' + +# base api +VUE_APP_BASE_API = '' + diff --git a/docker/nginx/web/.env.staging b/docker/nginx/web/.env.staging new file mode 100644 index 0000000..a8793a0 --- /dev/null +++ b/docker/nginx/web/.env.staging @@ -0,0 +1,8 @@ +NODE_ENV = production + +# just a flag +ENV = 'staging' + +# base api +VUE_APP_BASE_API = '/stage-api' + diff --git a/docker/nginx/web/.eslintignore b/docker/nginx/web/.eslintignore new file mode 100644 index 0000000..e6529fc --- /dev/null +++ b/docker/nginx/web/.eslintignore @@ -0,0 +1,4 @@ +build/*.js +src/assets +public +dist diff --git a/docker/nginx/web/.eslintrc.js b/docker/nginx/web/.eslintrc.js new file mode 100644 index 0000000..303d049 --- /dev/null +++ b/docker/nginx/web/.eslintrc.js @@ -0,0 +1,48 @@ +module.exports = { + root: true, + env: { + node: true, + browser: true, + }, + extends: ["plugin:vue/essential", "eslint:recommended"], + parserOptions: { + parser: "babel-eslint", + }, + rules: { + // Disable or downgrade problematic rules + "vue/require-prop-types": "off", + "vue/require-default-prop": "off", + "vue/no-unused-vars": "warn", + "no-unused-vars": "warn", + "no-undef": "warn", + eqeqeq: "warn", + "no-return-assign": "warn", + "new-cap": "warn", + "vue/html-self-closing": "off", + "vue/html-closing-bracket-spacing": "off", + "vue/this-in-template": "off", + "vue/require-v-for-key": "warn", + "vue/valid-v-model": "warn", + "vue/attributes-order": "off", + "no-multiple-empty-lines": "warn", + + // Style rules - make them warnings instead of errors + quotes: ["warn", "single"], + "comma-dangle": ["warn", "never"], + "space-in-parens": "warn", + "comma-spacing": "warn", + "object-curly-spacing": ["warn", "always"], + "arrow-spacing": "warn", + semi: ["warn", "never"], + "no-multi-spaces": "warn", + + // Turn off console warnings for development + "no-console": process.env.NODE_ENV === "production" ? "warn" : "off", + "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", + }, + globals: { + // Define global variables to prevent 'undefined' errors + ZLMRTCClient: "readonly", + jessibuca: "readonly", + }, +} diff --git a/docker/nginx/web/.gitignore b/docker/nginx/web/.gitignore new file mode 100644 index 0000000..9ad28d2 --- /dev/null +++ b/docker/nginx/web/.gitignore @@ -0,0 +1,16 @@ +.DS_Store +node_modules/ +dist/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* +package-lock.json +tests/**/coverage/ + +# Editor directories and files +.idea +.vscode +*.suo +*.ntvs* +*.njsproj +*.sln diff --git a/docker/nginx/web/.travis.yml b/docker/nginx/web/.travis.yml new file mode 100644 index 0000000..f4be7a0 --- /dev/null +++ b/docker/nginx/web/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: 10 +script: npm run test +notifications: + email: false diff --git a/docker/nginx/web/LICENSE b/docker/nginx/web/LICENSE new file mode 100644 index 0000000..6151575 --- /dev/null +++ b/docker/nginx/web/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017-present PanJiaChen + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/docker/nginx/web/README-zh.md b/docker/nginx/web/README-zh.md new file mode 100644 index 0000000..1beec9b --- /dev/null +++ b/docker/nginx/web/README-zh.md @@ -0,0 +1,111 @@ +# vue-admin-template + +> 这是一个极简的 vue admin 管理后台。它只包含了 Element UI & axios & iconfont & permission control & lint,这些搭建后台必要的东西。 + +[线上地址](http://panjiachen.github.io/vue-admin-template) + +[国内访问](https://panjiachen.gitee.io/vue-admin-template) + +目前版本为 `v4.0+` 基于 `vue-cli` 进行构建,若你想使用旧版本,可以切换分支到[tag/3.11.0](https://github.com/PanJiaChen/vue-admin-template/tree/tag/3.11.0),它不依赖 `vue-cli`。 + +
+ SPONSORED BY +
+
+
+
+
+
](http://godban.github.io/browsers-support-badges/)IE / Edge | [
](http://godban.github.io/browsers-support-badges/)Firefox | [
](http://godban.github.io/browsers-support-badges/)Chrome | [
](http://godban.github.io/browsers-support-badges/)Safari |
+| --------- | --------- | --------- | --------- |
+| IE10, IE11, Edge| last 2 versions| last 2 versions| last 2 versions
+
+## License
+
+[MIT](https://github.com/PanJiaChen/vue-admin-template/blob/master/LICENSE) license.
+
+Copyright (c) 2017-present PanJiaChen
diff --git a/docker/nginx/web/README.md b/docker/nginx/web/README.md
new file mode 100644
index 0000000..fa54b78
--- /dev/null
+++ b/docker/nginx/web/README.md
@@ -0,0 +1,99 @@
+# vue-admin-template
+
+English | [简体中文](./README-zh.md)
+
+> A minimal vue admin template with Element UI & axios & iconfont & permission control & lint
+
+**Live demo:** http://panjiachen.github.io/vue-admin-template
+
+
+**The current version is `v4.0+` build on `vue-cli`. If you want to use the old version , you can switch branch to [tag/3.11.0](https://github.com/PanJiaChen/vue-admin-template/tree/tag/3.11.0), it does not rely on `vue-cli`**
+
++ SPONSORED BY +
+
+
+
+
+
](http://godban.github.io/browsers-support-badges/)IE / Edge | [
](http://godban.github.io/browsers-support-badges/)Firefox | [
](http://godban.github.io/browsers-support-badges/)Chrome | [
](http://godban.github.io/browsers-support-badges/)Safari |
+| --------- | --------- | --------- | --------- |
+| IE10, IE11, Edge| last 2 versions| last 2 versions| last 2 versions
+
+## License
+
+[MIT](https://github.com/PanJiaChen/vue-admin-template/blob/master/LICENSE) license.
+
+Copyright (c) 2017-present PanJiaChen
diff --git a/docker/nginx/web/babel.config.js b/docker/nginx/web/babel.config.js
new file mode 100644
index 0000000..fb82b27
--- /dev/null
+++ b/docker/nginx/web/babel.config.js
@@ -0,0 +1,14 @@
+module.exports = {
+ presets: [
+ // https://github.com/vuejs/vue-cli/tree/master/packages/@vue/babel-preset-app
+ '@vue/cli-plugin-babel/preset'
+ ],
+ 'env': {
+ 'development': {
+ // babel-plugin-dynamic-import-node plugin only does one thing by converting all import() to require().
+ // This plugin can significantly increase the speed of hot updates, when you have a large number of pages.
+ // https://panjiachen.github.io/vue-element-admin-site/guide/advanced/lazy-loading.html
+ 'plugins': ['dynamic-import-node']
+ }
+ }
+}
diff --git a/docker/nginx/web/jest.config.js b/docker/nginx/web/jest.config.js
new file mode 100644
index 0000000..143cdc8
--- /dev/null
+++ b/docker/nginx/web/jest.config.js
@@ -0,0 +1,24 @@
+module.exports = {
+ moduleFileExtensions: ['js', 'jsx', 'json', 'vue'],
+ transform: {
+ '^.+\\.vue$': 'vue-jest',
+ '.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$':
+ 'jest-transform-stub',
+ '^.+\\.jsx?$': 'babel-jest'
+ },
+ moduleNameMapper: {
+ '^@/(.*)$': '