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

feat(docs):新增文档

This commit is contained in:
喜欢芝士的妹妹
2022-06-23 08:53:19 +08:00
parent 3f7784318d
commit e2b229ff03
63 changed files with 4498 additions and 171 deletions

View File

@@ -38,7 +38,7 @@ run(){
## 推送镜像
push_docker_image(){
if [[ "$(docker images -q "${repoAddress}${projectName}_${version}" 2> /dev/null)" != "" ]];
then

145
scripts/deploy.bash Normal file
View File

@@ -0,0 +1,145 @@
#!/bin/bash
## 功能:清除容器,删除旧镜像,创建新的容器
## 参考https://blog.csdn.net/Dontla/article/details/125210694
## 作者Rong姐姐好可爱
## 使用示例bash xxx.sh 容器名称 镜像地址
##
## 日志颜色定义
readonly successLogger="\033[36m"
readonly errorLogger="\033[1;31m"
readonly warnLogger="\033[1;33m"
## 定义时间
readonly currentTime=$(date "+%Y-%m-%d %H:%M:%S")
readonly repoAddress="registry.cn-hangzhou.aliyuncs.com/142vip/doc_book"
readonly containerName="408CSFamily"
readonly networkName="service_env_net"
## 定义参数
operationName=${1}
version=${2}
## 参数检查
prepare_check(){
if test -z "${containerName}"
then
echo -e "${errorLogger}${currentTime}:参数错误 部署平台不能为空."
exit 0
fi
}
## 判断容器存在即删除
## - 一个参数,容器名称
delete_container(){
docker inspect "${1}" -f '{{.Name}}' > /dev/null
if [ $? -eq 0 ] ;then
echo -e "${warnLogger}${currentTime}容器:${1} 存在,现进行删除"
docker rm -f "${1}"
fi
}
## 判断镜像存在,即删除
## - 一个参数,镜像地址
delete_image(){
## 判断版本号
if test -z "${version}";then
echo -e "${errorLogger}${currentTime}:参数错误 镜像版本号不能为空."
exit 0
fi
if [[ "$(docker images -q "${1}" 2> /dev/null)" != "" ]];
then
echo -e "${warnLogger}${currentTime}镜像:${1}存在,现进行删除"
docker rmi "${1}"
fi
}
## 环境初始成功
run(){
if [ "${operationName}" == "gitee" ];then
## 查看所有
deploy_to_gitee
exit 0;
elif [ "${operationName}" == "github" ]; then
deploy_to_github
exit 0;
elif [ "${operationName}" == "ali" ]; then
## 删除容器
delete_container "${containerName}"
## 删除镜像
delete_image "${repoAddress}:${containerName}_${version}"
## 部署
deploy_to_ali
exit 0;
else
echo -e "${errorLogger}${currentTime}当前操作不支持,目前只支持:ali/gitee/github"
exit 0
fi
}
## 部署到阿里服务器
deploy_to_ali(){
echo -e "${successLogger}---------------- deploy ${containerName} ali start ---------------- "
docker run -d --name "${containerName}" \
-p 7000:7000 \
--network="${networkName}" \
--restart=unless-stopped \
--ip=172.30.0.200 \
"${repoAddress}:${containerName}_${version}"
echo -e "${successLogger}---------------- deploy ${containerName} ali end ------------------ "
docker ps
}
## 部署到github静态资源托管
deploy_to_github(){
echo -e "${successLogger}---------------- deploy ${containerName} github start ---------------- "
# 当命令以非零状态退出时则退出shell
set -e
# 进入上级目录,并编译
npm run build && cd docs/.vuepress/dist
git init && git add --all
## 如果没有输入commit信息则采用默认
if [ "${commitInfo}" -eq "" ]; then
commitInfo="408CSFamily Init"
fi
git commit -m "refactor:${commitInfo}"
## 配置个人信息
git config user.name "晚上吃芝士+葡萄的妹妹"
git config user.email "fairy0115@2925.com"
git config --list
# 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/408CSFamily.git master:pages/github
cd -
echo -e "${successLogger}---------------- deploy ${containerName} github end ------------------ "
}
## 部署到gitee静态资源托管
deploy_to_gitee(){
exit 0
}
prepare_check
run

View File

@@ -54,7 +54,7 @@ run(){
echo -e "${successLogger}---------------- shell rm start ---------------- "
exit 0;
else
echo -e "${errorLogger}当前操作不支持,目前只支持:ls/init/rm"
echo -e "${errorLogger}当前操作不支持,目前只支持:ls/init/rm"
exit 0
fi
}
@@ -78,7 +78,8 @@ init_network(){
"${defaultNetworkName}"
echo -e "${successLogger}---------------- 创建后 ---------------------"
docker network ls
docker netwrok inspect "${networkName}"
echo -e "${successLogger}---------------- 网络信息 ---------------------"
docker netwrok inspect "${defaultNetworkName}"
fi
}
@@ -96,7 +97,7 @@ remove_network(){
fi
echo -e "${successLogger}----------------删除前---------------------"
docker network ls
docker network ls
docker network rm "${networkName}"
echo -e "${successLogger}----------------删除后---------------------"
docker network ls

View File

@@ -31,7 +31,7 @@ git commit -m "refactor:${commitInfo}"
## 配置个人信息
git config user.name "喜欢吃芝士葡萄的妹妹"
git config user.name "晚上吃芝士+葡萄的妹妹"
git config user.email "fairy0115@2925.com"
# if you are deploying to https://<USERNAME>.github.io

View File

@@ -1,125 +0,0 @@
#!/bin/bash
## 功能:清除容器,删除旧镜像,创建新的容器
## 参考https://blog.csdn.net/Dontla/article/details/125210694
## 作者Rong姐姐好可爱
## 使用示例bash xxx.sh 容器名称 镜像地址
##
## 日志颜色定义
readonly successLogger="\033[36m"
readonly errorLogger="\033[1;31m"
readonly warnLogger="\033[1;33m"
## 定义时间
readonly currentTime=$(date "+%Y-%m-%d %H:%M:%S")
## 定义参数
containerName=${1}
imageName=${2}
## 参数检查
prepare_check(){
if test -z "${containerName}"
then
echo -e "${errorLogger}${currentTime}参数错误 容器名称不能为空。脚本执行eg bash xxx.sh 容器名称 镜像地址"
exit 0
fi
if test -z "${imageName}";then
echo -e "${errorLogger}${currentTime}参数错误 镜像地址不能为空。脚本执行eg bash xxx.sh 容器名称 镜像地址"
exit 0
fi
}
## 判断容器存在即删除
delete_container(){
docker inspect "${containerName}" -f '{{.Name}}' > /dev/null
if [ $? -eq 0 ] ;then
echo -e "${warnLogger}${currentTime}容器:${containerName} 存在,现进行删除"
docker rm -f "${containerName}"
fi
}
## 判断镜像存在,即删除
delete_image(){
if [[ "$(docker images -q "${imageName}" 2> /dev/null)" != "" ]];
then
echo -e "${warnLogger}${currentTime}镜像:${imageName}存在,现进行删除"
docker rmi "${imageName}"
fi
}
## 环境初始成功
run(){
if [ "$operationName" == "client_web" ];then
## 查看所有
deploy_client_web
exit 0;
elif [ "$operationName" == "oauth_login" ]; then
deploy_oauth_login
exit 0;
elif [ "$operationName" == "server_api" ]; then
deploy_server_api
exit 0;
else
echo -e "${errorLogger}当前操作不支持,目前只支持:ls/init/rm"
exit 0
fi
}
## 创建容器,进行部署
deploy(){
## 执行docker容器创建
docker run -d --name="${containerName}" \
-p 4000:4000 \
--restart=always \
"${imageName}"
}
deploy_client_web(){
echo -e "${successLogger}---------------- deploy client_web start ---------------- "
docker run -d --name oauth2-client \
-p 8080:80 --network=tencent-net \
--ip=172.22.0.10 \
--restart=unless-stopped
echo -e "${successLogger}---------------- deploy client_web end ------------------ "
}
deploy_oauth_login(){
echo -e "${successLogger}---------------- deploy oauth_login start ---------------- "
docker run -d --name="${containerName}" \
-p 4000:4000 \
--restart=always \
"${imageName}"
echo -e "${successLogger}---------------- deploy oauth_login end ------------------ "
}
deploy_server_api(){
echo -e "${successLogger}---------------- deploy server_api start ---------------- "
docker run -d --name="${containerName}" \
-p 4000:4000 \
--restart=always \
"${imageName}"
echo -e "${successLogger}---------------- deploy server_api end ------------------ "
}
prepare_check
### 处理容器和镜像,更新初始化
delete_container
delete_image
### 运行,镜像更新
run