From 4833106964903c9d4b5d753cf7fd4db661d88d11 Mon Sep 17 00:00:00 2001 From: 2183691628 <2183691628@qq.com> Date: Thu, 2 Dec 2021 10:21:01 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20docker=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 32 ++++++++++++++++++++++--- Dockerfile | 5 ++++ README.md | 10 ++++++-- gps_card_admin.sh | 36 ++++++++++++++++++++++++++++ nginx/nginx.conf | 57 ++++++++++++++++++++++++++++++++++++++++++++ setup_development.sh | 30 +++++++++++++++++++++++ setup_production.sh | 28 ++++++++++++++++++++++ setup_test.sh | 31 ++++++++++++++++++++++++ src/utils/model.js | 4 ++-- 9 files changed, 226 insertions(+), 7 deletions(-) create mode 100644 Dockerfile create mode 100644 gps_card_admin.sh create mode 100644 nginx/nginx.conf create mode 100644 setup_development.sh create mode 100644 setup_production.sh create mode 100644 setup_test.sh diff --git a/.eslintrc.js b/.eslintrc.js index d75cc61..18c69a3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,4 +1,5 @@ -module.exports = { +// 取消 自定义eslintrc验证 +/* module.exports = { root: true, parserOptions: { parser: 'babel-eslint', @@ -11,8 +12,6 @@ module.exports = { }, extends: ['plugin:vue/recommended', 'eslint:recommended'], - // add your custom rules here - //it is base on https://github.com/vuejs/eslint-config-vue rules: { "vue/max-attributes-per-line": [0, { "singleline": 10, @@ -199,3 +198,30 @@ module.exports = { 'array-bracket-spacing': [2, 'never'] } } + */ +module.exports = { + root: true, + env: { + node: true, + }, + extends: ["plugin:vue/essential", "eslint:recommended"], + parserOptions: { + parser: "babel-eslint", + }, + rules: { + "no-console": process.env.NODE_ENV === "production" ? "warn" : "off", + "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", + /* "prettier/prettier": "off" */ + }, + overrides: [ + { + files: [ + "**/__tests__/*.{j,t}s?(x)", + "**/tests/unit/**/*.spec.{j,t}s?(x)", + ], + env: { + jest: true, + }, + }, + ], + }; diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..62ce7bc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM nginx +RUN mkdir /app +COPY dist /app +COPY nginx/nginx.conf /etc/nginx/nginx.conf +EXPOSE 80 \ No newline at end of file diff --git a/README.md b/README.md index a742b1f..8599a08 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ @@ -20,4 +20,10 @@ FEATURE ## v1.0.1F `2021年12月1日` FEATURE -- 完成 静态页面编写与交互 \ No newline at end of file +- 完成 静态页面编写与交互 + + +## v1.0.2F +`2021年12月2日` +FEATURE +- 增加 docker部署文件 \ No newline at end of file diff --git a/gps_card_admin.sh b/gps_card_admin.sh new file mode 100644 index 0000000..bfb122c --- /dev/null +++ b/gps_card_admin.sh @@ -0,0 +1,36 @@ +#!/bin/bash +### + # @Date: 2021-11-15 09:37:49 + # @LastEditors: JinxuChen + # @LastEditTime: 2021-12-02 09:20:59 + # @FilePath: \GpsCardAdmin\gps_card_admin.sh + # @description: 功能 +### +environment=$1 +version=$2 +echo "环境变量为${environment},版本为$version!" +if [[ ${environment} = 'production' ]]; then + echo "开始远程构建容器" + docker stop gps_card_admin || true; + docker rm gps_card_admin || true; + docker rmi -f $(docker images | grep registry.cn-shanghai.aliyuncs.com/gps_card/gps_card_admin | awk '{print $3}') + #docker login --username=telpo_linwl@1111649216405698 --password=telpo#1234 registry.cn-shanghai.aliyuncs.com; + docker login --username=rzl_wangjx@1111649216405698 --password=telpo.123 registry.cn-shanghai.aliyuncs.com + docker pull registry.cn-shanghai.aliyuncs.com/gps_card/gps_card_admin:$version + docker run -p 8802:80 -d --restart=always --name gps_card_admin registry.cn-shanghai.aliyuncs.com/gps_card/gps_card_admin:$version; + #删除产生的None镜像 + docker rmi -f $(docker images | grep none | awk '{print $3}') + docker ps -a + +elif [[ ${environment} == 'test' ]]; then + echo "开始在测试环境远程构建容器" + docker stop gps_card_admin || true + docker rm gps_card_admin || true + docker rmi -f $(docker images | grep 139.224.254.18:5000/gps_card_admin | awk '{print $3}') + docker pull 139.224.254.18:5000/gps_card_admin:$version + docker run -p 8802:80 -d --restart=always --name gps_card_admin 139.224.254.18:5000/gps_card_admin:$version; + #删除产生的None镜像 + docker rmi -f $(docker images | grep none | awk '{print $3}') + docker ps -a + +fi \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..3de107b --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,57 @@ +#user nobody; +worker_processes 1; + +#error_log logs/error.log; +#error_log logs/error.log notice; +error_log /var/log/nginx/error.log warn; + +pid /var/run/nginx.pid; + + +events { + accept_mutex on; #设置网路连接序列化,防止惊群现象发生,默认为on + multi_accept on; #设置一个进程是否同时接受多个网络连接,默认为off + use epoll; #事件驱动模型,select|poll|kqueue|epoll|resig|/dev/poll|eventport + worker_connections 1024; +} + + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + #access_log logs/access.log main; + + access_log /var/log/nginx/access.log main; + + sendfile on; + #tcp_nopush on; + + #keepalive_timeout 0; + keepalive_timeout 65; + + + server { + listen 80; + server_name localhost; + + #charset koi8-r; + charset utf-8; + + location / { + root /app; # 指向目录 + index index.html; + try_files $uri $uri/ /index.html; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + } + +} \ No newline at end of file diff --git a/setup_development.sh b/setup_development.sh new file mode 100644 index 0000000..f826e71 --- /dev/null +++ b/setup_development.sh @@ -0,0 +1,30 @@ +### + # @Author: JinxuChen + # @Date: 2021-11-15 + # @LastEditTime: 2021-12-02 09:21:48 + # @LastEditors: JinxuChen + # @Description: In User Settings Edit + # @FilePath: \GpsCardAdmin\setup_development.sh +### +#!/bin/bash +npm -v +npm config set registry https://registry.npm.taobao.org +npm config list +npm install +npm run build-test +image_version=`date +%Y%m%d%H%M`; +docker stop gps_card_admin || true; +# 删除gps_parent_web容器 +docker rm gps_card_admin || true; +# 删除镜像 +docker rmi -f $(docker images | grep telpo/gps_card_admin | awk '{print $3}') +# 构建telpo/gps_card_admin:$image_version镜像 +docker build . -t telpo/gps_card_admin:$image_version; +#删除产生的None镜像 +docker rmi -f $(docker images | grep none | awk '{print $3}') +# 查看镜像列表 +docker images; +# 启动容器 +docker run -p 8802:80 -d --restart=always --name gps_card_admin telpo/gps_card_admin:$image_version; +# 查看日志 +docker logs gps_card_admin; diff --git a/setup_production.sh b/setup_production.sh new file mode 100644 index 0000000..0333cd3 --- /dev/null +++ b/setup_production.sh @@ -0,0 +1,28 @@ +### + # @Author: JinxuChen + # @Date: 2021-11-15 + # @LastEditTime: 2021-12-02 09:22:02 + # @LastEditors: JinxuChen + # @Description: In User Settings Edit + # @FilePath: \GpsCardAdmin\setup_production.sh +### +#!/bin/bash +npm -v +npm install +npm run build +image_version=$version; +# 删除镜像 + docker rmi -f $(docker images | grep registry.cn-shanghai.aliyuncs.com/gps_card/gps_card_admin | awk '{print $3}') + +docker build . -t telpo/gps_card_admin:$image_version; +#TODO:推送镜像到阿里仓库 +echo '=================开始推送镜像=======================' +#docker login --username=telpo_linwl@1111649216405698 --password=telpo#1234 registry.cn-shanghai.aliyuncs.com; +docker login --username=rzl_wangjx@1111649216405698 --password=telpo.123 registry.cn-shanghai.aliyuncs.com +docker tag telpo/gps_card_admin:$image_version registry.cn-shanghai.aliyuncs.com/gps_card/gps_card_admin:$image_version +docker push registry.cn-shanghai.aliyuncs.com/gps_card/gps_card_admin:$image_version +echo '=================推送镜像完成=======================' +#删除产生的None镜像 +docker rmi -f $(docker images | grep none | awk '{print $3}') +# 查看镜像列表 +docker images; diff --git a/setup_test.sh b/setup_test.sh new file mode 100644 index 0000000..7db5e67 --- /dev/null +++ b/setup_test.sh @@ -0,0 +1,31 @@ +### + # @Author: JinxuChen + # @Date: 2021-11-15 + # @LastEditTime: 2021-12-02 09:22:16 + # @LastEditors: JinxuChen + # @Description: In User Settings Edit + # @FilePath: \GpsCardAdmin\setup_test.sh +### +#!/usr/bin/env bash +npm -v +npm config set registry https://registry.npm.taobao.org +npm config list +npm install +npm run build-test + +image_version=$version +# 删除镜像 +docker rmi -f $( + docker images | grep 139.224.254.18:5000/gps_card_admin | awk '{print $3}' +) +# 构建gps_card_admin:$image_version镜像 +docker build . -t telpo/gps_card_admin:$image_version; +#TODO:推送镜像到私有仓库 +echo '=================开始推送镜像=======================' +docker tag telpo/gps_card_admin:$image_version 139.224.254.18:5000/gps_card_admin:$image_version +docker push 139.224.254.18:5000/gps_card_admin:$image_version +echo '=================推送镜像完成=======================' +#删除产生的None镜像 +docker rmi -f $(docker images | grep none | awk '{print $3}') +# 查看镜像列表 +docker images \ No newline at end of file diff --git a/src/utils/model.js b/src/utils/model.js index 9aaa3ae..7bf1952 100644 --- a/src/utils/model.js +++ b/src/utils/model.js @@ -1,8 +1,8 @@ /* * @Date: 2021-11-30 15:09:25 * @LastEditors: JinxuChen - * @LastEditTime: 2021-12-01 18:17:55 + * @LastEditTime: 2021-12-02 10:20:39 * @FilePath: \GpsCardAdmin\src\utils\model.js * @description: 版本号 */ -export const VersionModel = '1.0.1'; \ No newline at end of file +export const VersionModel = '1.0.2'; \ No newline at end of file From ef158c32df915cdbfcd1ce08e17c0351918cbb16 Mon Sep 17 00:00:00 2001 From: 2183691628 <2183691628@qq.com> Date: Thu, 2 Dec 2021 15:09:30 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20docker=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 +++-- gps_card_admin.sh => gps_card_admin_run.sh | 0 2 files changed, 3 insertions(+), 2 deletions(-) rename gps_card_admin.sh => gps_card_admin_run.sh (100%) diff --git a/README.md b/README.md index 8599a08..cf72882 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ @@ -26,4 +26,5 @@ FEATURE ## v1.0.2F `2021年12月2日` FEATURE -- 增加 docker部署文件 \ No newline at end of file +- 增加 docker部署文件 +- 修改 docker部署文件 \ No newline at end of file diff --git a/gps_card_admin.sh b/gps_card_admin_run.sh similarity index 100% rename from gps_card_admin.sh rename to gps_card_admin_run.sh From 13ff64e1995ac06c43d453e5094d610f9becfd5c Mon Sep 17 00:00:00 2001 From: 2183691628 <2183691628@qq.com> Date: Thu, 2 Dec 2021 15:19:49 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20docker=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gps_card_admin_run.sh | 24 ++++++++++++------------ setup_development.sh | 16 ++++++++-------- setup_production.sh | 10 +++++----- setup_test.sh | 10 +++++----- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/gps_card_admin_run.sh b/gps_card_admin_run.sh index bfb122c..264ed36 100644 --- a/gps_card_admin_run.sh +++ b/gps_card_admin_run.sh @@ -2,8 +2,8 @@ ### # @Date: 2021-11-15 09:37:49 # @LastEditors: JinxuChen - # @LastEditTime: 2021-12-02 09:20:59 - # @FilePath: \GpsCardAdmin\gps_card_admin.sh + # @LastEditTime: 2021-12-02 15:19:14 + # @FilePath: \GpsCardAdmin\gps_card_admin_run.sh # @description: 功能 ### environment=$1 @@ -11,24 +11,24 @@ version=$2 echo "环境变量为${environment},版本为$version!" if [[ ${environment} = 'production' ]]; then echo "开始远程构建容器" - docker stop gps_card_admin || true; - docker rm gps_card_admin || true; - docker rmi -f $(docker images | grep registry.cn-shanghai.aliyuncs.com/gps_card/gps_card_admin | awk '{print $3}') + docker stop gps_card_admin_web || true; + docker rm gps_card_admin_web || true; + docker rmi -f $(docker images | grep registry.cn-shanghai.aliyuncs.com/gps_card/gps_card_admin_web | awk '{print $3}') #docker login --username=telpo_linwl@1111649216405698 --password=telpo#1234 registry.cn-shanghai.aliyuncs.com; docker login --username=rzl_wangjx@1111649216405698 --password=telpo.123 registry.cn-shanghai.aliyuncs.com - docker pull registry.cn-shanghai.aliyuncs.com/gps_card/gps_card_admin:$version - docker run -p 8802:80 -d --restart=always --name gps_card_admin registry.cn-shanghai.aliyuncs.com/gps_card/gps_card_admin:$version; + docker pull registry.cn-shanghai.aliyuncs.com/gps_card/gps_card_admin_web:$version + docker run -p 8803:80 -d --restart=always --name gps_card_admin_web registry.cn-shanghai.aliyuncs.com/gps_card/gps_card_admin_web:$version; #删除产生的None镜像 docker rmi -f $(docker images | grep none | awk '{print $3}') docker ps -a elif [[ ${environment} == 'test' ]]; then echo "开始在测试环境远程构建容器" - docker stop gps_card_admin || true - docker rm gps_card_admin || true - docker rmi -f $(docker images | grep 139.224.254.18:5000/gps_card_admin | awk '{print $3}') - docker pull 139.224.254.18:5000/gps_card_admin:$version - docker run -p 8802:80 -d --restart=always --name gps_card_admin 139.224.254.18:5000/gps_card_admin:$version; + docker stop gps_card_admin_web || true + docker rm gps_card_admin_web || true + docker rmi -f $(docker images | grep 139.224.254.18:5000/gps_card_admin_web | awk '{print $3}') + docker pull 139.224.254.18:5000/gps_card_admin_web:$version + docker run -p 8803:80 -d --restart=always --name gps_card_admin_web 139.224.254.18:5000/gps_card_admin_web:$version; #删除产生的None镜像 docker rmi -f $(docker images | grep none | awk '{print $3}') docker ps -a diff --git a/setup_development.sh b/setup_development.sh index f826e71..eba347c 100644 --- a/setup_development.sh +++ b/setup_development.sh @@ -1,7 +1,7 @@ ### # @Author: JinxuChen # @Date: 2021-11-15 - # @LastEditTime: 2021-12-02 09:21:48 + # @LastEditTime: 2021-12-02 15:19:22 # @LastEditors: JinxuChen # @Description: In User Settings Edit # @FilePath: \GpsCardAdmin\setup_development.sh @@ -13,18 +13,18 @@ npm config list npm install npm run build-test image_version=`date +%Y%m%d%H%M`; -docker stop gps_card_admin || true; +docker stop gps_card_admin_web || true; # 删除gps_parent_web容器 -docker rm gps_card_admin || true; +docker rm gps_card_admin_web || true; # 删除镜像 -docker rmi -f $(docker images | grep telpo/gps_card_admin | awk '{print $3}') -# 构建telpo/gps_card_admin:$image_version镜像 -docker build . -t telpo/gps_card_admin:$image_version; +docker rmi -f $(docker images | grep telpo/gps_card_admin_web | awk '{print $3}') +# 构建telpo/gps_card_admin_web:$image_version镜像 +docker build . -t telpo/gps_card_admin_web:$image_version; #删除产生的None镜像 docker rmi -f $(docker images | grep none | awk '{print $3}') # 查看镜像列表 docker images; # 启动容器 -docker run -p 8802:80 -d --restart=always --name gps_card_admin telpo/gps_card_admin:$image_version; +docker run -p 8803:80 -d --restart=always --name gps_card_admin_web telpo/gps_card_admin_web:$image_version; # 查看日志 -docker logs gps_card_admin; +docker logs gps_card_admin_web; diff --git a/setup_production.sh b/setup_production.sh index 0333cd3..b0947a5 100644 --- a/setup_production.sh +++ b/setup_production.sh @@ -1,7 +1,7 @@ ### # @Author: JinxuChen # @Date: 2021-11-15 - # @LastEditTime: 2021-12-02 09:22:02 + # @LastEditTime: 2021-12-02 15:17:27 # @LastEditors: JinxuChen # @Description: In User Settings Edit # @FilePath: \GpsCardAdmin\setup_production.sh @@ -12,15 +12,15 @@ npm install npm run build image_version=$version; # 删除镜像 - docker rmi -f $(docker images | grep registry.cn-shanghai.aliyuncs.com/gps_card/gps_card_admin | awk '{print $3}') + docker rmi -f $(docker images | grep registry.cn-shanghai.aliyuncs.com/gps_card/gps_card_admin_web | awk '{print $3}') -docker build . -t telpo/gps_card_admin:$image_version; +docker build . -t telpo/gps_card_admin_web:$image_version; #TODO:推送镜像到阿里仓库 echo '=================开始推送镜像=======================' #docker login --username=telpo_linwl@1111649216405698 --password=telpo#1234 registry.cn-shanghai.aliyuncs.com; docker login --username=rzl_wangjx@1111649216405698 --password=telpo.123 registry.cn-shanghai.aliyuncs.com -docker tag telpo/gps_card_admin:$image_version registry.cn-shanghai.aliyuncs.com/gps_card/gps_card_admin:$image_version -docker push registry.cn-shanghai.aliyuncs.com/gps_card/gps_card_admin:$image_version +docker tag telpo/gps_card_admin_web:$image_version registry.cn-shanghai.aliyuncs.com/gps_card/gps_card_admin_web:$image_version +docker push registry.cn-shanghai.aliyuncs.com/gps_card/gps_card_admin_web:$image_version echo '=================推送镜像完成=======================' #删除产生的None镜像 docker rmi -f $(docker images | grep none | awk '{print $3}') diff --git a/setup_test.sh b/setup_test.sh index 7db5e67..f15b3e0 100644 --- a/setup_test.sh +++ b/setup_test.sh @@ -1,7 +1,7 @@ ### # @Author: JinxuChen # @Date: 2021-11-15 - # @LastEditTime: 2021-12-02 09:22:16 + # @LastEditTime: 2021-12-02 15:17:38 # @LastEditors: JinxuChen # @Description: In User Settings Edit # @FilePath: \GpsCardAdmin\setup_test.sh @@ -16,14 +16,14 @@ npm run build-test image_version=$version # 删除镜像 docker rmi -f $( - docker images | grep 139.224.254.18:5000/gps_card_admin | awk '{print $3}' + docker images | grep 139.224.254.18:5000/gps_card_admin_web | awk '{print $3}' ) # 构建gps_card_admin:$image_version镜像 -docker build . -t telpo/gps_card_admin:$image_version; +docker build . -t telpo/gps_card_admin_web:$image_version; #TODO:推送镜像到私有仓库 echo '=================开始推送镜像=======================' -docker tag telpo/gps_card_admin:$image_version 139.224.254.18:5000/gps_card_admin:$image_version -docker push 139.224.254.18:5000/gps_card_admin:$image_version +docker tag telpo/gps_card_admin_web:$image_version 139.224.254.18:5000/gps_card_admin_web:$image_version +docker push 139.224.254.18:5000/gps_card_admin_web:$image_version echo '=================推送镜像完成=======================' #删除产生的None镜像 docker rmi -f $(docker images | grep none | awk '{print $3}')