1
0
mirror of https://github.com/142vip/408CSFamily.git synced 2026-04-05 03:27:57 +08:00

refactor(script):脚本配置文件修改

- 提供页面部署脚本
- Dockerfile修改,优化构建步骤
- nginx配置文件修改,自定义端口
-
This commit is contained in:
喜欢芝士的妹妹
2022-06-22 09:28:12 +08:00
parent 6d363326a0
commit 3f7784318d
4 changed files with 96 additions and 7 deletions

View File

@@ -16,5 +16,6 @@ FROM registry.cn-hangzhou.aliyuncs.com/142vip/nginx:latest
# 将dist文件中的内容复制到 /usr/share/nginx/html/ 这个目录下面 注意:--from参数
COPY --from=build_base /apps/docs/.vuepress/dist/ /usr/share/nginx/html/
## 暴露端口
EXPOSE 80
COPY nginx.conf /etc/nginx/
EXPOSE 7000
CMD ["nginx", "-g", "daemon off;"]

42
nginx.conf Normal file
View File

@@ -0,0 +1,42 @@
# 参考https://www.likecs.com/ask-1256888.html
user root;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile off;
access_log off;
keepalive_timeout 3000;
server {
listen 7000;
server_name localhost;
#charset koi8-r;
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log error;
## 静态资源代理
location / {
gzip on; #开启或关闭gzip on off
gzip_disable "msie6"; #不使用gzip IE6
gzip_min_length 100k; #gzip压缩最小文件大小超出进行压缩自行调节
gzip_buffers 4 16k; #buffer 不用修改
gzip_comp_level 8; #压缩级别:1-10数字越大压缩的越好时间也越长
gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; # 压缩文件类型
# root 根目录默认nginx镜像的html文件夹可以指定其他
root /usr/share/nginx/html;
index index.html index.htm;
# 如果vue-router使用的是history模式需要设置这个
try_files $uri $uri/ /index.html;
}
## 错误页面
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}

View File

@@ -15,6 +15,8 @@ readonly warnLogger="\033[1;33m"
readonly currentTime=$(date "+%Y-%m-%d %H:%M:%S")
## 项目名称
readonly projectName="408CSFamily"
## 仓库地址
readonly repoAddress="registry.cn-hangzhou.aliyuncs.com/142vip/doc_book:"
## 版本号
version=${1}
@@ -28,7 +30,7 @@ prepare_check(){
run(){
echo -e "${successLogger}---------------- shell doc_book start ---------------- "
docker build -t registry.cn-hangzhou.aliyuncs.com/142vip/doc_book:"${projectName}_${version}" .
docker build -t "${repoAddress}${projectName}_${version}" .
echo -e "${successLogger}---------------- shell doc_book end ---------------- "
push_docker_image
}
@@ -38,14 +40,14 @@ run(){
push_docker_image(){
if [[ "$(docker images -q registry.cn-hangzhou.aliyuncs.com/142vip/doc_book:"${projectName}_${version}" 2> /dev/null)" != "" ]];
if [[ "$(docker images -q "${repoAddress}${projectName}_${version}" 2> /dev/null)" != "" ]];
then
## 推送
docker push registry.cn-hangzhou.aliyuncs.com/142vip/doc_book:"${projectName}_${version}"
docker push "${repoAddress}${projectName}_${version}"
echo -e "${successLogger}---------------- 上传镜像成功,删除本地镜像 ---------------- "
docker rmi registry.cn-hangzhou.aliyuncs.com/142vip/doc_book:"${projectName}_${version}"
docker rmi "${repoAddress}${projectName}_${version}"
else
echo -e "${errorLogger}${currentTime}:镜像:registry.cn-hangzhou.aliyuncs.com/142vip/doc_book:${projectName}_${version}不存在"
echo -e "${errorLogger}${currentTime}:镜像:${repoAddress}${projectName}_${version}不存在"
fi
exit 0
}

44
scripts/page_deploy.sh Normal file
View File

@@ -0,0 +1,44 @@
#!/usr/bin/env sh
###
# @Description: 静态资源网站部署脚本
# @Version: Beta1.0
# @Author: 【B站&公众号】Rong姐姐好可爱
# @Date: 2021-02-19 22:34:57
# @LastEditors: 【B站&公众号】Rong姐姐好可爱
# @LastEditTime: 2022-04-18 23:35:15
###
commitInfo=${1}
set -e
# 进入上级目录,并编译
npm run build
## 切换到dist文件目录
cd docs/.vuepress/dist
git init
git add -A
## 如果没有输入commit信息则采用默认
if [ "${commitInfo}" -eq "" ]; then
commitInfo="408CSFamily page init"
fi
git commit -m "refactor:${commitInfo}"
## 配置个人信息
git config user.name "喜欢吃芝士葡萄的妹妹"
git config user.email "fairy0115@2925.com"
# if you are deploying to https://<USERNAME>.github.io
# git push -f git@github.com:<USERNAME>/<USERNAME>.github.io.git master
# if you are deploying to https://<USERNAME>.github.io/<REPO>
git push -f https://github.com/mmdapl/JavaScriptCollection.git master:pages/github
cd -