From b2ee9e3a5322cc33e28f0b3ce905072327803036 Mon Sep 17 00:00:00 2001 From: Stille Date: Mon, 11 Jul 2022 16:17:01 +0800 Subject: [PATCH] support config file --- .env | 2 -- .env.production | 2 -- Dockerfile | 4 ++-- README.md | 17 ++++++++++++++--- public/conf/config.js | 16 ++++++++++++++++ public/index.html | 1 + src/layouts/components/header/NavBar.vue | 16 +++++++++------- src/layouts/components/header/NavBarMobile.vue | 8 ++++---- src/views/home/HomeForm.vue | 4 ++-- start.sh | 12 ++++++++---- 10 files changed, 56 insertions(+), 26 deletions(-) delete mode 100644 .env delete mode 100644 .env.production create mode 100644 public/conf/config.js diff --git a/.env b/.env deleted file mode 100644 index be08eae..0000000 --- a/.env +++ /dev/null @@ -1,2 +0,0 @@ -NODE_ENV = 'development' -VUE_APP_BASE_API_URL = 'http://127.0.0.1:25500' \ No newline at end of file diff --git a/.env.production b/.env.production deleted file mode 100644 index 87a250a..0000000 --- a/.env.production +++ /dev/null @@ -1,2 +0,0 @@ -NODE_ENV = 'production' -VUE_APP_BASE_API_URL = 'http://127.0.0.1:25500' \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index af8cc69..aea065f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,6 @@ RUN npm run build FROM nginx:1.16-alpine COPY --from=build /app/dist /usr/share/nginx/html -COPY start.sh / +COPY . /app EXPOSE 80 -CMD [ "sh", "-c", "/start.sh" ] +CMD [ "sh", "-c", "/app/start.sh" ] diff --git a/README.md b/README.md index a7cf5ac..9133cc6 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Docker [stilleshan/subweb](https://hub.docker.com/r/stilleshan/subweb)* ## 部署 ### docker 本地版 -*适用于本机部署使用* +*适用于本机快速部署使用* ```shell docker run -d --name subweb --restart always \ -p 18080:80 \ @@ -23,11 +23,22 @@ docker run -d --name subweb --restart always \ 访问 `http://127.0.0.1:18080` -### docker 自定义后端 API 地址 -修改`API_URL`环境变量为你的后端 API 地址 +### docker 自定义版 +自定义版可以挂载配置文件来修改`API 地址`,`站点名称`,`导航链接`. +参考以下命令,修改本地挂载路径,启动容器后会生成`config.js`配置文件,更改后刷新生效. + ```shell docker run -d --name subweb --restart always \ -p 18080:80 \ + -v /PATH/subweb/conf:/usr/share/nginx/html/conf \ + stilleshan/subweb +``` + +同时也可以不挂载目录,直接通过`-e`环境变量来修改`API 地址`和`站点名称`,但是无法修改`导航链接`. +```shell +docker run -d --name subweb --restart always \ + -p 18080:80 \ + -e SITE_NAME=subweb \ -e API_URL=https://sub.ops.ci \ stilleshan/subweb ``` diff --git a/public/conf/config.js b/public/conf/config.js new file mode 100644 index 0000000..5460480 --- /dev/null +++ b/public/conf/config.js @@ -0,0 +1,16 @@ +window.config = { + siteName: 'Subconverter Web', + apiUrl: 'http://127.0.0.1:25500', + menuItem: [ + { + title: '首页', + link: '/', + target: '', + }, + { + title: 'GitHub', + link: 'https://github.com/stilleshan/subweb', + target: '_blank', + }, + ], +}; diff --git a/public/index.html b/public/index.html index 3e5a139..0aaa0f1 100644 --- a/public/index.html +++ b/public/index.html @@ -6,6 +6,7 @@ <%= htmlWebpackPlugin.options.title %> +