From 497fd0d9cf52624859ba8fa59a4db947dfe2931e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=96=9C=E6=AC=A2=E8=8A=9D=E5=A3=AB=E7=9A=84=E5=A6=B9?= =?UTF-8?q?=E5=A6=B9?= Date: Wed, 1 Feb 2023 22:06:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E9=95=9C=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 9 ++++++--- nginx.conf | 3 ++- scripts/build_image.sh | 18 ++++++++---------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 44dc03f..11b5173 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,10 +4,11 @@ LABEL version="Beta1.0" description="408CSFamily合集" LABEL author="【Github&公众号】:Rong姐姐好可爱" email="fairy@2925.com" RUN mkdir -p /apps ## 确定工作空间 /apps -COPY . /apps WORKDIR /apps +COPY . /apps + ## 安装依赖 -RUN npm ci --registry https://registry.npmmirror.com && npm run build +RUN npm i pnpm@6 -g && pnpm i -D && npm run build @@ -16,5 +17,7 @@ FROM registry.cn-hangzhou.aliyuncs.com/142vip/nginx:1.23.0-alpine COPY --from=build_base /apps/docs/.vuepress/dist/ /usr/share/nginx/html/ COPY nginx.conf /etc/nginx/ + EXPOSE 7000 -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file + +#CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/nginx.conf b/nginx.conf index 3bcf9f0..d362566 100644 --- a/nginx.conf +++ b/nginx.conf @@ -2,6 +2,7 @@ user root; worker_processes auto; error_log /var/log/nginx/error.log warn; + events { worker_connections 1024; } @@ -15,7 +16,7 @@ http { listen 7000; server_name localhost; -# access_log /var/log/nginx/access.log main; + #access_log /var/log/nginx/access.log main; error_log /var/log/nginx/error.log error; ## 静态资源代理 location / { diff --git a/scripts/build_image.sh b/scripts/build_image.sh index 0800b4e..b280da5 100644 --- a/scripts/build_image.sh +++ b/scripts/build_image.sh @@ -1,7 +1,7 @@ #!/bin/bash ## 功能:本地前后端项目构建、打包镜像,上传docker仓库 ## 参考:https://blog.csdn.net/Dontla/article/details/125210694 -## 作者:Rong姐姐好可爱 +## 作者:储凡 ## 使用示例:bash xxx.sh 版本号 ## - bash build_image.sh 0.0.1 ## @@ -29,9 +29,9 @@ prepare_check(){ } run(){ - echo -e "${successLogger}---------------- shell doc_book start ---------------- " - docker build -t "${repoAddress}${projectName}_${version}" . - echo -e "${successLogger}---------------- shell doc_book end ---------------- " + echo -e "${successLogger}---------------- shell ${projectName} start ---------------- " + docker build -t "${repoAddress}${projectName}-${version}" . + echo -e "${successLogger}---------------- shell ${projectName} end ---------------- " push_docker_image } @@ -40,20 +40,18 @@ run(){ ## 推送镜像 push_docker_image(){ - if [[ "$(docker images -q "${repoAddress}${projectName}_${version}" 2> /dev/null)" != "" ]]; + if [[ "$(docker images -q "${repoAddress}${projectName}-${version}" 2> /dev/null)" != "" ]]; then ## 推送 - docker push "${repoAddress}${projectName}_${version}" + docker push "${repoAddress}${projectName}-${version}" echo -e "${successLogger}---------------- 上传镜像成功,删除本地镜像 ---------------- " - docker rmi "${repoAddress}${projectName}_${version}" + docker rmi "${repoAddress}${projectName}-${version}" else - echo -e "${errorLogger}${currentTime}:镜像:${repoAddress}${projectName}_${version}不存在" + echo -e "${errorLogger}${currentTime}:镜像:${repoAddress}${projectName}-${version}不存在" fi exit 0 } - - prepare_check run